@fluxninja/aperture-js / 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(),
});• new ApertureClient(«destructured»): ApertureClient
Constructs a new instance of the ApertureClient.
| Name | Type |
|---|---|
«destructured» |
Object |
› address |
string |
› apiKey? |
string |
› channelCredentials? |
ChannelCredentials |
› channelOptions? |
ChannelOptions |
Throws
Error if the address is not provided.
▸ getState(): ConnectivityState
Gets the current state of the gRPC channel.
ConnectivityState
The connectivity state of the channel.
▸ shutdown(): void
Shuts down the ApertureClient.
void
▸ 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.
| Name | Type | Description |
|---|---|---|
controlPoint |
string |
The control point for the flow. |
params |
FlowParams |
The parameters for the flow. |
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",
});