cron-srv

command module
v0.0.0-...-5da7490 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2017 License: MIT Imports: 8 Imported by: 0

README

Cron Srv

  • All the flexibility and power of Cron as a Service.
  • Simple REST protocol, integrating with a web application in a easy and straightforward way.
  • No more wasting time building and managing scheduling infrastructure.

Basic Concepts

Cron Srv works by calling back to your application via HTTP GET according to a schedule constructed by you or your application.

Setup

Env vars

export CRON_SRV_DB="postgresql://postgres@localhost/cron_srv_dev?sslmode=disable"
export CRON_SRV_PORT=3000

Note: You must have created the database 'cron_srv_dev' in postgres running at localhost (or replace with valid database name and IP);

mkdir -p $GOPATH/src/github.com/EmpregoLigado
cd $GOPATH/src/github.com/EmpregoLigado 
git clone https://github.com/EmpregoLigado/cron-srv.git
cd cron-srv
glide install
go build

Running server

./cron-srv
# => Starting Cron Service at port 3000

Create an Cron

  • Request
curl -X POST -H "Content-Type: application/json" \
-d '{"url": "example.com/api/v1/stats", "expression": "0 5 * * * *", "status": "active", "max_retries": 2, "retry_timeout": 3}' \
localhost:3000/v1/events
  • Response
{
  "id": 1,
  "url": "example.com/api/v1/stats",
  "expression": "0 5 * * * *",
  "status": "active",
  "max_retries": 2,
  "retry_timeout": 3,
  "updated_at": "2016-12-10T14:02:37.064641296-02:00"
}

API Documentation

|HTTP verb| path| handle| |:--|:--|:--|:--| |GET |/v1/healthz|HealthzIndex |return a state of server {"alive":"up"}| |GET |/v1/events|EventsIndex |display a list of all events| |POST |/v1/events|EventsCreate |create a new event| |GET |/v1/events/:id|EventsShow |display a specific event| |PUT |/v1/events/:id|EventsUpdate |update a specific event| |DELETE |/v1/events/:id|EventsDelete |delete a specific event|

Cron Format

The cron expression format allowed is:

Field name Mandatory? Allowed values Allowed special characters
Seconds Yes 0-59 * / , -
Minutes Yes 0-59 * / , -
Hours Yes 0-23 * / , -
Day of month Yes 1-31 * / , - ?
Month Yes 1-12 or JAN-DEC * / , -
Day of week Yes 0-6 or SUN-SAT * / , - ?
more details about expression format here

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

Badges

CircleCI Go Report Card

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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