prefect.server.events.ordering

Manages the partial causal ordering of events for a particular consumer. This module maintains a buffer of events to be processed, aiming to process them in the order they occurred causally.

Classes

EventArrivedEarly

MaxDepthExceeded

event_handler

CausalOrdering

Methods:

event_has_been_seen

event_has_been_seen(self, event: Union[UUID, Event]) -> bool

forget_follower

forget_follower(self, db: PrefectDBInterface, follower: ReceivedEvent) -> None
Forget that this event is waiting on another event to arrive

get_followers

get_followers(self, db: PrefectDBInterface, leader: ReceivedEvent) -> List[ReceivedEvent]
Returns events that were waiting on this leader event to arrive

get_lost_followers

get_lost_followers(self, db: PrefectDBInterface) -> List[ReceivedEvent]
Returns events that were waiting on a leader event that never arrived

preceding_event_confirmed

preceding_event_confirmed(self, handler: event_handler, event: ReceivedEvent, depth: int = 0)
Events may optionally declare that they logically follow another event, so that we can preserve important event orderings in the face of unreliable delivery and ordering of messages from the queues. This function keeps track of the ID of each event that this shard has successfully processed going back to the PRECEDING_EVENT_LOOKBACK period. If an event arrives that must follow another one, confirm that we have recently seen and processed that event before proceeding. event (ReceivedEvent): The event to be processed. This object should include metadata indicating if and what event it follows. depth (int, optional): The current recursion depth, used to prevent infinite recursion due to cyclic dependencies between events. Defaults to 0. Raises EventArrivedEarly if the current event shouldn’t be processed yet.

record_event_as_seen

record_event_as_seen(self, event: ReceivedEvent) -> None

record_follower

record_follower(self, db: PrefectDBInterface, event: ReceivedEvent) -> None
Remember that this event is waiting on another event to arrive