Skip to main content

prefect.server.utilities.messaging

Functions

create_cache

Creates a new cache with the applications default settings. Returns:
  • a new Cache instance

create_publisher

Creates a new publisher with the applications default settings. Args: topic: the topic to publish to Returns: a new Consumer instance

ephemeral_subscription

Creates an ephemeral subscription to the given source, removing it when the context exits.

create_consumer

Creates a new consumer with the applications default settings. Args: topic: the topic to consume from Returns: a new Consumer instance

Classes

Message

A protocol representing a message sent to a message broker. Methods:

attributes

data

Cache

Methods:

clear_recently_seen_messages

forget_duplicates

without_duplicates

Publisher

Methods:

publish_data

CapturedMessage

CapturingPublisher

Methods:

publish_data

publish_data

StopConsumer

Exception to raise to stop a consumer.

Consumer

Abstract base class for consumers that receive messages from a message broker and call a handler function for each message received. Methods:

cleanup

Cleanup resources when the consumer is stopped. Override this method in subclasses that need to perform cleanup, such as unsubscribing from topics or closing connections. The default implementation is a no-op, which is appropriate for consumers that don’t need explicit cleanup.

run

Runs the consumer (indefinitely)

CacheModule

BrokerModule