mirror of https://github.com/grpc/grpc-node.git
Add checker for call invocation transformer.
This commit is contained in:
parent
1b11238d38
commit
cd6e2062c8
|
@ -480,22 +480,51 @@ Client.prototype.makeUnaryRequest = function(path, serialize, deserialize,
|
||||||
|
|
||||||
metadata = metadata.clone();
|
metadata = metadata.clone();
|
||||||
|
|
||||||
var intercepting_call = client_interceptors.getInterceptingCall(
|
var callProperties = {
|
||||||
method_definition,
|
argument: argument,
|
||||||
options,
|
metadata: metadata,
|
||||||
Client.prototype.resolveCallInterceptors.call(this, method_definition, options.interceptors, options.interceptor_providers),
|
call: new ClientUnaryCall(),
|
||||||
this.$channel,
|
channel: this.$channel,
|
||||||
callback
|
methodDefinition: method_definition,
|
||||||
);
|
callOptions: options,
|
||||||
var emitter = new ClientUnaryCall(intercepting_call);
|
callback: callback
|
||||||
var last_listener = client_interceptors.getLastListener(
|
};
|
||||||
method_definition,
|
|
||||||
emitter,
|
// Transform call properties if specified.
|
||||||
callback
|
var callInvocationTransformer = options.callInvocationTransformer;
|
||||||
|
if (callInvocationTransformer) {
|
||||||
|
callProperties = callInvocationTransformer(callProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
var callOptions = callProperties.callOptions;
|
||||||
|
var methodDefinition = callProperties.methodDefinition;
|
||||||
|
|
||||||
|
var interceptors = Client.prototype.resolveCallInterceptors.call(
|
||||||
|
this,
|
||||||
|
methodDefinition,
|
||||||
|
callOptions.interceptors,
|
||||||
|
callOptions.interceptor_providers
|
||||||
);
|
);
|
||||||
|
|
||||||
intercepting_call.start(metadata, last_listener);
|
var intercepting_call = client_interceptors.getInterceptingCall(
|
||||||
intercepting_call.sendMessage(argument);
|
methodDefinition,
|
||||||
|
callOptions,
|
||||||
|
interceptors,
|
||||||
|
callProperties.channel,
|
||||||
|
callProperties.callback
|
||||||
|
);
|
||||||
|
|
||||||
|
var emitter = callProperties.call;
|
||||||
|
emitter.call = intercepting_call;
|
||||||
|
|
||||||
|
var last_listener = client_interceptors.getLastListener(
|
||||||
|
methodDefinition,
|
||||||
|
emitter,
|
||||||
|
callProperties.callback
|
||||||
|
);
|
||||||
|
|
||||||
|
intercepting_call.start(callProperties.metadata, last_listener);
|
||||||
|
intercepting_call.sendMessage(callProperties.argument);
|
||||||
intercepting_call.halfClose();
|
intercepting_call.halfClose();
|
||||||
|
|
||||||
return emitter;
|
return emitter;
|
||||||
|
@ -555,21 +584,49 @@ Client.prototype.makeClientStreamRequest = function(path, serialize,
|
||||||
|
|
||||||
metadata = metadata.clone();
|
metadata = metadata.clone();
|
||||||
|
|
||||||
var intercepting_call = client_interceptors.getInterceptingCall(
|
var callProperties = {
|
||||||
method_definition,
|
metadata: metadata,
|
||||||
options,
|
call: new ClientWritableStream(),
|
||||||
Client.prototype.resolveCallInterceptors.call(this, method_definition, options.interceptors, options.interceptor_providers),
|
channel: this.$channel,
|
||||||
this.$channel,
|
methodDefinition: method_definition,
|
||||||
callback
|
callOptions: options,
|
||||||
);
|
callback: callback
|
||||||
var emitter = new ClientWritableStream(intercepting_call);
|
};
|
||||||
var last_listener = client_interceptors.getLastListener(
|
|
||||||
method_definition,
|
// Transform call properties if specified.
|
||||||
emitter,
|
var callInvocationTransformer = options.callInvocationTransformer;
|
||||||
callback
|
if (callInvocationTransformer) {
|
||||||
|
callProperties = callInvocationTransformer(callProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
var callOptions = callProperties.callOptions;
|
||||||
|
var methodDefinition = callProperties.methodDefinition;
|
||||||
|
|
||||||
|
var interceptors = Client.prototype.resolveCallInterceptors.call(
|
||||||
|
this,
|
||||||
|
methodDefinition,
|
||||||
|
callOptions.interceptors,
|
||||||
|
callOptions.interceptor_providers
|
||||||
);
|
);
|
||||||
|
|
||||||
intercepting_call.start(metadata, last_listener);
|
var intercepting_call = client_interceptors.getInterceptingCall(
|
||||||
|
methodDefinition,
|
||||||
|
callOptions,
|
||||||
|
interceptors,
|
||||||
|
callProperties.channel,
|
||||||
|
callProperties.callback
|
||||||
|
);
|
||||||
|
|
||||||
|
var emitter = callProperties.call;
|
||||||
|
emitter.call = intercepting_call;
|
||||||
|
|
||||||
|
var last_listener = client_interceptors.getLastListener(
|
||||||
|
methodDefinition,
|
||||||
|
emitter,
|
||||||
|
callProperties.callback
|
||||||
|
);
|
||||||
|
|
||||||
|
intercepting_call.start(callProperties.metadata, last_listener);
|
||||||
|
|
||||||
return emitter;
|
return emitter;
|
||||||
};
|
};
|
||||||
|
@ -613,22 +670,47 @@ Client.prototype.makeServerStreamRequest = function(path, serialize,
|
||||||
|
|
||||||
metadata = metadata.clone();
|
metadata = metadata.clone();
|
||||||
|
|
||||||
var emitter = new ClientReadableStream();
|
var callProperties = {
|
||||||
|
argument: argument,
|
||||||
|
metadata: metadata,
|
||||||
|
call: new ClientReadableStream(),
|
||||||
|
channel: this.$channel,
|
||||||
|
methodDefinition: method_definition,
|
||||||
|
callOptions: options,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Transform call properties if specified.
|
||||||
|
var callInvocationTransformer = options.callInvocationTransformer;
|
||||||
|
if (callInvocationTransformer) {
|
||||||
|
callProperties = callInvocationTransformer(callProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
var callOptions = callProperties.callOptions;
|
||||||
|
var methodDefinition = callProperties.methodDefinition;
|
||||||
|
|
||||||
|
var interceptors = Client.prototype.resolveCallInterceptors.call(
|
||||||
|
this,
|
||||||
|
methodDefinition,
|
||||||
|
callOptions.interceptors,
|
||||||
|
callOptions.interceptor_providers
|
||||||
|
);
|
||||||
|
|
||||||
|
var emitter = callProperties.call;
|
||||||
var intercepting_call = client_interceptors.getInterceptingCall(
|
var intercepting_call = client_interceptors.getInterceptingCall(
|
||||||
method_definition,
|
methodDefinition,
|
||||||
options,
|
callOptions,
|
||||||
Client.prototype.resolveCallInterceptors.call(this, method_definition, options.interceptors, options.interceptor_providers),
|
interceptors,
|
||||||
this.$channel,
|
callProperties.channel,
|
||||||
emitter
|
emitter
|
||||||
);
|
);
|
||||||
emitter.call = intercepting_call;
|
emitter.call = intercepting_call;
|
||||||
var last_listener = client_interceptors.getLastListener(
|
var last_listener = client_interceptors.getLastListener(
|
||||||
method_definition,
|
methodDefinition,
|
||||||
emitter
|
emitter
|
||||||
);
|
);
|
||||||
|
|
||||||
intercepting_call.start(metadata, last_listener);
|
intercepting_call.start(callProperties.metadata, last_listener);
|
||||||
intercepting_call.sendMessage(argument);
|
intercepting_call.sendMessage(callProperties.argument);
|
||||||
intercepting_call.halfClose();
|
intercepting_call.halfClose();
|
||||||
|
|
||||||
return emitter;
|
return emitter;
|
||||||
|
@ -669,21 +751,46 @@ Client.prototype.makeBidiStreamRequest = function(path, serialize,
|
||||||
|
|
||||||
metadata = metadata.clone();
|
metadata = metadata.clone();
|
||||||
|
|
||||||
var emitter = new ClientDuplexStream();
|
var callProperties = {
|
||||||
|
metadata: metadata,
|
||||||
|
call: new ClientDuplexStream(),
|
||||||
|
channel: this.$channel,
|
||||||
|
methodDefinition: method_definition,
|
||||||
|
callOptions: options,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Transform call properties if specified.
|
||||||
|
var callInvocationTransformer = options.callInvocationTransformer;
|
||||||
|
if (callInvocationTransformer) {
|
||||||
|
callProperties = callInvocationTransformer(callProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
var callOptions = callProperties.callOptions;
|
||||||
|
var methodDefinition = callProperties.methodDefinition;
|
||||||
|
|
||||||
|
var interceptors = Client.prototype.resolveCallInterceptors.call(
|
||||||
|
this,
|
||||||
|
methodDefinition,
|
||||||
|
callOptions.interceptors,
|
||||||
|
callOptions.interceptor_providers
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
var emitter = callProperties.call;
|
||||||
var intercepting_call = client_interceptors.getInterceptingCall(
|
var intercepting_call = client_interceptors.getInterceptingCall(
|
||||||
method_definition,
|
methodDefinition,
|
||||||
options,
|
callOptions,
|
||||||
Client.prototype.resolveCallInterceptors.call(this, method_definition, options.interceptors, options.interceptor_providers),
|
interceptors,
|
||||||
this.$channel,
|
callProperties.channel,
|
||||||
emitter
|
emitter
|
||||||
);
|
);
|
||||||
emitter.call = intercepting_call;
|
emitter.call = intercepting_call;
|
||||||
var last_listener = client_interceptors.getLastListener(
|
var last_listener = client_interceptors.getLastListener(
|
||||||
method_definition,
|
methodDefinition,
|
||||||
emitter
|
emitter
|
||||||
);
|
);
|
||||||
|
|
||||||
intercepting_call.start(metadata, last_listener);
|
intercepting_call.start(callProperties.metadata, last_listener);
|
||||||
|
|
||||||
return emitter;
|
return emitter;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue