Websocket support for the Storage Broker
WebSocket Client for communicating with the Storage Broker API. This class extends the basic WebSocket client, see WebSocket Client documentation for more details on capabilities and operation.
The following plugins are configured for the Payment Broker API:
Protocol Validation Plugin
Smart Reconnection Plugin
RPC Plugin
New StorageWsClient(tenantToken, virtualEnvopt, agentopt)
Creates a new StorageWsClient with the provided configuration.
Paramater
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
| tenantToken | string | Tenant API Token for communicating with tenant services, this will be read from secrets if not provided | ||
| virtualEnv | string | Virtual Environment to be provided to the broke | ||
| agent | external:ServiceDiscoveryAgent | require('@pps/svc-discovery').agent | service discovery agent for locating a broker instance |
Example
Default Service Discovery
const {StorageWsClient} = require('@pps/broker-client');
const client = new StorageWsClient(token, virtualEnv);
await client.open();
// start sending RPCs :)
await client.close();
withGlobalToken(virtualEnvopt, agentopt) → {Promise.<module:broker-client.StorageWsClient>}
Creates a new StorageWsClient using the global tenant token configured by the secrets module.
Paramater
| Name | Type | Attribute | Description |
|---|---|---|---|
| virtualEnv | string | Virtual environment name, passed through to StorageWsClient constructor. | |
| agent | external:ServiceDiscoverAgent | Service Discovery Agent, passed through to StorageWsClient constructor. |
Return: Promise.<module:broker-client.StorageWsClient>
Updated over 4 years ago
