Update README.md

This commit is contained in:
John Roesler
2023-12-13 10:48:53 -06:00
committed by GitHub
parent 9ad844a80f
commit 1177ef07d1
+66 -53
View File
@@ -73,59 +73,72 @@ func main() {
## Features ## Features
- **Job types**: Jobs can be run at various intervals. ### Job types
- [**Duration**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#DurationJob): Jobs can be run at various intervals.
Jobs can be run at a fixed `time.Duration`. - [**Duration**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#DurationJob):
- [**Random duration**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#DurationRandomJob): Jobs can be run at a fixed `time.Duration`.
Jobs can be run at a random `time.Duration` between a min and max. - [**Random duration**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#DurationRandomJob):
- [**Cron**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#CronJob): Jobs can be run at a random `time.Duration` between a min and max.
Jobs can be run using a crontab. - [**Cron**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#CronJob):
- [**Daily**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#DailyJob): Jobs can be run using a crontab.
Jobs can be run every x days at specific times. - [**Daily**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#DailyJob):
- [**Weekly**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#WeeklyJob): Jobs can be run every x days at specific times.
Jobs can be run every x weeks on specific days of the week and at specific times. - [**Weekly**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#WeeklyJob):
- [**Monthly**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#MonthlyJob): Jobs can be run every x weeks on specific days of the week and at specific times.
Jobs can be run every x months on specific days of the month and at specific times. - [**Monthly**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#MonthlyJob):
- **Concurrency Limits**: Jobs can be limited individually or across the entire scheduler. Jobs can be run every x months on specific days of the month and at specific times.
- [**Per job limiting with singleton mode**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithSingletonMode):
Jobs can be limited to a single concurrent execution that either reschedules (skips overlapping executions) ### Concurrency Limits
or queues (waits for the previous execution to finish). Jobs can be limited individually or across the entire scheduler.
- [**Per scheduler limiting with limit mode**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithLimitConcurrentJobs): - [**Per job limiting with singleton mode**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithSingletonMode):
Jobs can be limited to a certain number of concurrent executions across the entire scheduler Jobs can be limited to a single concurrent execution that either reschedules (skips overlapping executions)
using either reschedule (skip when the limit is met) or queue (jobs are added to a queue to or queues (waits for the previous execution to finish).
wait for the limit to be available). - [**Per scheduler limiting with limit mode**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithLimitConcurrentJobs):
- **Note:** A scheduler limit and a job limit can both be enabled. Jobs can be limited to a certain number of concurrent executions across the entire scheduler
- **Distributed instances of gocron**: Multiple instances of gocron can be run. using either reschedule (skip when the limit is met) or queue (jobs are added to a queue to
- [**Elector**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithDistributedElector): wait for the limit to be available).
An elector can be used to elect a single instance of gocron to run as the primary with the - **Note:** A scheduler limit and a job limit can both be enabled.
other instances checking to see if a new leader needs to be elected.
- Implementations: [go-co-op electors](https://github.com/go-co-op?q=-elector&type=all&language=&sort=) ### Distributed instances of gocron
- [**Locker**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithDistributedLocker): Multiple instances of gocron can be run.
A locker can be used to lock each run of a job to a single instance of gocron. - [**Elector**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithDistributedElector):
- Implementations: [go-co-op lockers](https://github.com/go-co-op?q=-lock&type=all&language=&sort=) An elector can be used to elect a single instance of gocron to run as the primary with the
- **Events**: Job events can trigger actions. other instances checking to see if a new leader needs to be elected.
- [**Listeners**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithEventListeners): - Implementations: [go-co-op electors](https://github.com/go-co-op?q=-elector&type=all&language=&sort=)
Can be added to a job, with [event listeners](https://pkg.go.dev/github.com/go-co-op/gocron/v2#EventListener), - [**Locker**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithDistributedLocker):
or all jobs across the A locker can be used to lock each run of a job to a single instance of gocron.
[scheduler](https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithGlobalJobOptions) - Implementations: [go-co-op lockers](https://github.com/go-co-op?q=-lock&type=all&language=&sort=)
to listen for job events and trigger actions.
- **Options**: Many job and scheduler options are available. ### Events
- [**Job options**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#JobOption): Job events can trigger actions.
Job options can be set when creating a job using `NewJob`. - [**Listeners**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithEventListeners):
- [**Global job options**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithGlobalJobOptions): Can be added to a job, with [event listeners](https://pkg.go.dev/github.com/go-co-op/gocron/v2#EventListener),
Global job options can be set when creating a scheduler using `NewScheduler` or all jobs across the
and the `WithGlobalJobOptions` option. [scheduler](https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithGlobalJobOptions)
- [**Scheduler options**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#SchedulerOption): to listen for job events and trigger actions.
Scheduler options can be set when creating a scheduler using `NewScheduler`.
- **Logging**: Logs can be enabled. ### Options
- [Logger](https://pkg.go.dev/github.com/go-co-op/gocron/v2#Logger): Many job and scheduler options are available.
The Logger interface can be implemented with your desired logging library. - [**Job options**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#JobOption):
The provided NewLogger uses the standard library's log package. Job options can be set when creating a job using `NewJob`.
- **Testing**: The gocron library is set up to enable testing. - [**Global job options**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithGlobalJobOptions):
- Mocks are provided in [the mock package](mocks) using [gomock](https://github.com/uber-go/mock). Global job options can be set when creating a scheduler using `NewScheduler`
- Time can be mocked by passing in a [FakeClock](https://pkg.go.dev/github.com/jonboulle/clockwork#FakeClock) and the `WithGlobalJobOptions` option.
to [WithClock](https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithClock) - - [**Scheduler options**](https://pkg.go.dev/github.com/go-co-op/gocron/v2#SchedulerOption):
see the [example on WithClock](https://pkg.go.dev/github.com/go-co-op/gocron/v2#example-WithClock). Scheduler options can be set when creating a scheduler using `NewScheduler`.
### Logging
Logs can be enabled.
- [Logger](https://pkg.go.dev/github.com/go-co-op/gocron/v2#Logger):
The Logger interface can be implemented with your desired logging library.
The provided NewLogger uses the standard library's log package.
### Testing
The gocron library is set up to enable testing.
- Mocks are provided in [the mock package](mocks) using [gomock](https://github.com/uber-go/mock).
- Time can be mocked by passing in a [FakeClock](https://pkg.go.dev/github.com/jonboulle/clockwork#FakeClock)
to [WithClock](https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithClock) -
see the [example on WithClock](https://pkg.go.dev/github.com/go-co-op/gocron/v2#example-WithClock).
## Supporters ## Supporters