-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BIP-545 BIP-538 smarter install script and oauth, bastion working
- Loading branch information
Alfonso Gober
committed
Jun 16, 2015
1 parent
ab9cb5c
commit bb12b11
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |