class documentation

class SubscriptionSink:

Constructor: SubscriptionSink(depth, qos, provenance)

View In Hierarchy

The write side of a Subscription; every method runs on the Runtime's event loop.

Method __init__ Open a sink buffering at most depth messages, affine to the running loop.
Async Method await_incompatibilities Await more incompatibilities than have been seen, and return how many there now are.
Async Method await_publishers Await a publisher count other than one already seen, and return it.
Method close End the stream, waking every consumer waiting on it.
Method deliver Accept one decoded message, dropping the oldest buffered one if the buffer is full.
Method note_incompatibility Record one incompatibility the middleware reported, unless it is one already recorded.
Method note_publishers Accept the publisher count a match event reported (a missed event costs nothing).
Method note_qos Record the profile this subscription asks for, after a re-subscription made it true.
Method note_type_hash_mismatch Record a type-hash disagreement seen on this topic.
Method require_own_loop Refuse an operation running on a loop other than the one this sink was opened on.
Async Method take Await the next buffered message.
Property closed Return whether the subscription's lifetime has ended.
Property publisher_count Return how many publishers this subscription is currently matched with.
Property qos Return the QoS profile the subscription is currently asking for.
Property qos_incompatibilities Return every incompatibility the middleware has reported on this topic so far.
Property qos_provenance Return where that profile came from, and therefore whether it may adapt.
Property type_hash_mismatches Return every type-hash disagreement seen on this topic so far.
Instance Variable _arrival Undocumented
Instance Variable _closed Undocumented
Instance Variable _incompatibilities Undocumented
Instance Variable _incompatible Undocumented
Instance Variable _loop Undocumented
Instance Variable _matched Undocumented
Instance Variable _messages Undocumented
Instance Variable _mismatches Undocumented
Instance Variable _provenance Undocumented
Instance Variable _publishers Undocumented
Instance Variable _qos Undocumented
def __init__(self, *, depth: int, qos: QoSProfile = MOST_PERMISSIVE, provenance: Provenance = Provenance.DISCOVERED):

Open a sink buffering at most depth messages, affine to the running loop.

Parameters
depth:intHow many messages may wait for a consumer. When the buffer is full the oldest is dropped, since a Monitoring variable wants the newest value.
qos:QoSProfileThe profile the subscription opened with.
provenance:ProvenanceWhere that profile came from.
Raises
RuntimeErrorWhen constructed with no running event loop.
ValueErrorWhen depth is below 1.
async def await_incompatibilities(self, seen: int) -> int:

Await more incompatibilities than have been seen, and return how many there now are.

Raises
SubscriptionClosedErrorWhen the subscription closes while waiting.
LoopAffinityErrorWhen awaited on a loop other than this sink's.
async def await_publishers(self, seen: int) -> int:

Await a publisher count other than one already seen, and return it.

Raises
SubscriptionClosedErrorWhen the subscription closes while waiting.
LoopAffinityErrorWhen awaited on a loop other than this sink's.
def close(self):

End the stream, waking every consumer waiting on it.

def deliver(self, message: Message):

Accept one decoded message, dropping the oldest buffered one if the buffer is full.

def note_incompatibility(self, incompatibility: QoSIncompatibility) -> bool:

Record one incompatibility the middleware reported, unless it is one already recorded.

Deduplicated by policy and request, so a flapping publisher cannot produce an unbounded list or an event storm. A clash after an adaptation counts as new, since the request moved.

Returns
boolWhether this was new. The caller logs only then.
def note_publishers(self, count: int):

Accept the publisher count a match event reported (a missed event costs nothing).

def note_qos(self, profile: QoSProfile):

Record the profile this subscription asks for, after a re-subscription made it true.

def note_type_hash_mismatch(self, mismatch: TypeHashMismatch):

Record a type-hash disagreement seen on this topic.

def require_own_loop(self):

Refuse an operation running on a loop other than the one this sink was opened on.

Raises
LoopAffinityErrorWhen the running loop is not this sink's.
async def take(self) -> Message:

Await the next buffered message.

Raises
SubscriptionClosedErrorWhen the subscription is closed and the buffer is empty.
LoopAffinityErrorWhen awaited on a loop other than this sink's.
@property
closed: bool =

Return whether the subscription's lifetime has ended.

@property
publisher_count: int =

Return how many publishers this subscription is currently matched with.

@property
qos: QoSProfile =

Return the QoS profile the subscription is currently asking for.

@property
qos_incompatibilities: tuple[QoSIncompatibility, ...] =

Return every incompatibility the middleware has reported on this topic so far.

@property
qos_provenance: Provenance =

Return where that profile came from, and therefore whether it may adapt.

@property
type_hash_mismatches: tuple[TypeHashMismatch, ...] =

Return every type-hash disagreement seen on this topic so far.

_arrival =

Undocumented

_closed: bool =

Undocumented

_incompatibilities: list[QoSIncompatibility] =

Undocumented

_incompatible =

Undocumented

_loop =

Undocumented

_matched =

Undocumented

_messages: deque[Message] =

Undocumented

_mismatches: list[TypeHashMismatch] =

Undocumented

_provenance =

Undocumented

_publishers =

Undocumented

_qos =

Undocumented