async-runner

command module
v0.0.0-...-3e9cf14 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

README

async-runner

async runner 异步任务队列

  • 基于fastHttp的http协议, 支持多种语言的客户端, 目前只在项目中实现了go方便用户(client/client_http.go)
  • 基于redis持久化任务
  • 基于mysql任务日志(失败,成功) //todo
  • 极少的资源占用
  • 自定义重试时间

usage

1. 运行服务

async-runner.exe config.json

2. 编写Worker
// 绑定本地9999端口以接受回调
c := client.NewHttpReceiver(":9999")
// 监听test话题
c.AddListener("test", func(data []byte) (err error) {
    log.Info("test", "run", data)
    return
})
c.StartSever()
2. 添加延时任务
// 绑定本地9999端口以接受回调
c := client.NewHttpPusher("http://127.0.0.1:9989", "http://127.0.0.1:9999")
// 添加一个话题为test,延时1s执行的job,内容为[]byte{1,10}
c.Add("test", 1, []byte{1, 10})

顺利的话就你能在Worker里看到log: run [1,10]

代码详情请看tests/default_test.go

conf

{
  "server_http": ":9999", // 服务器监听的地址
  "persistence": true, // 持久化到Redis
  "redis": "localhost:6379", // redis host
  "log": true, // 暂无用
  "mysql": "root:@tcp(localhost:3306)/test", // 暂无用
  "retry":[3,7,17,30] // 代表任务失败重试4次,4次间隔时间为3 7 17 30秒
}

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