MCPcopy Index your code
hub / github.com/cenkalti/dalga

github.com/cenkalti/dalga @v4.0.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v4.0.1 ↗ · + Follow
163 symbols 704 edges 23 files 59 documented · 36%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Dalga

Dalga is a job scheduler. It's like cron-as-a-service.

  • Can schedule periodic or one-off jobs.
  • Stores jobs in a MySQL table with location info.
  • Has an HTTP interface for scheduling and cancelling jobs.
  • Makes a POST request to the endpoint defined in config on the job's execution time.
  • Retries failed jobs with constant or exponential backoff.
  • Multiple instances can be run for high availability and scaling out.

Install

Use pre-built Docker image:

$ docker run -e DALGA_MYSQL_HOST=mysql.example.com cenkalti/dalga

or download the latest binary from releases page.

Usage

See example config file for configuration options. TOML and YAML file formats are supported. Configuration values can also be set via environment variables with DALGA_ prefix.

First, you must create the table for storing jobs:

$ dalga -config dalga.toml -create-tables

Then, run the server:

$ dalga -config dalga.toml

Schedule a new job to run every 60 seconds:

$ curl -i -X PUT 'http://127.0.0.1:34006/jobs/check_feed/1234?interval=60'
HTTP/1.1 201 Created
Content-Type: application/json; charset=utf-8
Date: Tue, 11 Nov 2014 22:10:40 GMT
Content-Length: 83

{"path":"check_feed","body":"1234","interval":60,"next_run":"2014-11-11T22:11:40Z"}

PUT always returns 201. If there is an existing job with path and body, it will be rescheduled.

There are 4 options that you can pass to Schedule but not every combination is valid:

Param Description Type Example
interval Run job at intervals Integer or ISO 8601 interval 60 or PT60S
first-run Do not run job until this time RFC3339 Timestamp 1985-04-12T23:20:50.52Z
one-off Run job only once Boolean true, false, 1, 0
immediate Run job immediately as it is scheduled Boolean true, false, 1, 0

60 seconds later, Dalga makes a POST to your endpoint defined in config:

Path: <config.baseurl>/<job.path>
Body: <job.body>

The endpoint must return 200 if the job is successful.

The endpoint may return 204 if job is invalid. In this case Dalga will remove the job from the table.

Anything other than 200 or 204 makes Dalga to retry the job indefinitely with an exponential backoff.

Get the status of a job:

$ curl -i -X GET 'http://127.0.0.1:34006/jobs/check_feed/1234'
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Tue, 11 Nov 2014 22:12:21 GMT
Content-Length: 83

{"path":"check_feed","body":"1234","interval":60,"next_run":"2014-11-11T22:12:41Z"}

GET may return 404 if job is not found.

Cancel previously scheduled job:

$ curl -i -X DELETE 'http://127.0.0.1:34006/jobs/check_feed/1234'
HTTP/1.1 204 No Content
Date: Tue, 11 Nov 2014 22:13:35 GMT

Extension points exported contracts — how you extend this code

ClientOpt (FuncType)
ClientOpt is an option that can be provided to a Dalga client.
client.go
Scanner (Interface)
(no doc)
internal/table/table.go
ScheduleOpt (FuncType)
ScheduleOpt is an option that can be provided to the Schedule method.
client.go

Core symbols most depended-on inside this repo

String
called by 49
internal/table/job.go
Add
called by 42
internal/clock/clock.go
Set
called by 35
internal/clock/clock.go
Close
called by 28
dalga.go
Run
called by 21
dalga.go
Addr
called by 17
config.go
Get
called by 15
internal/table/table.go
NotifyDone
called by 11
dalga.go

Shape

Method 85
Function 52
Struct 22
FuncType 2
Interface 1
Route 1

Languages

Go99%
Python1%

Modules by API surface

internal/table/table.go31 symbols
client.go22 symbols
internal/server/server.go15 symbols
internal/jobmanager/jobmanager.go12 symbols
internal/table/job.go9 symbols
internal/scheduler/scheduler.go9 symbols
internal/log/log.go7 symbols
internal/instance/instance.go7 symbols
dalga.go7 symbols
config.go7 symbols
internal/clock/clock.go6 symbols
internal/scheduler/benchmark_test.go4 symbols

For agents

$ claude mcp add dalga \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page