dalga

command module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2020 License: MIT Imports: 8 Imported by: 0

README

Dalga

Build Status

Dalga is a job scheduler.

  • Can schedule periodic or one-off jobs.
  • Stores jobs in a MySQL table.
  • 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.

Install

$ go get github.com/cenkalti/dalga

Usage

Example config file is in the repository.

To create the table for storing jobs:

$ dalga -config dalga.ini -create-table

Then, run the server:

$ dalga -config dalga.ini

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 cann pass to Schedule but not every combination is valid:

Param Description Type Example
interval Run job at intervals in seconds Integer 60
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, yes, no, on, off, 1, 0
immediate Run job immediately as it is scheduled Boolean true, false, yes, no, on, off, 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

You may trigger a job manually by sending a POST request:

$ curl -i -X POST 'http://127.0.0.1:34006/jobs/check_feed/1234?interval=60'
HTTP/1.1 200 OK
Content-Type: application/json
Date: Fri, 14 Nov 2014 09:09:01 GMT
Content-Length: 83

{"path":"check_feed","body":"1234","interval":0,"next_run":"2014-11-14T09:09:01Z"}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Godeps/_workspace/src/code.google.com/p/gcfg
Package gcfg reads "INI-style" text-based configuration files with "name=value" pairs grouped into sections (gcfg files).
Package gcfg reads "INI-style" text-based configuration files with "name=value" pairs grouped into sections (gcfg files).
Godeps/_workspace/src/code.google.com/p/gcfg/scanner
Package scanner implements a scanner for gcfg configuration text.
Package scanner implements a scanner for gcfg configuration text.
Godeps/_workspace/src/code.google.com/p/gcfg/token
Package token defines constants representing the lexical tokens of the gcfg configuration syntax and basic operations on tokens (printing, predicates).
Package token defines constants representing the lexical tokens of the gcfg configuration syntax and basic operations on tokens (printing, predicates).
Godeps/_workspace/src/code.google.com/p/gcfg/types
Package types defines helpers for type conversions.
Package types defines helpers for type conversions.
Godeps/_workspace/src/github.com/bmizerany/pat
Package pat implements a simple URL pattern muxer
Package pat implements a simple URL pattern muxer
Godeps/_workspace/src/github.com/cenkalti/backoff
Package backoff implements backoff algorithms for retrying operations.
Package backoff implements backoff algorithms for retrying operations.
Godeps/_workspace/src/github.com/fzzy/radix/redis/resp
This package provides an easy to use interface for creating and parsing messages encoded in the REdis Serialization Protocol (RESP).
This package provides an easy to use interface for creating and parsing messages encoded in the REdis Serialization Protocol (RESP).
Godeps/_workspace/src/github.com/go-sql-driver/mysql
Go MySQL Driver - A MySQL-Driver for Go's database/sql package The driver should be used via the database/sql package: import "database/sql" import _ "github.com/go-sql-driver/mysql" db, err := sql.Open("mysql", "user:password@/dbname") See https://github.com/go-sql-driver/mysql#usage for details
Go MySQL Driver - A MySQL-Driver for Go's database/sql package The driver should be used via the database/sql package: import "database/sql" import _ "github.com/go-sql-driver/mysql" db, err := sql.Open("mysql", "user:password@/dbname") See https://github.com/go-sql-driver/mysql#usage for details

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL