tarantool / queue

Create task queues, add and take jobs, monitor failed tasks
Other
237 stars 52 forks source link

[5pt] Provide state diagram for a task #123

Closed Totktonada closed 3 years ago

Totktonada commented 4 years ago

Aside of states and task actions we can show how timeout events (ttl, ttr) change a state. Also we can place internal actions that is performed by a queue to keep its guarantees (say, order of tasks): I mean, when exactly queue wake up blocked :take().

I guess this way it will be easier to understand what guarantees we provide and how it is achieved. It should make life easier for users as well as for developers.

https://github.com/tarantool/queue#fields-of-the-space-associated-with-each-queue

veod32 commented 3 years ago

For reference or further updates: below is the plantuml code used for drawing the diagram.

@startuml
hide empty description
[*] --> READY : put()
[*] --> DELAYED : put('my_task_data', { delay = delay })
READY --> TAKEN : take()
READY --> DONE : delete()
READY --> BURIED : bury()
READY --> DONE : ttl timeout
TAKEN -up-> READY : release()
TAKEN -up-> READY : ttr timeout
TAKEN --> DELAYED : release(id, { delay = delay })
TAKEN --> DONE : ack()
TAKEN --> BURIED : bury()
TAKEN --> DONE : delete()
BURIED --> DONE : delete()
BURIED --> READY : kick()
BURIED --> DONE: ttl timeout
DELAYED --> READY : timeout
DELAYED --> DONE : delete()
DONE --> [*] : remove executed task
@enduml