crossbar.master.cluster.webcluster¶
Classes¶
Manages Web clusters, which runs Crossbar.io Web transport listening |
|
Background monitor running periodically in the master node to monitor, check and apply |
Module Contents¶
- class WebClusterManager(session, globaldb, globalschema, db, schema, reactor=None)[source]¶
Bases:
objectManages Web clusters, which runs Crossbar.io Web transport listening endpoints on many (frontend) workers over many nodes using applying a shared, common transport definition, such as regarding the Web services configured on URL paths of the Web transport.
- async add_webcluster_node(webcluster_oid: str, node_oid: str, config: dict | None = None, details: autobahn.wamp.types.CallDetails | None = None) dict[source]¶
Add a node to a web cluster. The node-to-webcluster association can be configured in
config:{ "parallel": 2, "standby": false }
parallel: The parallelism (in CPU) that the node should receive.standby: Wheather to add this node as a standby node that only takes over work when active nodes fail.
The web cluster will start and manage
parallelproxy workers on the node. Whenstandbyis set (NOT YET IMPLEMENTED), the node will not become active immediately, but only be used and become active to replace a failed (active) node in the cluster.- Parameters:
webcluster_oid – OID of the web cluster to which to add the node.
node_oid – OID of the node to add to the cluster. A node can be added to more than one cluster.
- Returns:
Added node, for example:
{ "cluster_oid": "92f5f4c7-4175-4c72-a0a6-81467c343565", "node_oid": "b0b36b60-5712-40fd-8ae5-ac1177ea850c", "parallel": 2, "standby": null }
- async add_webcluster_service(webcluster_oid: str, path: str, webservice: dict, details: autobahn.wamp.types.CallDetails | None = None) dict[source]¶
Add a Web service to a Web cluster.
- Parameters:
webcluster_oid – Web cluster to which to add the Web service.
path – The path on which to add the webservice.
webservice – Web service definition object.
- Returns:
The web service added to the web cluster, for example:
{ "description": null, "directory": "..", "label": null, "oid": "4411eb80-006a-45a0-8624-52a7ee84d0ce", "options": { "enable_directory_listing": true }, "path": "/", "tags": null, "type": "static", "webcluster_oid": "92f5f4c7-4175-4c72-a0a6-81467c343565" }
- async create_webcluster(webcluster: dict, details: autobahn.wamp.types.CallDetails | None = None) dict[source]¶
Create a new web cluster definition
webcluster:Web listening endpoint:
tcp_version: IP version, either 4 for 6tcp_port: IP listening porttcp_shared: enable TCP port sharingtcp_interface: listen on this interfacetcp_backlog: TCP accept backlog queue size
Web endpoint TLS configuration:
tls_key: TLS server private key to usetls_certificate: TLS server certificate to usetls_chain_certificates: TLS certificate chaintls_dhparam: DH parameter filetls_ciphers: Ciphers listtls_ca_certificates: CA certificates to use
Web transport options:
http_client_timeout: HTTP client inactivity timeouthttp_hsts: enable HTTP strict transport security (HSTS)http_hsts_max_age: HSTS maximum age to announcehttp_access_log: enable Web request access logginghttp_display_tracebacks: enable tracebacks when running into Web errors
- Procedure:
crossbarfabriccenter.mrealm.cluster.create_webclusterURI of WAMP procedure to call.- Event:
crossbarfabriccenter.mrealm.cluster.on_webcluster_createdWAMP event published once the web cluster has been created.- Error:
wamp.error.invalid_configurationWAMP error returned when the web cluster configuration provided has a problem.- Error:
wamp.error.not_authorizedWAMP error returned when the user is currently not allowed to created (another) web cluster.- Error:
crossbar.error.already_existsWAMP error returned when a web cluster named as contained in the configuration already exists.- Parameters:
webcluster –
Web cluster settings. For example:
{ "name": "cluster1" }
- Returns:
Web cluster creation information. For example:
{ "changed": 1598388333642427113, "description": null, "http_access_log": null, "http_client_timeout": null, "http_display_tracebacks": null, "http_hsts": null, "http_hsts_max_age": null, "label": null, "name": "cluster1", "oid": "96e3d9a6-3e88-4205-8eec-2e7c338b2620", "owner_oid": "c10a7e49-cea6-47ce-a003-74f7196d1763", "status": "STOPPED", "tags": null, "tcp_backlog": null, "tcp_interface": null, "tcp_port": 8080, "tcp_shared": true, "tcp_version": null, "tls_ca_certificates": null, "tls_certificate": null, "tls_chain_certificates": null, "tls_ciphers": null, "tls_dhparam": null, "tls_key": null }
- async delete_webcluster(webcluster_oid: str, details: autobahn.wamp.types.CallDetails | None = None) dict[source]¶
Delete an web router cluster definition. The web cluster must be in status
"STOPPED".- Procedure:
crossbarfabriccenter.webcluster.delete_webclusterURI of WAMP procedure to call.- Event:
crossbarfabriccenter.webcluster.on_webcluster_deletedWAMP event published once the web cluster has been deleted.- Error:
wamp.error.invalid_argumentWAMP error returned whenwebcluster_oidwas invalid.- Error:
crossbar.error.no_such_objectWAMP error returned whenwebcluster_oidwas not found.- Error:
crossbar.error.not_stoppedWAMP error returned when web cluster is not in statusSTOPPED.- Parameters:
webcluster_oid – OID of the Web cluster to delete
- Returns:
Deleted router cluster, for example:
{ "changed": 1598391866736370655, "description": null, "http_access_log": null, "http_client_timeout": null, "http_display_tracebacks": null, "http_hsts": null, "http_hsts_max_age": null, "label": null, "name": "cluster1", "oid": "90d46851-0ba4-4e3d-8d9d-7a117379b212", "owner_oid": "8d6e3068-900a-4fa8-a6f5-0828c8d0ee24", "status": "STOPPED", "tags": null, "tcp_backlog": null, "tcp_interface": null, "tcp_port": 8080, "tcp_shared": true, "tcp_version": null, "tls_ca_certificates": null, "tls_certificate": null, "tls_chain_certificates": null, "tls_ciphers": null, "tls_dhparam": null, "tls_key": null }
- get_webcluster(webcluster_oid: str, details: autobahn.wamp.types.CallDetails | None = None) dict[source]¶
Return configuration and run-time status information for a web cluster (by object ID).
- Parameters:
routercluster_oid – Object ID of the web cluster to return.
- Returns:
Web cluster definition. For example:
{ "changed": 1598388779771813358, "description": null, "http_access_log": null, "http_client_timeout": null, "http_display_tracebacks": null, "http_hsts": null, "http_hsts_max_age": null, "label": null, "name": "cluster1", "oid": "4917ca20-acc5-497a-9801-b53db5db4d89", "owner_oid": "8d6e3068-900a-4fa8-a6f5-0828c8d0ee24", "status": "STOPPED", "tags": null, "tcp_backlog": null, "tcp_interface": null, "tcp_port": 8080, "tcp_shared": true, "tcp_version": null, "tls_ca_certificates": null, "tls_certificate": null, "tls_chain_certificates": null, "tls_ciphers": null, "tls_dhparam": null, "tls_key": null }
- get_webcluster_by_name(webcluster_name: str, details: autobahn.wamp.types.CallDetails | None = None) dict[source]¶
Return configuration and run-time status information for a web cluster (by name).
See also the corresponding procedure
crossbar.master.cluster.webcluster.WebClusterManager.get_webcluster()which returns the same information, given and object ID rather than name.- Parameters:
webcluster_name – Name of the web cluster to return.
- Returns:
Web cluster definition.
- get_webcluster_node(webcluster_oid: str, node_oid: str, details: autobahn.wamp.types.CallDetails | None = None) dict[source]¶
Get information (such as for example parallel degree) for the association of a node with a web cluster.
- Parameters:
webcluster_oid – Object ID of web cluster to return node association for.
node_oid – Object ID of node to return association for.
- Returns:
Information for the association of the node with the webcluster, for example:
{ "cluster_oid": "92f5f4c7-4175-4c72-a0a6-81467c343565", "node_oid": "cf0241bc-b9d9-4b81-a496-5873a74b5f0a", "parallel": 2, "standby": null }
- get_webcluster_service(webcluster_oid: str, webservice_oid: str, details: autobahn.wamp.types.CallDetails | None = None) dict[source]¶
Get definition of a web service by ID.
See also the corresponding procedure
crossbar.master.cluster.webcluster.WebClusterManager.get_webcluster_service_by_path()which returns the same information, given HTTP path rather than object ID.- Parameters:
webcluster_oid – The web cluster running the web service to return.
webservice_oid – The web service to return.
- Returns:
The web service definition, for example:
{ "description": null, "label": null, "oid": "6cc51192-4259-4640-84cb-ee03b6f92fbf", "path": "info", "tags": null, "type": "nodeinfo", "webcluster_oid": "92f5f4c7-4175-4c72-a0a6-81467c343565" }
- get_webcluster_service_by_path(webcluster_oid: str, path: str, details: autobahn.wamp.types.CallDetails | None = None) dict[source]¶
Get definition of a web service by HTTP path.
See also the corresponding procedure
crossbar.master.cluster.webcluster.WebClusterManager.get_webcluster_service()which returns the same information, given and object ID rather than HTTP path.- Parameters:
webcluster_oid – The web cluster running the web service to return.
path – HTTP path of web service to return.
- Returns:
see
crossbar.master.cluster.webcluster.WebClusterManager.get_webcluster_service()
- list_webcluster_nodes(webcluster_oid: str, return_names: bool | None = None, filter_by_status: str | None = None, details: autobahn.wamp.types.CallDetails | None = None) List[str][source]¶
List nodes currently associated with the given web cluster.
- Parameters:
webcluster_oid – The web cluster to list nodes for.
return_names – Return web cluster node names (WAMP authid) instead of object IDs.
filter_by_status – Filter nodes by this status, eg.
"online".
- Returns:
List of node IDs of nodes associated with the web cluster, for example:
[ "3c7584f7-b8db-4e9b-8508-7ab4d573265d", "aa1d67de-d434-4bee-96ec-d0f576c12e02", "b0b36b60-5712-40fd-8ae5-ac1177ea850c", "cf0241bc-b9d9-4b81-a496-5873a74b5f0a" ]
or with
return_namesset:[ "node1", "node2", "node3", "node4" ]
- list_webcluster_services(webcluster_oid: str, prefix: str | None = None, details: autobahn.wamp.types.CallDetails | None = None) Dict[str, str][source]¶
List webservices defined on a webcluster, optionally filtering by prefix.
- Parameters:
webcluster_oid – The web cluster for which to list currently defined web services.
prefix – If provided, the path prefix for filtering web services.
- Returns:
A map with HTTP paths as keys and webservice ID as values, for example:
{ "/": "92f5f4c7-4175-4c72-a0a6-81467c343565", "info": "92f5f4c7-4175-4c72-a0a6-81467c343565", "settings": "92f5f4c7-4175-4c72-a0a6-81467c343565", "ws": "92f5f4c7-4175-4c72-a0a6-81467c343565" }
- list_webclusters(return_names: bool | None = False, details: autobahn.wamp.types.CallDetails | None = None) List[str][source]¶
Returns list of web clusters defined. Detail information for a web cluster can be retrieved using
crossbar.master.cluster.webcluster.WebClusterManager.get_webcluster().- Parameters:
return_names – Return webcluster names instead of object IDs
- Returns:
List of WebCluster UUIDs (or names). For example:
[ "4917ca20-acc5-497a-9801-b53db5db4d89" ]
or with
return_namesset:[ "cluster1" ]
- async remove_webcluster_node(webcluster_oid: str, node_oid: str, details: autobahn.wamp.types.CallDetails | None = None) dict[source]¶
Remove a node from a web cluster.
- Parameters:
webcluster_oid – OID of the web cluster from which to remove the node.
node_oid – OID of the node to remove from the web cluster
- Returns:
Node removed from web cluster, for example:
{ "cluster_oid": "92f5f4c7-4175-4c72-a0a6-81467c343565", "node_oid": "cf0241bc-b9d9-4b81-a496-5873a74b5f0a", "parallel": 2, "standby": null }
- async remove_webcluster_service(webcluster_oid: str, webservice_oid: str, details: autobahn.wamp.types.CallDetails | None = None) dict[source]¶
Remove the Web service from the Web cluster.
- Parameters:
webcluster_oid – Object ID of the web cluster from which to remove the web service.
webservice_oid – Object ID of the web service to remove.
- Returns:
The web service removed from the web cluster, for example:
{ "description": null, "label": null, "oid": "96d30fa8-6df2-4888-9845-87db8884a062", "path": "settings", "tags": null, "type": "json", "value": [ 1, 2, 3 ], "webcluster_oid": "92f5f4c7-4175-4c72-a0a6-81467c343565" }
- async start_webcluster(webcluster_oid: str, details: autobahn.wamp.types.CallDetails | None = None) dict[source]¶
Start a web cluster.
- Parameters:
webcluster_oid – Object ID of web cluster to start.
- Returns:
Started web cluster, for example:
{ "changed": 1598395797587541578, "oid": "92f5f4c7-4175-4c72-a0a6-81467c343565", "status": "STARTING", "who": { "authid": "superuser", "authrole": "owner", "session": 2587789023701533 } }
- async stop_webcluster(webcluster_oid: str, details: autobahn.wamp.types.CallDetails | None = None) dict[source]¶
Stop a running web cluster.
- Procedure:
crossbarfabriccenter.webcluster.stop_webclusterURI of WAMP procedure to call.- Event:
crossbarfabriccenter.webcluster.on_webcluster_stopppingWAMP event published once the web cluster is stopping.- Error:
wamp.error.invalid_argumentWAMP error returned whenwebcluster_oidwas invalid.- Error:
crossbar.error.no_such_objectWAMP error returned whenwebcluster_oidwas not found.- Error:
crossbar.error.cannot_stopWAMP error returned when web cluster is not in statusRUNNINGorSTARTING.- Parameters:
webcluster_oid – Object ID of web cluster to stop.
- Returns:
Stopped web cluster, for example:
{ "changed": 1598395878649535271, "oid": "92f5f4c7-4175-4c72-a0a6-81467c343565", "status": "STOPPING", "who": { "authid": "superuser", "authrole": "owner", "session": 1047738189758144 } }
- class WebClusterMonitor(manager, webcluster_oid, interval=10.0)[source]¶
Bases:
objectBackground monitor running periodically in the master node to monitor, check and apply necessary actions for web clusters.
The monitor is started when a web cluster is started.