(WORK IN PROGRESS)
A Go REST API service for programmatic job scheduling using the declarative shell functional core design pattern.
- Functional Core with pure business logic
- Imperative Shell for side effects (HTTP, storage, scheduling)
- CRUD operations for scheduled jobs
- Job control endpoints (run, pause, resume)
- Standard 5-field cron scheduling
- SQLite database storage
- Background job execution
- Install dependencies:
go mod tidy- Build and run the service:
go run cmd/server/main.goThe service will start on http://localhost:5000 with the scheduler running in the background.
POST /api/scheduler/v1/jobs- Create a new jobGET /api/scheduler/v1/jobs- Get all jobs (supports ?status= and ?name= filters)GET /api/scheduler/v1/jobs/{id}- Get specific jobPUT /api/scheduler/v1/jobs/{id}- Update job (full replacement)PATCH /api/scheduler/v1/jobs/{id}- Partial update jobDELETE /api/scheduler/v1/jobs/{id}- Delete job
POST /api/scheduler/v1/jobs/{id}/run- Run job immediatelyPOST /api/scheduler/v1/jobs/{id}/pause- Pause jobPOST /api/scheduler/v1/jobs/{id}/resume- Resume paused job
GET /api/scheduler/v1/jobs/{id}/runs- List all runs for a jobGET /api/scheduler/v1/jobs/{id}/runs/{run_id}- Get specific run details
Jobs are authenticated via the X-Rh-Identity header. The org_id, username, and user_id are automatically extracted from this header and not exposed in API responses.
{
"id": "string (UUID)",
"name": "string",
"schedule": "string (5-field cron expression)",
"type": "string (message|http_request|command|export)",
"payload": {},
"status": "string (scheduled|running|paused|failed)",
"last_run": "string (ISO timestamp)"
}Note: The payload field can be any valid JSON value (object, array, string, number, boolean, or null). Its structure depends on the job type.
The service accepts standard 5-field cron expressions:
- Format:
minute hour day-of-month month day-of-week
Common examples:
*/10 * * * *- Every 10 minutes0 * * * *- Every hour at minute 00 0 * * *- Every day at midnight0 0 1 * *- Every month on the 1st at midnight30 14 * * MON-FRI- Every weekday at 2:30 PM0 9 * * 1- Every Monday at 9:00 AM
Run the test suite:
go run cmd/test/main.goMake sure the service is running before executing tests.
domain/- Pure domain models and validation logicusecases/- Business logic with dependency interfaces
http/- HTTP handlers and routingstorage/- In-memory repository implementationscheduler/- Background schedulingexecutor/- Job execution logic
server/- Main application servertest/- API test client

