mirror of https://github.com/grpc/grpc-node.git
Pass cancel and getPeer to underlying call
This commit is contained in:
parent
5bae250077
commit
6bfb5de337
|
|
@ -707,22 +707,22 @@ function _getUnaryInterceptor(method_definition, channel, emitter, callback) {
|
||||||
return function (options) {
|
return function (options) {
|
||||||
var call = common.getCall(channel, method_definition.path, options);
|
var call = common.getCall(channel, method_definition.path, options);
|
||||||
var first_listener;
|
var first_listener;
|
||||||
return new InterceptingCall(null, {
|
var final_requester = {};
|
||||||
start: function (metadata, listener) {
|
final_requester.start = function (metadata, listener) {
|
||||||
var batch = {
|
var batch = {
|
||||||
[grpc.opType.SEND_INITIAL_METADATA]:
|
[grpc.opType.SEND_INITIAL_METADATA]:
|
||||||
metadata._getCoreRepresentation(),
|
metadata._getCoreRepresentation(),
|
||||||
};
|
};
|
||||||
first_listener = listener;
|
first_listener = listener;
|
||||||
call.startBatch(batch, function () {});
|
call.startBatch(batch, function () { });
|
||||||
},
|
};
|
||||||
sendMessage: function(message) {
|
final_requester.sendMessage = function (message) {
|
||||||
var batch = {
|
var batch = {
|
||||||
[grpc.opType.SEND_MESSAGE]: serialize(message),
|
[grpc.opType.SEND_MESSAGE]: serialize(message),
|
||||||
};
|
};
|
||||||
call.startBatch(batch, function () {});
|
call.startBatch(batch, function () { });
|
||||||
},
|
};
|
||||||
halfClose: function() {
|
final_requester.halfClose = function () {
|
||||||
var batch = {
|
var batch = {
|
||||||
[grpc.opType.SEND_CLOSE_FROM_CLIENT]: true,
|
[grpc.opType.SEND_CLOSE_FROM_CLIENT]: true,
|
||||||
[grpc.opType.RECV_INITIAL_METADATA]: true,
|
[grpc.opType.RECV_INITIAL_METADATA]: true,
|
||||||
|
|
@ -758,8 +758,14 @@ function _getUnaryInterceptor(method_definition, channel, emitter, callback) {
|
||||||
first_listener.onReceiveMessage(deserialized);
|
first_listener.onReceiveMessage(deserialized);
|
||||||
first_listener.onReceiveStatus(status);
|
first_listener.onReceiveStatus(status);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
});
|
final_requester.cancel = function () {
|
||||||
|
call.cancel();
|
||||||
|
};
|
||||||
|
final_requester.getPeer = function () {
|
||||||
|
return call.getPeer();
|
||||||
|
};
|
||||||
|
return new InterceptingCall(null, final_requester);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -865,6 +871,12 @@ function _getClientStreamingInterceptor(method_definition, channel, emitter,
|
||||||
};
|
};
|
||||||
call.startBatch(batch, function () { });
|
call.startBatch(batch, function () { });
|
||||||
};
|
};
|
||||||
|
final_requester.cancel = function () {
|
||||||
|
call.cancel();
|
||||||
|
};
|
||||||
|
final_requester.getPeer = function() {
|
||||||
|
return call.getPeer();
|
||||||
|
};
|
||||||
return new InterceptingCall(null, final_requester);
|
return new InterceptingCall(null, final_requester);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -944,6 +956,12 @@ function _getServerStreamingInterceptor(method_definition, channel, emitter) {
|
||||||
call.startBatch(recv_batch, _getStreamReadCallback(emitter, call,
|
call.startBatch(recv_batch, _getStreamReadCallback(emitter, call,
|
||||||
first_listener, deserialize));
|
first_listener, deserialize));
|
||||||
};
|
};
|
||||||
|
final_requester.cancel = function() {
|
||||||
|
call.cancel();
|
||||||
|
};
|
||||||
|
final_requester.getPeer = function() {
|
||||||
|
return call.getPeer();
|
||||||
|
};
|
||||||
return new InterceptingCall(null, final_requester);
|
return new InterceptingCall(null, final_requester);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -1041,6 +1059,12 @@ function _getBidiStreamingInterceptor(method_definition, channel, emitter) {
|
||||||
call.startBatch(recv_batch, _getStreamReadCallback(emitter, call,
|
call.startBatch(recv_batch, _getStreamReadCallback(emitter, call,
|
||||||
first_listener, deserialize));
|
first_listener, deserialize));
|
||||||
};
|
};
|
||||||
|
final_requester.cancel = function() {
|
||||||
|
call.cancel();
|
||||||
|
};
|
||||||
|
final_requester.getPeer = function() {
|
||||||
|
return call.getPeer();
|
||||||
|
};
|
||||||
return new InterceptingCall(null, final_requester);
|
return new InterceptingCall(null, final_requester);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -289,6 +289,12 @@ exports.getCall = function(channel, path, options) {
|
||||||
* @param {function} next Calls the next interceptor.
|
* @param {function} next Calls the next interceptor.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function GetPeerRequester
|
||||||
|
* @param {function} next Calls the next interceptor.
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {object} grpc~Requester
|
* @typedef {object} grpc~Requester
|
||||||
* @param {MetadataRequester=} start A function triggered when the call begins.
|
* @param {MetadataRequester=} start A function triggered when the call begins.
|
||||||
|
|
@ -298,6 +304,8 @@ exports.getCall = function(channel, path, options) {
|
||||||
* closes the call.
|
* closes the call.
|
||||||
* @param {CancelRequester=} cancel A function triggered when the call is
|
* @param {CancelRequester=} cancel A function triggered when the call is
|
||||||
* cancelled.
|
* cancelled.
|
||||||
|
* @param {GetPeerRequester=} getPeer A function triggered when the endpoint is
|
||||||
|
* requested.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue