Zaqar/specs/use-cases/1

= Marconi: Use Case 1 =

Distribute tasks among multiple workers.

Main Sequence
1. Producer signs and submits work ticket to Service

2. Service acknowledges work ticket and guarantees its durability

3. Worker retrieves work ticket from Service

4. Worker verifies work ticket signature

5. Worker performs requested work

6. Worker acknowledges completion of work

7. Worker loops to (3)

Variations
2a. Service is unable to persist work ticket in a durable manner: Service returns error status and information to Producer; Producer may retry the request or fail the work item depending on the nature of the error received.

3a. More than one work ticket is enqueued: Worker retrieves up to min(50, n), where n is specified by the Worker in each request to Service.

3b. No work tickets are available: Service returns "no content" status code, and Worker must try again after some delay.

3c. Worker must distinguish a particular work stream: Producer tags work tickets, and Worker requests that the Service filter work tickets by the specified tags (negotiated out-of-band between Producer and Worker).

3d. More than one Worker is processing work tickets: Worker asks Service to create a transaction that effectively hides a given batch of work tickets from all other workers.

4a. Signature is invalid: Worker logs this fact and ignores this work item by skipping the next step (5), but does delete the work item (6).

5a. Worker is unable to complete work for any reason: Service makes work ticket available to another worker.

7a. More than min(50, n) work tickets are enqueued, or Producer submits work tickets faster than they can be consumed: Workers loop until all tickets have been processed. Worker pool may be dynamically resized according to ticket volume.

Related Information

 * All work ticket state changes are broadcast as audit messages.
 * Producers and consumers can namespace work tickets via tagging.
 * Worker pool managers may request message bus metrics, optionally filtering by one or more tags.