crossbar.worker.proxy

Classes

ProxyConnection

Proxy connection run-time representation.

ProxyController

Controller for proxy workers. Manages:

ProxyRoute

Proxy route run-time representation.

ProxyWorkerProcess

Internal run-time representation of a native worker (router or

Module Contents

class ProxyConnection(controller: ProxyController, connection_id: str, config: Dict[str, Any])[source]

Bases: object

Proxy connection run-time representation.

__str__()[source]
_config[source]
_connection_id[source]
_controller[source]
_started = None[source]
_state = 1[source]
_stopped = None[source]
property config: Dict[str, Any][source]

The original configuration as supplied to this proxy backend connection.

Type:

return

property id: str[source]

The ID of this proxy backend connection.

Type:

return

log[source]
marshal()[source]
start()[source]

Start this proxy backend connection.

property started: int | None[source]

When this proxy backend connection was started (Posix time in ns).

Type:

return

property state: int[source]

Current state of this proxy backend connection.

Type:

return

stop()[source]

Stop this proxy backend connection.

property stopped: int | None[source]

When this proxy backend connection was stopped (Posix time in ns).

Type:

return

class ProxyController(config=None, reactor=None, personality=None)[source]

Bases: crossbar.worker.transport.TransportController

Controller for proxy workers. Manages:

  • proxy transports, for accepting incoming client connections

  • proxy connections, for backend router connections

  • proxy routes, for routes from (realm_name, role_name) to backend router connections

and

  • web transport services (from base class TransportController), when running a proxy transport

of type web.

Proxy controllers also inherit more procedures and events from the base classes

WORKER_TITLE = 'WAMP proxy'[source]
WORKER_TYPE = 'proxy'[source]
_backends_by_frontend[source]
_cbdir[source]
_connections: Dict[str, ProxyConnection][source]
_connections_by_auth: Dict[Tuple[str, str], Set[ProxyConnection]][source]
_next_route_id = 0[source]
_reactor = None[source]
_roundrobin_idx[source]
_router_factory[source]
_router_session_factory[source]
_routes: Dict[str, Dict[str, ProxyRoute]][source]
_routes_by_connection: Dict[str, Set[ProxyRoute]][source]
_service_sessions[source]
can_map_backend(session_id, realm, authid, authrole, authextra)[source]

Checks if the proxy can map the incoming frontend session to a backend.

Returns:

True only-if map_backend() can succeed later for the same args (essentially, if the realm + role exist).

get_backend_config(realm_name, role_name)[source]

Return backend connection information for the given backend realm and role.

Returns:

a dict containing the connection configuration for the backend identified by the realm_name and role_name

get_proxy_connection(connection_id, details=None)[source]

Get run-time information for a currently running proxy connection.

Parameters:
  • connection_id – The run-time ID of the proxy connection to return information for.

  • details – WAMP call details.

Returns:

Proxy connection configuration.

get_proxy_connections(details=None)[source]

Get currently running proxy connections.

Parameters:

details – WAMP call details.

Returns:

List of run-time IDs of currently running connection.s

get_proxy_realm_route(realm_name, route_id, details=None)[source]

Get a particular realm-route

Parameters:

details (autobahn.wamp.types.CallDetails) – Call details.

Returns:

Proxy route object.

Return type:

dict

get_proxy_routes(details=None)[source]

Get proxy routes currently running in this proxy worker.

Parameters:

details (autobahn.wamp.types.CallDetails) – Call details.

Returns:

List of (target) realm names in proxy routes currently running.

Return type:

list

get_proxy_transport(transport_id, details=None)[source]

Get transport currently running in this proxy worker.

Parameters:

details (autobahn.wamp.types.CallDetails) – Call details.

Returns:

List of transports currently running.

Return type:

dict

get_proxy_transports(details=None)[source]

Get proxy (listening) transports currently running in this proxy worker.

Parameters:

details (autobahn.wamp.types.CallDetails) – Call details.

Returns:

List of transport IDs of transports currently running.

Return type:

list

get_service_session(realm: str, authrole: str) autobahn.twisted.wamp.ApplicationSession[source]

Returns a cached service session on the given realm using the given role.

Service sessions are used for:

Service sessions are NOT used to forward WAMP client connections incoming to the proxy worker.

Parameters:
  • realm – WAMP realm (the WAMP name, _not_ the run-time object ID).

  • authrole – WAMP authentication role (the WAMP URI, _not_ the run-time object ID).

Returns:

The service session for the realm.

has_realm(realm: str) bool[source]

Check if a route to a realm with the given name is currently running.

Parameters:

realm – Realm name (the WAMP name, _not_ the run-time object ID).

Returns:

True if a route to the realm (for any role) exists.

has_role(realm: str, authrole: str) bool[source]

Check if a role with the given name is currently running in the given realm.

Parameters:
  • realm – WAMP realm (the WAMP name, _not_ the run-time object ID).

  • authrole – WAMP authentication role (the WAMP URI, _not_ the run-time object ID).

Returns:

True if a route to the realm for the role exists.

list_proxy_realm_routes(realm_name, details=None)[source]

Get list of all routes enabled for a particular realm

map_backend(frontend, realm: str, authid: str, authrole: str, authextra: Dict[str, Any] | None)[source]

Returns the cached backend forwarding session for the given frontend session. Map the given frontend session to a backend session under the given authentication credentials.

Parameters:
  • frontend

  • realm

  • authid

  • authrole

  • authextra

Returns:

a protocol instance connected to the backend

onJoin(details)[source]

Called when worker process has joined the node’s management realm.

start_proxy_connection(connection_id, config, details=None)[source]

Start a new backend connection for the proxy.

Called from master node orchestration in

:method:`crossbar.master.arealm.arealm.ApplicationRealmMonitor._apply_webcluster_connections`.

Parameters:
  • connection_id

  • config

  • details

Returns:

start_proxy_realm_route(realm_name, config, details=None)[source]

Start a new proxy route for the given realm. A proxy route maps authroles on the given realm to proxy backend connection IDs.

Example route configuration:

{
    "anonymous": "conn1",
    "restbridge": "conn1",
    "user": "conn2"
}

In this example, the two specified connections "conn1" and "conn2" must be running already.

Parameters:
  • realm_name – The realm this route should apply for.

  • config – The route configuration.

  • details – WAMP call details.

Returns:

Proxy route run-time information.

start_proxy_transport(transport_id, config, details=None)[source]

Start a new proxy front-end listening transport.

Parameters:
  • transport_id – The run-time ID to start the transport under.

  • config – The listening transport configuration.

  • details – WAMP call details.

Returns:

Proxy transport run-time metadata.

stop_proxy_connection(connection_id, details=None)[source]
Parameters:
  • connection_id

  • details

Returns:

stop_proxy_realm_route(realm_name, route_id, details=None)[source]

Stop a currently running proxy route.

Parameters:
  • realm_name – The name of the realm to stop the route for.

  • route_id – Which route to stop

  • details – WAMP call details.

Returns:

Run-time information about the stopped route.

stop_proxy_transport(transport_id, details=None)[source]

Stop a currently running proxy front-end listening transport.

Parameters:
  • transport_id – The run-time ID of the transport to stop.

  • details – WAMP call details.

Returns:

Proxy transport run-time information.

unmap_backend(frontend, backend, leave_reason=None, leave_message=None)[source]

Unmap the backend session from the given frontend session it is currently mapped to.

class ProxyRoute(controller: ProxyController, realm_name: str, route_id: str, config: Dict[str, Any])[source]

Bases: object

Proxy route run-time representation.

__str__()[source]
_config[source]
_controller[source]
_realm_name[source]
_route_id[source]
_started = None[source]
_state = 1[source]
_stopped = None[source]
property config: Dict[str, Any][source]

The original configuration as supplied to this proxy route.

Type:

return

has_role(role_name) bool[source]

Checks if the given role is mapped in this proxy route.

Parameters:

role_name – Role to lookup.

Returns:

True if the role is configured in this proxy route.

property id: str[source]

The ID of this proxy route.

Type:

return

log[source]
map_connection_id(role_name) str | None[source]

Map the given role to a connection ID according to the configuration of this route.

Parameters:

role_name – Role to map.

Returns:

Connection ID configured for the role in this proxy route.

marshal() Dict[str, Any][source]
property realm: str[source]

The realm this route applies to.

Type:

return

start()[source]

Start proxy route.

property started: int | None[source]

When this route was started in it’s hosting worker.

Type:

return

property state: int[source]

Current state of route in it’s hosting worker.

Type:

return

stop()[source]

Stop proxy route.

property stopped: int | None[source]

When this route was stopped in it’s hosting worker.

Type:

return

class ProxyWorkerProcess(controller, id, who=None, keeplog=None)[source]

Bases: crossbar.node.worker.NativeWorkerProcess

Internal run-time representation of a native worker (router or container currently) process.

LOGNAME = 'Proxy'[source]
TYPE = 'proxy'[source]