featureflags-client
v1.0.3
Published
GRPC node client for feacture flags service
Downloads
2
Readme
Feature Flags client
NodeJS client grpc
lib, for featureflags service. Provides abilitty to gracefull set and updates
for ur features.
.proto
files were taken directly from repo above. They should be uploaded in some place from the root repo ondeploy
i guess
API
FeatureClient
is the base class. With it's constructor u will init grpc
client, wich will call ExchangeRequest
every 5 min. in async manner. So it shouldn't hurt ur eventloop
much, or app performance, coz of inmemory caching and time interval.
So u do this on application start:
import { FeatureClient, Variable, Types } from '@evo/featureflags-client';
// Ur default flags dict
const Flags = {
TEST: false,
NODE: false
};
const featureClient = new FeatureClient(
'thecorp', // project name
'grpc:50051', // grpc-url
Flags, // default flags
[
new Variable('username', Types.STRING) // ur controll values for Checks
],
true, // isDebugg mode
);
In ur controllers, or somewhere when ur need ur features to work properly,
call getFlags
, and provide there context = {}
. Ctx is the object with Variable
as a key,
and a value u want checks to depend on.
import { getFlags } from '@evo/featureflags-client';
// ready to use object with proceeded checks
const flags = getFlags({ username: 'Petro' });
if (flags.TEST) doSomeThing();
Left to implement
There several features, that exists in python flags.lib , that u are free to extend:
- StatsController - Accumulates interval/flag/requests count
- Tracer - Accumulates request/flag/values