https://github.com/apigear-io/scheduler
a go job scheduler based on timer ticks
https://github.com/apigear-io/scheduler
Last synced: 4 months ago
JSON representation
a go job scheduler based on timer ticks
- Host: GitHub
- URL: https://github.com/apigear-io/scheduler
- Owner: apigear-io
- License: mit
- Created: 2023-03-22T12:26:19.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-22T14:18:43.000Z (over 2 years ago)
- Last Synced: 2025-01-18T11:27:02.890Z (5 months ago)
- Language: Go
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Job scheduler
A job scheduler is a system that is used to schedule jobs to run at an interval. It is used to schedule jobs that are not time critical and can be run at a later time.
The scheduler is not ware of any time or time location. It is based on a time interval. The time interval is the time between the current time and the time the job is scheduled to run. All time presented here are in milliseconds.
When a job is finished the job will automatically be removed from the scheduler. If you want to run the job again you need to create a new job.
The scheduler reschedules the job to run at the next interval, if it is repeated or runs forever. If a job is scheduled in the past it will run immediately.
This scheduler is inspired by Go-Cron (https://github.com/jasonlvhit/gocron). It is a great cron-scheduler but I wanted to have something more lean and no need for time and location support. Something which can be used to drive a world simulation.
## Installation
```bash
go get github.com/apigear-io/scheduler
```## Usage
```go
s := scheduler.New(time.Millisecond * 10)
s.CreateJob().Every(time.Millisecond * 100).Do(func(t, dt int64) {
fmt.Printf("tick: %d, delta-tick: %d\n", t, dt)
})
s.Run()
```