crossbar.worker.router

Classes

RouterController

A native Crossbar.io worker that runs a WAMP router which can manage

Module Contents

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

Bases: crossbar.worker.transport.TransportController

A native Crossbar.io worker that runs a WAMP router which can manage multiple realms, run multiple transports and links, as well as host multiple (embedded) application components.

WORKER_TITLE = 'Router'[source]
WORKER_TYPE = 'router'[source]
_router_factory[source]
_router_session_factory[source]
_service_sessions[source]
components: Dict[str, crossbar.worker.types.RouterComponent][source]
components_shared[source]
get_router_component(component_id, details=None)[source]

Get details about a router component

Parameters:
Returns:

Details of component

Return type:

dict

get_router_components(details=None)[source]

Get app components currently running in this router worker.

Parameters:

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

Returns:

List of app components currently running.

Return type:

list[dict]

get_router_realm(realm_id, details=None)[source]

Return realm detail information.

Parameters:
Returns:

realm information object

Return type:

dict

get_router_realm_by_name(realm_name, details=None)[source]

Return realm detail information.

Parameters:
Returns:

realm information object

Return type:

dict

Get router link detail information.

Parameters:
  • realm_id (str) – The ID of the (local) realm of the link.

  • link_id (str) – The ID of the router link to return.

Returns:

Router link detail information.

Return type:

dict

Returns the currently running routing links to remote router realms.

Parameters:

realm_id (str) – The ID of the (local) realm to get links for.

Returns:

List of router link IDs.

Return type:

list[str]

get_router_realm_role(realm_id, role_id, details=None)[source]

Return role detail information.

Parameters:
Returns:

role information object

Return type:

dict

get_router_realm_roles(realm_id, details=None)[source]

Get roles currently running on a realm running on this router worker.

Parameters:
Returns:

A list of roles.

Return type:

list[dict]

get_router_realm_stats(realm_id=None, details=None)[source]

Return realm messaging statistics.

Parameters:

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

Returns:

realm statistics object

Return type:

dict

get_router_realms(details=None)[source]

Get realms currently running on this router worker.

Parameters:

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

Returns:

List of realms currently running.

Return type:

list[str]

get_router_transport(transport_id, details=None)[source]

Get transports currently running in this router worker.

Parameters:

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

Returns:

List of transports currently running.

Return type:

list[dict]

get_router_transports(details=None)[source]

Get transports currently running in this router worker.

Parameters:

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

Returns:

List of transports currently running.

Return type:

list[dict]

get_service_session(realm, authrole)[source]
has_realm(realm: str) bool[source]

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

Parameters:

realm (str) – Realm name (_not_ ID).

Returns:

True if realm is running.

Return type:

bool

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 (str) – WAMP realm (name, _not_ run-time ID).

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

Returns:

True if realm is running.

Return type:

bool

kill_by_authid(realm_id, authid, reason, message=None, details=None)[source]
onJoin(details, publish_ready=True)[source]

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

onLeave(details)[source]

Implements autobahn.wamp.interfaces.ISession.onLeave()

onWelcome(msg)[source]

Implements autobahn.wamp.interfaces.ISession.onWelcome()

realm_by_name(name)[source]
realm_to_id: Dict[str, str][source]
realms: Dict[str, crossbar.worker.types.RouterRealm][source]
property router_factory[source]

The router factory used for producing (per-realm) routers.

Type:

return

router_factory_class[source]
router_realm_class[source]
property router_session_factory[source]

The router session factory for producing router sessions.

Type:

return

set_service_session(session, realm, authrole)[source]
start_router_component(component_id, config, details=None)[source]

Start an app component in this router worker.

Parameters:
start_router_realm(realm_id, realm_config, details=None)[source]

Starts a realm on this router worker. The minimum configuration must contain the realm name:

{
    "name": "realm1"
}

The configuration can also configure one or more roles, including configuration of role permissions:

{
    "name": "realm1",
    "roles": [{
        "name": "anonymous",
        "permissions": [{
            "uri": "",
            "match": "prefix",
            "allow": {
                "call": True,
                "register": True,
                "publish": True,
                "subscribe": True
            },
            "disclose": {
                "caller": True,
                "publisher": True
            },
            "cache": True
        }]
    }]
}
Parameters:

Start a new router link to a remote router on a (local) realm.

The link configuration (link_config) must include the transport definition to the remote router. Here is an example:

{
    "realm": "realm1",
    "transport": {
        "type": "websocket",
        "endpoint": {
            "type": "tcp",
            "host": "localhost",
            "port": 8002
        },
        "url": "ws://localhost:8002/ws"
    }
}
Parameters:
  • realm_id (str) – The ID of the (local) realm on which to start the link.

  • link_id (str) – The ID of the router link to start.

  • link_config (dict) – The router link configuration.

Returns:

The new link detail information.

Return type:

dict

start_router_realm_role(realm_id, role_id, role_config, details=None)[source]

Start a role on a realm running on this router worker.

Parameters:
  • id (str) – The ID of the realm the role should be started on.

  • role_id (str) – The ID of the role to start under.

  • config (dict) – The role configuration.

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

start_router_transport(transport_id, config, create_paths=False, details=None)[source]

Start a transport on this router worker.

Parameters:
  • transport_id (str) – The ID of the transport to start.

  • config (dict) – The transport configuration.

  • create_paths (bool) – If set, start subservices defined in the configuration too. This currently only applies to Web services, which are part of a Web transport.

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

stop_router_component(component_id, details=None)[source]

Stop an app component currently running in this router worker.

Parameters:
stop_router_realm(realm_id, details=None)[source]

Stop a realm currently running on this router worker.

When a realm has stopped, no new session will be allowed to attach to the realm. Optionally, close all sessions currently attached to the realm.

Parameters:

Stop a currently running router link.

Parameters:
  • realm_id (str) – The ID of the (local) realm on which the link is running that is to be stopped.

  • link_id (str) – The ID of the router link to stop.

Returns:

The stopped link detail information.

Return type:

dict

stop_router_realm_role(realm_id, role_id, details=None)[source]

Stop a role currently running on a realm running on this router worker.

Parameters:
stop_router_transport(transport_id, details=None)[source]

Stop a transport currently running in this router worker.

Parameters:
transports: Dict[str, crossbar.worker.transport.RouterTransport][source]