@alt-javascript/scanner-darkly

1.0.2 • Public • Published

A Pluggable Scanner For Launch Darkly Feature Flag Variations

NPM
Language Badge Package Badge
release notes

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": "user@test.com"},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.

A Scanner Darkly - Philip. K. Dick, 1977

The movie is pretty good too, weird good.

Package Sidebar

Install

npm i @alt-javascript/scanner-darkly

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

9.77 kB

Total Files

10

Last publish

Collaborators

  • craigparra