Skip to content

Commit 286ab7d

Browse files
veod32LeonidVas
authored andcommitted
documentation: add task state diagram
The diagram gives a concise and holistic view of all the task states and what method triggers each transition between the states. Closes #123
1 parent ef2b6a8 commit 286ab7d

File tree

3 files changed

+93
-7
lines changed

3 files changed

+93
-7
lines changed

README.md

+26-7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ align="right">
2121
* [Fields of the \_queue\_taken\_2 space](#fields-of-the-_queue_taken_2-space)
2222
* [Fields of the \_queue\_session\_ids space](#fields-of-the-_queue_session_ids-space)
2323
* [Fields of the space associated with each queue](#fields-of-the-space-associated-with-each-queue)
24+
* [Task state diagram](#task-state-diagram)
2425
* [Installing](#installing)
2526
* [Using the queue module](#using-the-queue-module)
2627
* [Initialization](#initialization)
@@ -295,14 +296,32 @@ The `task_state` field takes one of the following values
295296
(different queue types support different
296297
sets of `task_state` values, so this is a superset):
297298

298-
* 'r' - the task is ready for execution (the first consumer executing
299+
* 'r' - the task is **ready** for execution (the first consumer executing
299300
a `take` request will get it)
300-
* 't' - the task has been taken by a consumer
301-
* '-' - the task has been executed (a task is removed from the queue
302-
after it
303-
has been executed, so this value will rarely be seen)
304-
* '!' - the task is buried (disabled temporarily until further changes)
305-
* '~' - the task is delayed for some time
301+
* 't' - the task has been **taken** by a consumer
302+
* '-' - the task has been **executed (done)** (a task is removed from the queue
303+
after it has been executed, so this value will rarely be seen)
304+
* '!' - the task is **buried** (disabled temporarily until further changes)
305+
* '~' - the task is **delayed** for some time.
306+
307+
For details on the state transitions, refer to [Task state diagram](#task-state-diagram).
308+
309+
# Task state diagram
310+
311+
The following diagram shows possible transitions between the [task states](#fields-of-the-space-associated-with-each-queue).
312+
For information on the transition triggers, refer to:
313+
314+
* [put()](#putting-a-task-in-a-queue)
315+
* [release()](#releasing-a-task)
316+
* [take()](#taking-a-task-from-the-queue-consuming)
317+
* [kick()](#kicking-a-number-of-tasks)
318+
* [bury()](#burying-a-task)
319+
* [ack()](#acknowledging-the-completion-of-a-task)
320+
* [delete()](#deleting-a-task)
321+
* description of the `timeout`, `ttl timeout`, and `ttr timeout` options in
322+
the sections of the corresponding [queue types](#queue-types).
323+
324+
![Task state diagram](./doc/images/statediagram.svg)
306325

307326
# Installing
308327

doc/images/statediagram.svg

+40
Loading

doc/src/statediagram.puml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/' This code is for generating the task state diagram in SVG format.
2+
Use any PlantUML rendering service, for example, https://www.planttext.com/.
3+
To generate the diagram on the page of this service:
4+
1. In the left pane, copy and paste the code or select this source file
5+
statediagram.puml with the "File Manager" button.
6+
2. Click "Refresh". The resulting diagram is displayed in the right pane.
7+
3. Click SVG link below the diagram view and download the diagram file.
8+
4. Rename the file into "statediagram.svg" and upload in the ./doc/images/
9+
folder.
10+
'/
11+
12+
@startuml
13+
[*] -down-> READY : put()
14+
[*] -down-> DELAYED : put('my_task_data',\n{ delay = delay })
15+
READY -down-> TAKEN : take()
16+
READY -down-> DONE : delete() /\nttl timeout
17+
READY -down-> BURIED : bury()
18+
TAKEN -up-> READY : release() /\nttr timeout
19+
TAKEN -left-> DELAYED : release\n(id, { delay = delay })
20+
TAKEN -down-> DONE : ack() / delete()
21+
TAKEN -right-> BURIED : bury()
22+
BURIED -down-> DONE : delete() /\nttl timeout
23+
BURIED -up-> READY : kick()
24+
DELAYED -up-> READY : timeout
25+
DELAYED -down-> DONE : delete()
26+
DONE -down-> [*] : remove executed task
27+
@enduml

0 commit comments

Comments
 (0)