Skip to content

a distributed task schedule system which high avaliabled and strong data consistent by Raft.

License

Notifications You must be signed in to change notification settings

yushaolong10/xcron

Repository files navigation

xcron

xcron is a distributed task system based on raft. it still need to be durable optimize for it's performance.中文

features

  • easy be used by it's served http api

  • support instance task (will be trigger once in future time) & task format like linux crontab

  • dispatcher task with planB in cluster mode when one server accidentally downtime

  • based on raft to increment avaliable and the stable running of task in cluster mode

quick start

# 1.clone the program in your work directory
git clone https://github.com/alwaysthanks/xcron.git
# 2. run command belong under the program root path to build the server
bash build.sh
# 3. change the config file 'xcron.toml' if you need.
# - one machine is just to run
# - in cluster mode, you should change 'xcron,toml' like example:
#     peer_hosts = ["192.24.1.1:8899","192.24.1.2:8899","192.24.1.3:8899"]
# 4. run server
./xcron_server

architecture

the system designed architecture:

http api

the http api based on HTTP content-type as "application/json"

1. create new task

  • api:/xcron/createTask
  • method:POST
  • params:
param type must description
type int Y enum,the type of task:
1: periodicity time task ; 2:regular time task
format string Y when type=1, the format can use linux crontab
when type=2, the format is unix timestamp, unit: second
callback callback_table Y when the task running, it's callback info, as below callback_table:

callback_table:

param type must description
url string Y callback http url through HTTP POST in protocol content-type of application/json when the task running
body map<k>v N this param will be as the http json body when call the url above mentioned
  • returns:
param type description
uuid string the unique request generated by system
code int when code equal 0 mean success. vice versa.
message string when code not equal 0, the param expresses the reason
data data_table response data of the request, as below data_table:

data_table:

param type description
task_id string the unique task id in the system
  • returns example:
{
    "uuid": "80eb2fb8-2724-4707-9484-8e7d07b9171d",
    "code": 0,
    "data": {
        "task_id": "289057701458138645"
    }
}

dependence

github.com/json-iterator/go
github.com/sony/sonyflake
github.com/grandecola/bigqueue
github.com/hashicorp/raft
github.com/hashicorp/raft-boltdb
github.com/facebookgo/grace/gracehttp
github.com/ouqiang/timewheel
github.com/robfig/cron

About

a distributed task schedule system which high avaliabled and strong data consistent by Raft.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published