Skip to content

Commit

Permalink
BIP-545 BIP-538 smarter install script and oauth, bastion working
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfonso Gober committed Jun 16, 2015
1 parent ab9cb5c commit bb12b11
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions server/utilities/bastion.litcoffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
### Bastion helper class.

rabbit = require 'rabbit.js'
events = require 'events'
Q = require 'q'
Rx = require 'rx'
class Bastion
constructor: (url) ->
self = @
self.queue = rabbit.createContext url
self.queue.on 'ready', () ->
console.log "RabbitMQ Connected"
self.pub = self.queue.socket('PUSH')
self.sub = self.queue.socket('WORKER', {prefetch: 1})
self.broker = Rx.Observable.fromEvent self.sub, "data"
self.queue.on 'error', (err) ->
console.log err
self
getBroker: () ->
@broker
addJob: (bip) ->
self = @
self.sub.connect 'bips', () ->
self.pub.connect 'bips', () ->
self.pub.write JSON.stringify(bip), 'utf8'
acknowledge: () ->
@sub.ack()
module.exports = Bastion

0 comments on commit bb12b11

Please sign in to comment.