• Stars
    star
    249
  • Rank 157,612 (Top 4 %)
  • Language
    Go
  • License
    MIT License
  • Created over 10 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

⏰ MySQL backed Job Scheduler with a HTTP interface

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

More Repositories

1

backoff

⏱ The exponential backoff algorithm in Go
Go
3,192
star
2

rain

🌧 BitTorrent client and library in Go
Go
922
star
3

github-flask

🍾 Flask extension for GitHub API
Python
260
star
4

kuyruk

⚙️ Simple task queue for Python
Python
230
star
5

dominantcolor

Find dominant color in images
Go
113
star
6

rpc2

Bi-directional RPC in Go (Golang)
Go
105
star
7

pypi-notifier

📨 A web service that monitors your requirements.txt files
Python
99
star
8

putio.py

A python wrapper for put.io APIv2
Python
72
star
9

pyhtml

HTML generation library for Python
Python
71
star
10

tus.py

tus (resumable file upload protocol) client in python
Python
34
star
11

what

A helper for testing output of a process in tests.
Python
24
star
12

darbe

RDS MySQL replication setup tool
Python
18
star
13

tcpproxy

TCP proxy server written in Go
Go
13
star
14

resume

My resume
9
star
15

mse

BitTorrent Message Stream Encryption in Go
Go
9
star
16

go-sched

A generally useful event scheduler in Go (Golang).
Go
8
star
17

hub

Simple PubSub (Publish/Subscribe) library in Go (Golang)
Go
7
star
18

dotfiles

dotfiles management with git
Shell
7
star
19

catalyst

Caches binaries and libraries and runs a command. Used usually for decreasing release size of applications.
Go
7
star
20

kuyruk-manager

See and manage Kuyruk workers.
Python
6
star
21

putiofs

A FUSE wrapper around put.io API v2
Python
5
star
22

remux

HTTP router that routes requests based on regex patterns.
Go
4
star
23

httpagain

Graceful restart for HTTP server (Golang)
Go
4
star
24

redialer

Generic redialer for connection-like types in Go
Go
4
star
25

container-manager

Go
3
star
26

seslisozluk-chrome

SesliSozluk.com Chrome Extension
JavaScript
3
star
27

bitfield

bitfield implementation in go
Go
3
star
28

putio-treemap

Python
3
star
29

bcount

Cardinality counter that uses bloom filter internally.
Go
3
star
30

kuyruk-go

Library for sending Kuyruk tasks from Go programs
Go
3
star
31

debe-postasi

Python
3
star
32

putio-osx-menubar

Swift
2
star
33

kuyruk-requeue

Save failed tasks to Redis and requeue them.
Python
2
star
34

math.kite

Example kite for demonstating kite framework
Go
2
star
35

puke

generate data for http speed testing
Go
2
star
36

cenkalti.com

My home page
HTML
1
star
37

overlord

Process manager
C
1
star
38

pb

Turn long command outputs to a nice progress bar
Go
1
star
39

cpu-guard

Shows MacOS notification if a process uses too much CPU
Swift
1
star
40

kuyruk-sentry

Sends exceptions in Kuyruk workers to Sentry.
Python
1
star