databay.support.buffers

class databay.support.buffers.Buffer(count_threshold: int = None, time_threshold: float = None, custom_controllers: Union[callable, List[callable]] = None, on_reset: callable = None, conjugate_controllers: bool = False)[source]

databay.support.buffers.Buffer

Buffers are special built-in Processors. They allow you to temporarily accumulate records before passing them over to outlets.

When processing records (see Processors) a Buffer will figure out whether records should be stored or released. This is done by passing the list of records to Buffer’s internal callable functions called controllers.

Each controller performs different types of checks, returning True or False depending on whether records should be released or stored respectively.

Parameters
  • count_threshold (int) – The number of records stored that when reached will complete the count controller. When set to None it will disable the count controller.

    Default:
    None

  • time_threshold (float) – The number of seconds elapsed since the previous release that when reached will complete the time controller. When set to None it will disable the time controller.

    Default:
    None

  • custom_controllers (callable or list[callable]) – List of custom callable controllers.

    Default:
    None

  • on_reset (callable) – Callback invoked when reset is called.

    Default:
    None

  • conjugate_controllers (bool) – Whether to release the records when any controller returns True or to wait for all of them to complete before releasing records.

    Default:
    False

get_controllers(self)[source]

Return the list of currently active controllers.

Returns

list of controllers

Return type

list[callable]

reset(self)[source]

Resets this buffer, resetting the controllers’ counters and emptying the list of records stored.