Skip to content

Latest commit

 

History

History
122 lines (79 loc) · 2.58 KB

File metadata and controls

122 lines (79 loc) · 2.58 KB

@fluxninja/aperture-js / ApertureClient

Class: ApertureClient

Represents the Aperture Client used for interacting with the Aperture Agent.

Example

const apertureClient = new ApertureClient({
 address:
   process.env.APERTURE_AGENT_ADDRESS !== undefined
     ? process.env.APERTURE_AGENT_ADDRESS
     : "localhost:8089",
 apiKey: process.env.APERTURE_API_KEY || undefined,
 // if process.env.APERTURE_AGENT_INSECURE set channelCredentials to insecure
 channelCredentials:
   process.env.APERTURE_AGENT_INSECURE !== undefined
     ? grpc.credentials.createInsecure()
     : grpc.credentials.createSsl(),
});

Table of contents

Constructors

Methods

Constructors

constructor

new ApertureClient(«destructured»): ApertureClient

Constructs a new instance of the ApertureClient.

Parameters

Name Type
«destructured» Object
› address string
› apiKey? string
› channelCredentials? ChannelCredentials
› channelOptions? ChannelOptions

Returns

ApertureClient

Throws

Error if the address is not provided.

Methods

getState

getState(): ConnectivityState

Gets the current state of the gRPC channel.

Returns

ConnectivityState

The connectivity state of the channel.


shutdown

shutdown(): void

Shuts down the ApertureClient.

Returns

void


startFlow

startFlow(controlPoint, params): Promise<Flow>

Starts a new flow with the specified control point and parameters. startFlow() takes a control point and labels that get passed to Aperture Agent via flowcontrolv1.Check call. Return value is a Flow. The default semantics are fail-to-wire. If startFlow() fails, calling Flow.ShouldRun() on returned Flow returns as true.

Parameters

Name Type Description
controlPoint string The control point for the flow.
params FlowParams The parameters for the flow.

Returns

Promise<Flow>

A promise that resolves to a Flow object.

Example

apertureClient.startFlow("awesomeFeature", {
 labels: labels,
 grpcCallOptions: {
   deadline: Date.now() + 30000,
 },
 rampMode: false,
 cacheKey: "cache",
});