OpenComponents plugin for interacting with Hobknob toggles inside OC components.
- Node version: min: 4
- OC registry
- Hobknob server
npm i oc-hobknob --save
More info about integrating OC plugins: here
...
const registry = oc.registry(configuration);
registry.register({
name: 'getToggle',
register: require('oc-hobknob'),
options: {
host: 'hobknob-etcd.hosts.com',
errorHandler: (err) => {
console.log(err);
}
}
}, (err) => {
if(err){
console.log('plugin initialisation failed:', err);
} else {
console.log('hobknob now available');
}
});
...
registry.start(callback);
Example for a component's server.js:
module.exports.data = (context, callback) => {
callback(null, {
showSomething: context.plugins.getToggle('myApp', 'toggleName', false)
});
};
parameter | type | mandatory | description |
---|---|---|---|
errorHandler | function |
no | The error handler |
host | string |
yes | The hobknob etcd host |
port | number |
no | Default 4001, the etcd port |
syncInterval | number (ms) |
no | Default 30000, time for the internal cache to refresh |
The plugin name is declared when initialising a plugin. Following assumes getToggle
is the designated name.
Syncronous function that gets a value for a given Service name and toggle. Default for when hobknob doesn't have the value is false
.
Syncronous function that gets a value for a given Service name and toggle. Default for when hobknob doesn't have the value is false
.
Syncronous function that gets an Hobknob toggle value for a given serviceName and toggleName and secondaryToggleKey using specified default value.
Yes please. Open an issue first.
MIT