job

Golang library for job scheduling.

About The Project

Job – small library, that provides api for task scheduling. Package has some benefits unlike known implementations:

  • laconic api
  • context package support

Usage

Start job:

job := New(func(_ context.Context) {
	// your logic here
})
err := job.Start(0, time.Second)

Start job in context:

job := New(func(_ context.Context) {
	// your logic here
})
ctx, cancel := context.WithCancel(context.Background())
go func() {
    // wait some event
    cancel()
}()
err := job.StartContext(ctx, 0, time.Second)

Stop job:

err := job.Stop()

Stop job with context:

ctx, cancel := context.WithCancel(context.Background())
go func() {
    // wait some event
    cancel()
}()
err := job.StopContext(ctx)

Similar projects

License

Retry is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.

Contact

GitHub

View Github