crossbar.router.observation

Classes

UriObservationMap

Represents the current set of observations maintained by a broker/dealer.

Functions

is_protected_uri(uri[, details])

Test if the given URI is from a "protected namespace" (starting with wamp.

Module Contents

class UriObservationMap(ordered=False)[source]

Bases: object

Represents the current set of observations maintained by a broker/dealer.

To test: trial crossbar.router.test.test_subscription

__repr__()[source]
__slots__ = ('_ordered', '_observations_exact', '_observations_prefix', '_observations_wildcard',...[source]
_observation_id_to_observation[source]
_observations_exact[source]
_observations_prefix[source]
_ordered = False[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:
  • observer (obj) – The observer to add (this can be any opaque object).

  • uri (unicode) – The URI (or URI pattern) to add the observer to add to.

  • match (unicode) – The matching policy for observing, one of "exact", "prefix" or "wildcard".

Returns:

A tuple (observation, was_already_observed, was_first_observer). Here, observation is an instance of one of ExactUriObservation, PrefixUriObservation or WildcardUriObservation.

Return type:

tuple

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, PrefixUriObservation or WildcardUriObservation or None.

Return type:

obj or None

create_observation(uri, match='exact', extra=None)[source]

Create an observation with no observers.

Parameters:
  • uri (unicode) – The URI (or URI pattern) to get the observation for.

  • match (unicode) – The matching policy for observation to retrieve, one of "exact", "prefix" or "wildcard".

Returns:

The observation (instance of one of ExactUriObservation, PrefixUriObservation or WildcardUriObservation).

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, PrefixUriObservation or WildcardUriObservation previously 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, PrefixUriObservation or WildcardUriObservation previously 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:

tuple

get_observation(uri, match='exact')[source]

Get a observation (if any) for given URI and match policy.

Parameters:
  • uri (unicode) – The URI (or URI pattern) to get the observation for.

  • match (unicode) – The matching policy for observation to retrieve, one of "exact", "prefix" or "wildcard".

Returns:

The observation (instance of one of ExactUriObservation, PrefixUriObservation or WildcardUriObservation) or None.

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

match_observations(uri)[source]

Returns the observations matching the given URI. This is the core method called by a broker to actually dispatch events.

Parameters:

uri (unicode) – The URI to match.

Returns:

A list of observations matching the URI. This is a list of instance of one of ExactUriObservation, PrefixUriObservation or WildcardUriObservation.

Return type:

list

is_protected_uri(uri, details=None)[source]

Test if the given URI is from a “protected namespace” (starting with wamp. or crossbar.). Note that “trusted” clients can access all namespaces.