Skip to content

jenchik/workers

Repository files navigation

Worker

GoDoc Build Status codecov Go Report Card codebeat badge GolangCI

Package worker adding the abstraction layer around background jobs, allows make a job periodically, observe execution time and to control concurrent execution.

Group of workers allows to control jobs start time and wait until all runned workers finished when we need stop all jobs.

Features

  • Scheduling, use one from existing workers.By* schedule functions. Supporting cron schedule spec format by robfig/cron parser.
  • Graceful stop, wait until all running jobs was completed.

Example

wg := workers.NewGroup(context.Background())
wg.Add(
    workers.
        New(func(context.Context) {}).
        ByTicker(time.Second),

    workers.
        New(func(context.Context) {}).
        ByTimer(time.Second),

    workers.
        New(func(context.Context) {}).
        ByCronSpec("@every 1s"),
)
wg.Run()

See more examples here

About

test workers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages