-
Notifications
You must be signed in to change notification settings - Fork 74
Are worker clusters supported? #15
Comments
@nodesocket Yes, multiple workers working on the same group of jobs/tasks is the natural workflow for workq. The jobs are distributed on a first come first serve basis. The workers can be on as many servers as needed, but there can only be a single Retry is also supported per-job as needed and at a somewhat granular level. Retry is only supported on background jobs, foreground jobs are up to caller (since they control the retry attempt). Retry can be configured on the job with the following flags: (Extracted from protocol doc)
The key concept to note though is that the client configures a job with how they want the job retried and the server will hand out the job to the workers as needed. As a concrete example, if you want a job run successfully executed within 5 seconds, but want it retried at least once in case the initial worker timed out, the job := &workq.BgJob{
ID: "6ba7b810-9dad-11d1-80b4-00c04fd430c4",
Name: "ping",
TTL: 60000, // Expire the job after 60 seconds
TTR: 5000, // 5 second time-to-run limit for a single execution.
Payload: []byte("ping"),
Priority: 10, // @OPTIONAL Numeric priority, default 0.
MaxAttempts: 1, // @OPTIONAL Absolute max num of attempts.
}
err := client.Add(job)
if err != nil {
// ...
} In the above case, if a worker picks up the job, but fails to complete, another worker will pick it up and attempt it once more. If you don't provide a Hope the above example provides some clarity. Let me know if you have any more questions. |
@iamduo really appreciate the awesome and detailed reply. Is there a client in Node.js by chance? |
@nodesocket I am not aware of a node js client at the moment. The protocol is a plain text based protocol so if you chose to, it would be on the easier side to implement. You can refer to: https://github.com/iamduo/workq/blob/master/doc/protocol.md for reference and use the official Go client as a working example. It is also not required to implement the full protocol, just the commands you need if you want to reduce the effort (e.g., "add", "lease", "complete", "fail", "result") |
@nodesocket If you do end up creating a client, let me know and I will list it under the README#clients section. Thanks. |
Can I create multiple workers on separate servers and have the clients round robin tasks to the workers? Extra credit, clients should detect if a worker is down and retry the task on another worker automatically.
The text was updated successfully, but these errors were encountered: