Workex.Aggregate protocol

Specifies the protocol used by Workex behaviour to aggregate incoming messages.

Source

Summary

add(aggregate, message)

Adds the new item to the aggregate

remove_oldest(aggregate)

Removes the oldest item from the collection

size(aggregate)

Returns the number of aggregated items

value(aggregate)

Produces an aggregated value from all collected items

Types

value :: any

t :: term

Functions

add(aggregate, message)

Specs:

  • add(t, any) :: t

Adds the new item to the aggregate.

Source
remove_oldest(aggregate)

Specs:

  • remove_oldest(t) :: t

Removes the oldest item from the collection.

Sometimes it doesn't make sense to implement this function, for example when the aggregation doesn't guarantee or preserve ordering. In such cases, just raise from the implementation, and document that the implementation can't be used with the replace_oldest option.

Source
size(aggregate)

Specs:

  • size(t) :: non_neg_integer

Returns the number of aggregated items.

This function is invoked frequently, so be sure to make the implementation fast.

Source
value(aggregate)

Specs:

Produces an aggregated value from all collected items.

The returned tuple contains aggregated items, and the new instance that doesn't contain those items.

Source