bobocep.cep.engine.decider.decider.BoboDecider

class bobocep.cep.engine.decider.decider.BoboDecider(phenomena: List[BoboPhenomenon], gen_event_id: BoboGenEventID, gen_run_id: BoboGenEventID, max_cache: int = 0, max_size: int = 0)[source]

Bases: BoboEngineTask, BoboDeciderPublisher, BoboReceiverSubscriber, BoboDistributedSubscriber

A decider task.

__init__(phenomena: List[BoboPhenomenon], gen_event_id: BoboGenEventID, gen_run_id: BoboGenEventID, max_cache: int = 0, max_size: int = 0)[source]
Parameters:
  • phenomena – List of phenomena.

  • gen_event_id – Event ID generator.

  • gen_run_id – Run ID generator.

  • max_cache – Max cache size (<=0 means no caching). Default: 0.

  • max_size – Max queue size. Default: 0 (unbounded).

all_runs() Tuple[BoboRun, ...][source]
Returns:

All active runs in the decider.

close() None[source]

Closes the Decider.

is_closed() bool[source]
Returns:

True if decider is set to close; False otherwise.

on_distributed_update(completed: List[BoboRunSerial], halted: List[BoboRunSerial], updated: List[BoboRunSerial]) None[source]
Parameters:
  • completed – Completed runs.

  • halted – Halted runs.

  • updated – Updated runs.

on_receiver_update(event: BoboEvent) None[source]
Parameters:

event – Event from Receiver.

phenomena() Tuple[BoboPhenomenon, ...][source]
Returns:

All phenomena under consideration by the decider.

run_at(phenomenon_name: str, pattern_name: str, run_id: str) BoboRun | None[source]
Parameters:
  • phenomenon_name – A phenomenon name.

  • pattern_name – A pattern name.

  • run_id – A run ID.

Returns:

A run associated with the given phenomenon and pattern name; or None if no such run exists.

runs_from(phenomenon_name: str, pattern_name: str) Tuple[BoboRun, ...][source]
Parameters:
  • phenomenon_name – A phenomenon name.

  • pattern_name – A pattern name.

Returns:

The runs associated with the given phenomenon and pattern name.

size() int[source]
Returns:

The total number of events in the decider’s queue.

snapshot() Tuple[List[BoboRunSerial], List[BoboRunSerial], List[BoboRunSerial]][source]

A snapshot of the current state of the Decider.

Returns:

Tuple of cached completed, cached halted, and currently partially-completed runs. If caching is disabled, the first two lists will be empty.

subscribe(subscriber: BoboDeciderSubscriber) None[source]
Parameters:

subscriber – Subscriber to Decider data.

update() bool[source]

Performs an update cycle of the decider that takes an event from its queue and checks it against phenomena and existing runs.

Returns:

True if an internal state change occurred during the update; False otherwise.