Skip to content

Commit

Permalink
Measure lookup() times
Browse files Browse the repository at this point in the history
  • Loading branch information
jwolski committed Apr 17, 2015
1 parent 9a9176d commit 16c7961
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ All other properties should be considered private. Any mutation of properties no
**Events**
* `ready` - ringpop has been bootstrapped
* `changed` - ring or membership state is changed (DEPRECATED)
* `lookup` - A key has been looked up. A single argument is provided to the listener which takes the shape: `{ timing: Number }`
* `membershipChanged` - membership state has changed (status or incarnation number). A membership change may result in a ring change.
* `requestProxy.checksumsDiffer` - a proxied request arrives at its destination and source/destination checksums differ
* `requestProxy.requestProxied` - a request is sent over the proxy channel
Expand Down
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,14 @@ RingPop.prototype.protocolPing = function protocolPing(options, callback) {
};

RingPop.prototype.lookup = function lookup(key) {
this.stat('increment', 'lookup');
var startTime = Date.now();

var dest = this.ring.lookup(key + '');

this.emit('lookup', {
timing: Date.now() - startTime
});

if (!dest) {
this.logger.debug('could not find destination for a key', {
key: key
Expand Down

0 comments on commit 16c7961

Please sign in to comment.