Skip to content

Instantly share code, notes, and snippets.

@hub-cap
Created June 18, 2014 17:11
Show Gist options
  • Save hub-cap/56230467aebdfb9c7c2f to your computer and use it in GitHub Desktop.
Save hub-cap/56230467aebdfb9c7c2f to your computer and use it in GitHub Desktop.
util.inherits(LBClient, events.EventEmitter);
function LBClient() {
events.EventEmitter.call(this);
this.on('newLoadBalancer', this._scheduleLoadBalancer);
this.on('loadBalancerScheduled', this._saveChildLoadBalancer);
this.on('loadBalancerSaved', this._provisionChildLoadBalancer);
this.on('loadBalancerProvisioned', this._updateChildLoadBalancer);
}
LBClient.prototype.createLoadBalancerWithNode = function (privateIP,
privatePort,
instanceUUID,
datastoreType) {
var childLB = { privateIP: privateIP, privatePort: privatePort,
instanceUUID: instanceUUID, datastoreType: datastoreType,
}
this.emit('newLoadBalancer', childLB);
}
LBClient.prototype._scheduleLoadBalancer = function (childLB) {
//
var parentLB = { id:'1', virtualIP:'2' };
this.emit('loadBalancerScheduled', childLB, parentLB);
}
LBClient.prototype._saveChildLoadBalancer = function (childLB, parentLB) {
childLB.id = '99';
this.emit('loadBalancerSaved', childLB, parentLB);
}
LBClient.prototype._provisionChildLoadBalancer = function(childLB, parentLB) {
var remoteLB = {some: 'stuff'}
this.emit('loadBalancerProvisioned', childLB, parentLB, remoteLB);
}
LBClient.prototype._updateChildLoadBalancer = function (childLb,
parentLB,
remoteLB) {
this.emit('loadBalancerFinished', 'success');
}
module.exports.LBClient = LBClient
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment