@alt-javascript/scanner-darkly
v1.0.2
Published
A Pluggable Scanner For Launch Darkly Feature Flag Variations
Downloads
10
Maintainers
Readme
A Pluggable Scanner For Launch Darkly Feature Flag Variations
Introduction
A pluggable scanner for listening and acting on Launch Darkly feature flag variations in server-side node.js.
Usage
To use the module, follow the example in the included scan.js
file, which plays nicely with all the other
@alt-javascript modules.
The Scanner, takes an Arctor
(or array of Arctors
) that will act on flagged LaunchDarkly variations with
the implemented see(clearly)
function, in this case the provided LogArctor
outputs the changed flag value.
scan.js
const LaunchDarkly = require('launchdarkly-node-server-sdk');
const ScannerDarkly = require('@alt-javascript/scanner-darkly');
const {config} = require ("@alt-javascript/config");
const {boot} = require ("@alt-javascript/boot");
const {LoggerFactory} = require ('@alt-javascript/logger');
boot({ config });
const LogArctor = require('@alt-javascript/scanner-darkly'); // this uses booted logging config, so is required after boot().
const logger = LoggerFactory.getLogger('@alt-javascript/scanner-darkly/scan');
const ldlogger = LoggerFactory.getLogger('LaunchDarkly');
const SDK_KEY = config.get('scanner.darkly.sdk-key');
const scannerDarkly = new ScannerDarkly(
new LogArctor('logging-levels', {"key": "[email protected]"},null),
SDK_KEY,
{logger : ldlogger});
scannerDarkly.init();
// ... later, on process exit.
scannerDarkly.destroy();
When your LaunchDarkly product, environment, sdk-key and feature flag are configured, you should see output like:
Wed Jul 28 2021 10:57:03 GMT+1000 (GMT+10:00):LaunchDarkly:info:Initializing stream processor to receive feature flag updates
Wed Jul 28 2021 10:57:04 GMT+1000 (GMT+10:00):LaunchDarkly:info:Opened LaunchDarkly stream connection
Wed Jul 28 2021 10:57:04 GMT+1000 (GMT+10:00):LaunchDarkly:debug:Received put event
Wed Jul 28 2021 10:57:15 GMT+1000 (GMT+10:00):LaunchDarkly:debug:Received patch event
Wed Jul 28 2021 10:57:15 GMT+1000 (GMT+10:00):LaunchDarkly:debug:Updating logging-levels in features
Wed Jul 28 2021 10:57:15 GMT+1000 (GMT+10:00):@alt-javascript/scanner-darkly/LogArctor:info:Variation seen clearly as {"crew_prestart/src/services":"debug"}
Wed Jul 28 2021 10:57:18 GMT+1000 (GMT+10:00):LaunchDarkly:debug:Flushing %d events2
Yes, its Arctor, not Actor
Yes, the class is called Arctor
by design, and in homage to one of my very favourite novels,
What does a scanner see? he asked himself. I mean, really see? Into the head? Down into the heart? Does a passive infrared scanner like they used to use or a cube-type holo-scanner like they use these days, the latest thing, see into me - into us - clearly or darkly? I hope it does, he thought, see clearly, because I can't any longer these days see into myself. I see only murk. Murk outside; murk inside. I hope, for everyone's sake, the scanners do better. Because, he thought, if the scanner sees only darkly, the way I myself do, then we are cursed, cursed again and like we have been continually, and we'll wind up dead this way, knowing very little and getting that little fragment wrong too.
The movie is pretty good too, weird good.