Skip to content

Commit

Permalink
in_progress_state confusion (#77)
Browse files Browse the repository at this point in the history
Hi there,

Our team was tracking down a bug due to us defining the same `in_progress_state` name on all our workers. We did not understand what it did, but after a great explanation here: #76, we suggest to open the docs to be more explicit about how this actually works :)

Thanks for a really amazing project, this has totally saved our startup!
  • Loading branch information
christianalfoni authored and Chris Raynor committed Aug 30, 2016
1 parent 66f7a5c commit f7c853e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ A default spec configuration is assumed if no specs are specified in the `specs`
```

- `start_state` - The default spec has no `start_state`, which means any task pushed into the `tasks` subtree without a `_state` key will be picked up by default spec workers. If `start_state` is specified, only tasks with that `_state` may be claimed by the worker.
- `in_progress_state` - When a worker picks up a task and begins processing it, it will change the tasks's `_state` to the value of `in_progress_state`. This is the only required spec property, and it cannot equal the `start_state`, `finished_state`, or `error_state`.
- `in_progress_state` - When a worker picks up a task and begins processing it, it will change the tasks's `_state` to the value of `in_progress_state`. This is the only required spec property, and it cannot equal the `start_state`, `finished_state`, or `error_state`. The `in_progress_state` is important for timeouts. If a timeout occurs on the specific task, any worker defined with the `in_progress_state` in question will try to pick it up and reset it to its own `start_state`. That means it is important that `in_progress_state` is unique, unless you want other workers to pick it up when it times out
- `finished_state` - The default spec has no `finished_state` so the worker will remove tasks from the queue upon successful completion. If `finished_state` is specified, then the task's `_state` value will be updated to the `finished_state` upon task completion. Setting this value to another spec's `start_state` is useful for chaining tasks together to create a job. It's possible to override the `finished_state` on a per-task basis by setting the `_new_state` key of the object passed into `resolve()` to a string to set the `_state` explicitly, `null` to remove the `_state` so it gets picked up by any spec without a `start_state`, or `false` to remove the task from the queue.
- `error_state` - If the task gets rejected the `_state` will be updated to this value and an additional key `_error_details` will be populated with the `previous_state` and an optional error message from the `reject()` callback. If this isn't specified, it defaults to "error". This can be useful for specifying different error states for different tasks, or chaining errors so that they can be logged.
- `timeout` - The default timeout is 5 minutes. When a task has been claimed by a worker but has not completed within `timeout` milliseconds, the queue will report that task as timed out, and reset that task to be claimable once again. If this is not specified, a task claimed by a worker could be orphaned and left in an unclaimable state if the worker processing it dies before the task is resolved or rejected.
Expand Down

0 comments on commit f7c853e

Please sign in to comment.