subscription

class mersal.subscription.SubscriptionStorage

Bases: Protocol

A protocol that defines the storage required to store topics subscriptions.

__init__(*args, **kwargs)
async get_subscriber_addresses(topic: str) set[str]

Get addresses subscribed for the given topic.

Parameters:

topic – topic name to get the addresses for.

Returns:

A set of addresses subscribed to this topic.

property is_centralized: bool

Whether this storage is centralized.

Centralized storage means topic subscriptions are stored in one place and registration/unregistration can be done by directly calling register_subscriber and unregister_subscriber, respectively.

Non centralized means each topic handles its own storage and registration/unregistration is performed by sending a message to the topic owner (async).

async register_subscriber(topic: str, subscriber_address: str) None

Register the given address for the given topic.

async unregister_subscriber(topic: str, subscriber_address: str) None

Unregister the given address for the given topic.