event package¶
Submodules¶
event.Constants module¶
event.EventStream module¶
- class event.EventStream.EventStream(*args, **kwargs)¶
Bases:
IEventStream
,Singleton
- emit(entity: ~reactive_reference.event.data.Entity.Entity, data: ~typing.Any, domain: ~reactive_reference.event.data.Domain.Domain = Domain(name: Default), exclusive: bool = False) NoReturn ¶
Sends data to the Event Stream, triggering on_event_receive for all subscribers. :param entity: Entity from which the emit was called from :param data: Structured payload for the Event Stream :param domain: Domain to which the data is binded to :param exclusive: Set the mode of the message to exclusive. If True, will only notify those of the same domain :return: None
- follow(entity: Entity, domain: Domain) bool ¶
Adds the ability to Subscribers to receive notifications from other Domains :param entity: Entity object which specifies the subscriber :param domain: Domain to register to stream :return: True if was correctly subscribed, False otherwise or if already subscribed
- get(_filter: Callable | None = None) List[Event] ¶
Retrieve all events :param _filter: Function to allow filtering of events :return: List with all applicable Events
- register(instance: ~reactive_reference.event.interfaces.IEventSubscriber.IEventSubscriber, domain: ~reactive_reference.event.data.Domain.Domain = Domain(name: Default)) Entity ¶
Register class for Event updates :param instance: Class instance that extends from EventSubscriber :param domain: Domain to subscribe for updates. If no domain is given class will subscribe to every update :return: Entity object
- restart() NoReturn ¶
- property subscribers: int¶
Number of connected subscribers
- unfollow(entity: Entity, domain: Domain) bool ¶
Removes the Subscribers from receiving notifications from other Domains :param entity: Entity object which specifies the subscriber :param domain: Domain to unfollow from the stream :return: True if was correctly unfollowed, False otherwise or if already unfollowed
- class event.EventStream.EventStreamThreaded(exclusive: bool = False, limit: int | None = None)¶
Bases:
Thread
- kill_stream()¶
- run()¶
Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
event.EventSubscriber module¶
- class event.EventSubscriber.EventSubscriber(stream: ~reactive_reference.event.interfaces.IEventStream.IEventStream, domain: ~reactive_reference.event.data.Domain.Domain = Domain(name: Default), replay_strategy: ~reactive_reference.event.data.ReplayStrategy.ReplayStrategy = ReplayStrategy.DISABLED)¶
Bases:
IEventSubscriber
- emit(data: Any, exclusive: bool = False) NoReturn ¶
Sends data to the Event Stream :param data: Structured payload for the Event Stream :param exclusive: Set the mode of the message to exclusive. If True, will only notify those of the same domain :return: None
- follow(domain: Domain) bool ¶
Adds the ability to Subscribers to receive notifications from other Domains :param domain: Domain to register to stream :return: True if was correctly subscribed, False otherwise or if already subscribed
- get(_filter: Callable | None = None) List[Event] ¶
Retrieve all events :param _filter: Function to allow filtering of events :return: List with all applicable Events
- abstract async on_event_receive(data: Event) NoReturn ¶
Triggered by the event stream when new Events are posted in the Stream :param data: Event sent by the stream :return: None
- async on_lifecycle_event(event: LifecycleEvent) NoReturn ¶
Triggered by the event stream when new Events are posted in the Stream :param event: Lifecycle event sent by the stream :return: None
- property strategy: ReplayStrategy¶
- unfollow(domain: Domain) bool ¶
Removes the Subscribers from receiving notifications from other Domains :param domain: Domain to register to stream :return: True if was correctly unfollowed, False otherwise or if already unfollowed
- unregister() bool ¶
Unregisters the class from the Stream, therefore won’t receive any other updates :return: True if unregistered successfully, False otherwhise
Module contents¶
- class event.Entity(id: str, instance: reactive_reference.event.interfaces.IEventSubscriber.IEventSubscriber, domain: reactive_reference.event.data.Domain.Domain)¶
Bases:
object
- id: str¶
- instance: IEventSubscriber¶
- class event.Event(id: str, payload: reactive_reference.event.data.Payload.Payload | None, timestamp: float, domain: reactive_reference.event.data.Domain.Domain)¶
Bases:
object
- id: str¶
- timestamp: float¶
- class event.IEventStream¶
Bases:
object
- emit(entity: ~reactive_reference.event.data.Entity.Entity, data: ~typing.Any, domain: ~reactive_reference.event.data.Domain.Domain = Domain(name: Default), exclusive: bool = False) NoReturn ¶
Sends data to the Event Stream, triggering on_event_receive for all subscribers. :param entity: Entity from which the emit was called from :param data: Structured payload for the Event Stream :param domain: Domain to which the data is binded to :param exclusive: Set the mode of the message to exclusive. If True, will only notify those of the same domain :return: None
- follow(entity: Entity, domain: Domain) bool ¶
Adds the ability to Subscribers to receive notifications from other Domains :param entity: Entity object which specifies the subscriber :param domain: Domain to register to stream :return: True if was correctly subscribed, False otherwise or if already subscribed
- get(_filter: Callable | None = None) List[Event] ¶
Retrieve all events :param _filter: Function to allow filtering of events :return: List with all applicable Events
- register(instance: ~reactive_reference.event.interfaces.IEventSubscriber.IEventSubscriber, domain: ~reactive_reference.event.data.Domain.Domain = Domain(name: Default)) Entity ¶
Register class for Event updates :param instance: Class instance that extends from EventSubscriber :param domain: Domain to subscribe for updates. If no domain is given class will subscribe to every update :return: Entity object
- subscribers: int¶
- unfollow(entity: Entity, domain: Domain) bool ¶
Removes the Subscribers from receiving notifications from other Domains :param entity: Entity object which specifies the subscriber :param domain: Domain to unfollow from the stream :return: True if was correctly unfollowed, False otherwise or if already unfollowed
- class event.IEventSubscriber¶
Bases:
object
- emit(data: Any, exclusive: bool = False) NoReturn ¶
Sends data to the Event Stream :param data: Structured payload for the Event Stream :param exclusive: Set the mode of the message to exclusive. If True, will only notify those of the same domain :return: None
- follow(domain: Domain) bool ¶
Adds the ability to Subscribers to receive notifications from other Domains :param domain: Domain to register to stream :return: True if was correctly subscribed, False otherwise or if already subscribed
- get(_filter: Callable | None = None) List[Event] ¶
Retrieve all events :param _filter: Function to allow filtering of events :return: List with all applicable Events
- async on_event_receive(data: Event) NoReturn ¶
Triggered by the event stream when new Events are posted in the Stream :param data: Event sent by the stream :return: None
- async on_lifecycle_event(event: LifecycleEvent) NoReturn ¶
Triggered by the event stream when new Events are posted in the Stream :param event: Lifecycle event sent by the stream :return: None
- strategy: ReplayStrategy¶
- unfollow(domain: Domain) bool ¶
Removes the Subscribers from receiving notifications from other Domains :param domain: Domain to register to stream :return: True if was correctly unfollowed, False otherwise or if already unfollowed
- unregister() bool ¶
Unregisters the class from the Stream, therefore won’t receive any other updates :return: True if unregistered successfully, False otherwhise