crossbar.router.observation¶
Classes¶
Represents the current set of observations maintained by a broker/dealer. |
Functions¶
|
Test if the given URI is from a "protected namespace" (starting with wamp. |
Module Contents¶
- class UriObservationMap(ordered=False)[source]¶
Bases:
objectRepresents the current set of observations maintained by a broker/dealer.
To test: trial crossbar.router.test.test_subscription
- __slots__ = ('_ordered', '_observations_exact', '_observations_prefix', '_observations_wildcard',...[source]¶
- add_observer(observer, uri, match='exact', extra=None, observer_extra=None)[source]¶
Adds a observer to the observation set and returns the respective observation.
- Parameters:
- Returns:
A tuple
(observation, was_already_observed, was_first_observer). Here,observationis an instance of one ofExactUriObservation,PrefixUriObservationorWildcardUriObservation.- Return type:
- best_matching_observation(uri)[source]¶
Returns the observation that best matches the given URI. This is the core method called by a dealer to actually forward calls.
- Parameters:
uri (unicode) – The URI to match.
- Returns:
The observation best matching the URI. This is an instance of
ExactUriObservation,PrefixUriObservationorWildcardUriObservationorNone.- Return type:
obj or None
- create_observation(uri, match='exact', extra=None)[source]¶
Create an observation with no observers.
- Parameters:
- Returns:
The observation (instance of one of
ExactUriObservation,PrefixUriObservationorWildcardUriObservation).- Return type:
obj
- delete_observation(observation)[source]¶
Delete the observation from the map.
- Parameters:
observation (obj) – The observation which to remove from the map. An instance of
ExactUriObservation,PrefixUriObservationorWildcardUriObservationpreviously created and handed out by this observation map.- Return type:
None
- drop_observer(observer, observation)[source]¶
Drop a observer from a observation.
- Parameters:
observer (obj) – The observer to drop from the given observation.
observation (obj) – The observation from which to drop the observer. An instance of
ExactUriObservation,PrefixUriObservationorWildcardUriObservationpreviously created and handed out by this observation map.delete (bool) – Whether or not to delete the observation if they are the last observer.
- Returns:
A tuple
(was_observed, was_last_observer).- Return type:
- get_observation(uri, match='exact')[source]¶
Get a observation (if any) for given URI and match policy.
- Parameters:
- Returns:
The observation (instance of one of
ExactUriObservation,PrefixUriObservationorWildcardUriObservation) orNone.- Return type:
obj or None
- get_observation_by_id(id)[source]¶
Get a observation by ID.
- Parameters:
id (int) – The ID of the observation to retrieve.
- Returns:
The observation for the given ID or
None.- Return type:
obj or None