Tai.Orders.OrderTransitionWorker (tai v0.0.75)

The OrderTransitionWorker acts as a locking mechanism to ensure an order can only be updated sequentially to avoid race conditions when receiving the accepted response from a request and asynchronously receiving the result of that request.

Below is an example of the sequence that can occur when creating an order:

send HTTP request to create order ->

                                <- asynchronously receive on stream that order created successfully
                                 <- response from HTTP request that create order was accepted

Multiple orders can be updated in parallel by using 2 or more workers. Orders are deterministically sent to the same worker using the following algorithm.

hash(order.client_id) % order_transition_worker_count

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Link to this section Types

Link to this section Functions

Link to this function

apply(client_id, transition_attrs)

Specs

apply(client_id(), attrs()) :: {:ok, order()} | {:error, term()}
Link to this function

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

process_name(idx)

Specs

process_name(pos_integer()) :: atom()
Link to this function

start_link(idx)

Specs

start_link(pos_integer()) :: GenServer.on_start()