unicorn-adapter

1.1.1 • Public • Published

Unicorn Adapter

Travis (.org) Coverage Status npm NPM Twitter Follow

Unicorn Adapter is a node library to help subscribe to events in the event processing platform Unicorn.

Getting started

npm install unicorn-adapter to install the package

const UnicornAdapter = require('unicorn-adapter');
 
let unicornAdapter = new UnicornAdapter("Your Unicorn Url", "Your callback Url", options);

Available options:

  • maxTries - Number of retries

Subscribe to events

let uuid;
unicornAdapter.subscribeToEvent('EventType').then(subscriptionId => {
    uuid = subscriptionUuid;
    console.log(`Subscription UUID: ${ subscriptionId }`);
});
 
unicornAdapter.unsubscribeFromEvent(uuid);

Publish events

const exampleEventType = 'exampleEventType';
const exampleEvent = {
  key1: 'value1',
  key2: 'value2'
};
 
// Sent event to Unicorn
unicornAdapter.generateEvent(exampleEvent, exampleEventType).then(eventId => {
  console.log(`EventId: ${ eventId }`);
});
 
// Adds TimeStamp and DO_state to event before sending event to Unicorn
unicornAdapter.generateChimeraEvent(exampleEvent, exampleEventType, 'state1').then(eventId => {
  console.log(`EventId: ${ eventId }`);
});

Authors

Package Sidebar

Install

npm i unicorn-adapter

Weekly Downloads

4

Version

1.1.1

License

MIT

Unpacked Size

58.4 kB

Total Files

17

Last publish

Collaborators

  • lichtblau