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

NameTypeAttributesDefaultDescription
tenantTokenstringTenant API Token for communicating with tenant services, this will be read from secrets if not provided
virtualEnvstringVirtual Environment to be provided to the broke
agentexternal:ServiceDiscoveryAgentrequire('@pps/svc-discovery').agentservice 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

NameTypeAttributeDescription
virtualEnvstringVirtual environment name, passed through to StorageWsClient constructor.
agentexternal:ServiceDiscoverAgentService Discovery Agent, passed through to StorageWsClient constructor.

Return: Promise.<module:broker-client.StorageWsClient>