Orbis is a robust and lightweight cron scheduler, crafted in the Go programming language. It features an API server that serves as an interface to the scheduler. Orbis leverages Postgres for storing cron jobs and employs a resizable goroutine pool to achieve efficient concurrency.
To interpret scheduling expressions, Orbis utilizes the cronexpr
library (available at github.com/gorhill/cronexpr). This library enables Orbis to accurately determine when commands should be activated based on the provided schedule.
-
Concurrency: Leveraging Go’s goroutines, Orbis efficiently handles multiple jobs simultaneously.
-
Flexibility: Supports standard cron expressions for flexible scheduling.
-
Simplicity: Minimal setup required with clear separation of concerns between scheduling and execution.
-
Cronexpr - https://github.com/gorhill/cronexpr
Orbis is built on top of Go’s powerful concurrency model and integrates seamlessly with popular libraries such as Gin for web routing and Cronexpr for cron expression parsing.
Clone the repository -> https://github.com/heyyakash/orbis
go to the root folder and create a new file called .env
touch .env
Populate the .env file with following information (using the same is fine for testing)
POSTGRES_PASSWORD = mysecret
POSTGRES_USER = postgres
POSTGRES_DB = postgres
POSTGRES_PORT = 5432
POSTGRES_HOST = pg-image
POOL = 5
-
POSTGRES_PASSWORD
: refers to the password for postgres database -
POSTGRES_USER
: refers to the user of the postgres database -
POSTGRES_DB
: refers to the database that will store the table -
POSTGRES_PORT
: refers to the port at which the postgres db will run -
POSTGRES_HOST
: refers to the host address for the PostgreSQL database (usually the name of the PostgreSQL container). -
POOL
: refers to the size of goroutine pool
Run the following command to start the scheduler
docker compose up
Check whether the scheduler is running or not by running the following (assuming the scheduler is running on the port 8080)
curl localhost:8080/ping
This should return the following result
{"message":"pong"}
POST /set
curl -X POST \
'http://localhost:8080/set' \
--header 'Accept: */*' \
--header 'User-Agent: Thunder Client (https://www.thunderclient.com)' \
--header 'Content-Type: application/json' \
--data-raw '{
"command":"echo Akash Sharma",
"schedule":"*/1 * * * *"
}'
Returns the id of the job created
{
"message": "Added job with id : 3"
}
GET : /:id
curl -X GET 'http://localhost:8080/13'
Returns the job with the given id
{
"JobId": 3,
"Command": "curl localhost:8080/ping",
"Schedule": "*/1 * * * *",
"NextRun": "2024-07-22T09:25:00Z"
}
GET /all
curl -X GET \
'http://localhost:8080/all'
returns all jobs
{
"data": [
{
"JobId": 1,
"Command": "echo Akash D",
"Schedule": "*/1 * * * *",
"NextRun": "2024-07-22T09:26:00Z"
},
{
"JobId": 2,
"Command": "curl localhost:8080/ping",
"Schedule": "*/1 * * * *",
"NextRun": "2024-07-22T09:26:00Z"
},
{
"JobId": 3,
"Command": "curl localhost:8080/ping",
"Schedule": "*/1 * * * *",
"NextRun": "2024-07-22T09:26:00Z"
}
]
}
DELETE /:id
curl -X DELETE 'http://localhost:8080/11'
DELETE /all
curl -X DELETE 'http://localhost:8080/all'
-
Switching to another lightweight database
-
Add Metrics and logging
-
Retry mechanisms