Dispenser.AssignmentStrategy behaviour (dispenser v0.1.0) View Source

A AssignmentStrategy is strategy to handle assigning events to subscribers to meet their demands.

Link to this section Summary

Types

t()

The AssignmentStrategy type.

Callbacks

Given subscriber demands and a number of events, determines how to assign the events to the subscribers.

Link to this section Types

Specs

t() :: module()

The AssignmentStrategy type.

Link to this section Callbacks

Link to this callback

assign(demands, event_count)

View Source

Specs

assign(
  demands :: Dispenser.Demands.t(subscriber),
  event_count :: non_neg_integer()
) ::
  {assigned_demands :: Dispenser.Demands.t(subscriber),
   remaining_demands :: Dispenser.Demands.t(subscriber)}
when subscriber: any()

Given subscriber demands and a number of events, determines how to assign the events to the subscribers.

Returns a new assigned_demands that contains values for assigning the events to the subscribers, and returns a remaining_demands that are left over for later when there are more events than demand.