Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/opencomponents/oc-hobknob
OpenComponents hobknob plugin
https://github.com/opencomponents/oc-hobknob
hobknob oc-plugin opencomponents
Last synced: about 2 months ago
JSON representation
OpenComponents hobknob plugin
- Host: GitHub
- URL: https://github.com/opencomponents/oc-hobknob
- Owner: opencomponents
- License: mit
- Created: 2016-05-20T11:04:17.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-04-30T21:45:46.000Z (about 4 years ago)
- Last Synced: 2024-04-14T07:49:32.999Z (3 months ago)
- Topics: hobknob, oc-plugin, opencomponents
- Language: JavaScript
- Size: 27.3 KB
- Stars: 2
- Watchers: 23
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-oc - Hobknob plugin - Plugin for integrating [Hobknob](https://github.com/opentable/hobknob) (Registry Plugins/Utilities)
README
oc-hobknob [![Build Status](https://secure.travis-ci.org/opencomponents/oc-hobknob.png?branch=master)](http://travis-ci.org/opencomponents/oc-hobknob)
==========[![Greenkeeper badge](https://badges.greenkeeper.io/opencomponents/oc-hobknob.svg)](https://greenkeeper.io/)
[OpenComponents](https://github.com/opentable/oc) plugin for interacting with [Hobknob](https://github.com/opentable/hobknob) toggles inside OC components.
# Requirements:
* Node version: min: **4**
* OC registry
* Hobknob server### Install
```js
npm i oc-hobknob --save
```### Registry setup
More info about integrating OC plugins: [here](https://github.com/opentable/oc/wiki/Registry#plugins)
```js
...
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);
```### Using it inside components
Example for a component's server.js:
```js
module.exports.data = (context, callback) => {
callback(null, {
showSomething: context.plugins.getToggle('myApp', 'toggleName', false)
});
};
```### API
#### Api for plugin setup:
|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|#### Api for plugin usage:
The plugin name is declared when initialising a plugin. Following assumes `getToggle` is the designated name.
##### context.plugins.getToggle(serviceName, toggleName)
Syncronous function that gets a value for a given Service name and toggle. Default for when hobknob doesn't have the value is `false`.
##### context.plugins.getToggle(serviceName, toggleName, defaultValue)
Syncronous function that gets a value for a given Service name and toggle. Default for when hobknob doesn't have the value is `false`.
##### context.plugins.getToggle(serviceName, toggleName, secondaryToggleKey, defaultValue)
Syncronous function that gets an Hobknob toggle value for a given serviceName and toggleName and secondaryToggleKey using specified default value.
# Contributing
Yes please. Open an issue first.
### License
MIT