Skip to content

Commit

Permalink
Camel case aliases, config as object as well as string
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalopitz committed Feb 26, 2013
1 parent 4770b94 commit 27a56c2
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions lib/beanstalk_client.js
Expand Up @@ -98,15 +98,18 @@ function BeanstalkClient() {
util.inherits(BeanstalkClient, events.EventEmitter);

// Singleton like method that returns an instance
BeanstalkClient.prototype.Instance = function(server) {
var p = [];

if(server) {
p = server.split(':');
BeanstalkClient.prototype.Instance = function(config) {
if (config) {
if (typeof config == 'string') {
var c = config.split(':');
this.address = c[0] || this.address;
this.port = c[1] || this.port;
} else {
this.address = config.address || this.address;
this.port = config.port || this.port;
}
}

this.address = (p[0]) ? p[0] : this.address;
this.port = (p[1]) ? p[1] : this.port;
return this;
};

Expand Down Expand Up @@ -257,6 +260,8 @@ BeanstalkClient.prototype.reserve_with_timeout = function(time) {
expected: 'RESERVED'
});
};
// camel case alias
BeanstalkClient.prototype.reserveWithTimeout = BeanstalkClient.prototype.reserve_with_timeout;

// ###touch
// tell the server that you're still working on a job
Expand Down Expand Up @@ -334,6 +339,8 @@ BeanstalkClient.prototype.peek_ready = function() {
expected: 'FOUND'
});
};
// camel case alias
BeanstalkClient.prototype.peekReady = BeanstalkClient.prototype.peek_ready;

// ###peek-delayed
// let's you inspect the next delayed job
Expand All @@ -343,6 +350,8 @@ BeanstalkClient.prototype.peek_delayed = function() {
expected: 'FOUND'
});
};
// camel case alias
BeanstalkClient.prototype.peekDelayed = BeanstalkClient.prototype.peek_delayed;

// ###peek-buried
// let's you inspect the next buried job
Expand All @@ -352,6 +361,8 @@ BeanstalkClient.prototype.peek_buried = function() {
expected: 'FOUND'
});
};
// camel case alias
BeanstalkClient.prototype.peekBuried = BeanstalkClient.prototype.peek_buried;

// ###stats
// gives statistical information about the server
Expand All @@ -372,6 +383,8 @@ BeanstalkClient.prototype.stats_job = function(id) {
is_yaml: 1
});
};
// camel case alias
BeanstalkClient.prototype.statsJob = BeanstalkClient.prototype.stats_job;

// ###stats-tube
// gives statistical information about the specified tube if it exists
Expand All @@ -382,6 +395,8 @@ BeanstalkClient.prototype.stats_tube = function(tube) {
is_yaml: 1
});
};
// camel case alias
BeanstalkClient.prototype.statsTube = BeanstalkClient.prototype.stats_tube;

// ###list-tubes
// lists all existing tubes
Expand All @@ -392,6 +407,8 @@ BeanstalkClient.prototype.list_tubes = function() {
is_yaml: 1
});
};
// camel case alias
BeanstalkClient.prototype.listTubes = BeanstalkClient.prototype.list_tubes;

// ###list-tubes-watched
// lists all existing tubes that are currently watched
Expand All @@ -402,6 +419,8 @@ BeanstalkClient.prototype.list_tubes_watched = function() {
is_yaml: 1
});
};
// camel case alias
BeanstalkClient.prototype.listTubesWatched = BeanstalkClient.prototype.list_tubes_watched;

// ###list-tube-used
// returns the tube currently being used by the client
Expand All @@ -411,6 +430,8 @@ BeanstalkClient.prototype.list_tube_used = function() {
expected: 'USING'
});
};
// camel case alias
BeanstalkClient.prototype.listTubeUsed = BeanstalkClient.prototype.list_tube_used;

// ###pause-tube
// can delay any new job being reserved for a given time
Expand All @@ -420,6 +441,8 @@ BeanstalkClient.prototype.pause_tube = function(tube, delay) {
expected: 'PAUSED'
});
};
// camel case alias
BeanstalkClient.prototype.pauseTube = BeanstalkClient.prototype.pause_tube;

// ###quit
// closes connection
Expand Down

0 comments on commit 27a56c2

Please sign in to comment.