Centralized Lock for Distributed Systems for Go Schedule Tasks

  • Kubernetes
  • Docker Swarm
  • AWS ECS Fargate
go get github.com/ehsaniara/gointerlock

Local Scheduler (Single App)

var job = gointerlock.GoInterval{
Interval: 2 * time.Second,
Arg: myJob,
}
err := job.Run(ctx)
if err != nil {
log.Fatalf("Error: %s", err)
}

Examples

Distributed Mode (Scaled Up)

Redis (Recommended)

Existing Redis Connection

var redisConnector = redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "myRedisPassword",
DB: 0,
})
var job = gointerlock.GoInterval{
Interval: 2 * time.Second,
Arg: myJob,
Name: "MyTestJob",
RedisConnector: redisConnector,
}
err := jobTicker.Run(ctx)
if err != nil {
log.Fatalf("Error: %s", err)
}
func myJob() {
fmt.Println(time.Now(), " - called")
}

Centralized lock for the Distributed Systems (No Timer/Scheduler)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store