Skip to content

GraftJS/graft-broker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

graft-broker  Build Status

A Graft microservice that implements a pub/sub broker.

Install

npm install graft-broker --save

Usage

var broker  = graftBroker()
  , updates = broker.ReadChannel()
  , ret     = broker.ReadChannel()

ret.on('data', function(data) {
  console.log('subscription result', data)
  // prints
  // subscription result { status: 'subscribed', topic: 'hello' }
})

updates.on('data', function(data) {
  console.log('message received', data)

  // prints
  // message received { cmd: 'publish',
  //   topic: 'hello',
  //   hello: 'world' }
})

broker.write({
    cmd: 'subscribe'
  , topic: 'hello'
  , messages: updates // mandatory channel for updates
  , ret: ret // optional return channel
})

broker.write({
    cmd: 'publish'
  , topic: 'hello'
  , hello: 'world'
})

Subscribe errors

The subscribe command will return an error on the return channel if there is no topic or no messages channel. The error format follows the pattern:

{
    status: 'not subscribed'
  , reason: 'missing topic'
}

License

MIT

About

The Graft pub/sub broker

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published