Workq - 作业调度服务器
MPL
跨平台
Google Go
软件简介
Workq 是一个用 Go 开发的作业调度服务器。主要特性:
-
异步和同步的作业处理
-
提交作业,然后在作业完成后返回结果,最多等待 TTL
-
提交作业并马上获得执行结果
-
-
在任意时间临时安排作业调度
-
使用数值表示作业优先级
-
可以制定每个作业的 TTR (time-to-run) - 限制最大执行时间
-
可以制定每个作业的 TTL 超时 - 限制作业最大存活时间
-
每个作业可单独设置重试策略,包括 max-attempts 和 max-fails 参数
示例代码:
job := &workq.FgJob{
ID: "6ba7b810-9dad-11d1-80b4-00c04fd430c4",
Name: "ping",
TTR: 5000, // 5 second time-to-run limit
Timeout: 60000, // Wait up to 60 seconds for a worker to pick up.
Payload: []byte("ping"),
Priority: 10, // @OPTIONAL Numeric priority, default 0.
}
result, err := client.Run(job)
if err != nil {
// ...
}
fmt.Printf("Success: %t, Result: %s", result.Success, result.Result)