Skip to content

Commit

Permalink
Lookup an arbitrary key over an admin endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jwolski committed May 20, 2015
1 parent 9d9bb20 commit 1ce4098
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/admin-lookup-recvr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) 2015 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
'use strict';

module.exports = function recvAdminLookup(opts, callback) {
callback(null, null, {
dest: opts.ringpop.lookup(opts.key)
});
};
9 changes: 9 additions & 0 deletions lib/tchannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

var recvAdminJoin = require('./admin-join-recvr.js');
var recvAdminLeave = require('./admin-leave-recvr.js');
var recvAdminLookup = require('./admin-lookup-recvr.js');
var recvJoin = require('./swim/join-recvr.js');
var recvPing = require('./swim/ping-recvr.js');
var recvPingReq = require('./swim/ping-req-recvr.js');
Expand All @@ -36,6 +37,7 @@ var commands = {
'/admin/debugClear': 'adminDebugClear',
'/admin/gossip': 'adminGossip',
'/admin/leave': 'adminLeave',
'/admin/lookup': 'adminLookup',
'/admin/join': 'adminJoin',
'/admin/reload': 'adminReload',
'/admin/tick': 'adminTick',
Expand Down Expand Up @@ -94,6 +96,13 @@ RingPopTChannel.prototype.adminLeave = function adminLeave(arg1, arg2, hostInfo,
}, cb);
};

RingPopTChannel.prototype.adminLookup = function adminLookup(arg1, arg2, hostInfo, cb) {
recvAdminLookup({
ringpop: this.ringpop,
key: arg2.toString()
}, cb);
};

RingPopTChannel.prototype.adminJoin = function (arg1, arg2, hostInfo, cb) {
var body = safeParse(arg2.toString()) || {};

Expand Down

0 comments on commit 1ce4098

Please sign in to comment.