From f5294f7258a3222d114c7a23d993a84ba2e42d9b Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Tue, 20 Aug 2019 10:11:49 -0700 Subject: [PATCH] Upmerge 1.22 into 1.23 --- packages/grpc-native-core/build.yaml | 2 +- packages/grpc-native-core/index.d.ts | 6 ++- packages/grpc-native-core/index.js | 4 +- packages/grpc-native-core/package.json | 2 + packages/grpc-native-core/src/client.js | 50 ++++++++++++++++++- packages/grpc-native-core/src/server.js | 3 +- .../templates/package.json.template | 2 + 7 files changed, 63 insertions(+), 6 deletions(-) diff --git a/packages/grpc-native-core/build.yaml b/packages/grpc-native-core/build.yaml index fa21241b..ce12f437 100644 --- a/packages/grpc-native-core/build.yaml +++ b/packages/grpc-native-core/build.yaml @@ -1,3 +1,3 @@ settings: '#': It's possible to have node_version here as a key to override the core's version. - node_version: 1.23.1 \ No newline at end of file + node_version: 1.23.1 diff --git a/packages/grpc-native-core/index.d.ts b/packages/grpc-native-core/index.d.ts index c7dab49d..f36b6e86 100644 --- a/packages/grpc-native-core/index.d.ts +++ b/packages/grpc-native-core/index.d.ts @@ -1,3 +1,5 @@ +import { EventEmitter } from "events"; + /* * Copyright 2019 gRPC authors. * @@ -341,7 +343,7 @@ declare module "grpc" { /** * An EventEmitter. Used for unary calls. */ - export class ServerUnaryCall { + export class ServerUnaryCall extends EventEmitter { /** * Indicates if the call has been cancelled */ @@ -1231,7 +1233,7 @@ declare module "grpc" { /** * An EventEmitter. Used for unary calls. */ - export class ClientUnaryCall { + export class ClientUnaryCall extends EventEmitter { private constructor(); /** diff --git a/packages/grpc-native-core/index.js b/packages/grpc-native-core/index.js index 9134667a..9534c7d4 100644 --- a/packages/grpc-native-core/index.js +++ b/packages/grpc-native-core/index.js @@ -312,7 +312,9 @@ exports.Client = client.Client; * @memberof grpc * @param {string} target The address of the server to connect to * @param {grpc.ChannelCredentials} credentials Channel credentials to use when connecting - * @param {grpc~ChannelOptions} options A map of channel options that will be passed to the core + * @param {grpc~ChannelOptions} options A map of channel options that will be passed to the core. + * The available options are listed in + * [this document]{@link https://grpc.github.io/grpc/core/group__grpc__arg__keys.html}. */ exports.Channel = grpc.Channel; diff --git a/packages/grpc-native-core/package.json b/packages/grpc-native-core/package.json index 816b2678..9edc2d96 100644 --- a/packages/grpc-native-core/package.json +++ b/packages/grpc-native-core/package.json @@ -75,6 +75,8 @@ "deps/grpc/third_party/nanopb/*.{c,cc,h}", "deps/grpc/third_party/upb/**/*.{c,h}", "deps/grpc/third_party/zlib/**/*.{c,cc,h}", + "deps/grpc/third_party/address_sorting/**/*.{c,h}", + "deps/grpc/third_party/cares/**/*.{c,h}", "binding.gyp" ], "main": "index.js", diff --git a/packages/grpc-native-core/src/client.js b/packages/grpc-native-core/src/client.js index 256f8d1c..faba6dec 100644 --- a/packages/grpc-native-core/src/client.js +++ b/packages/grpc-native-core/src/client.js @@ -353,6 +353,42 @@ ClientDuplexStream.prototype.getPeer = getPeer; * should be used to make this particular call. */ +/** + * Properties of a call, for use with a {@link grpc.Client~callInvocationTransformer}. + * @typedef {Object} grpc.Client~CallProperties + * @property {*} argument The call argument. Only preset if the method is unary or server streaming. + * @property {grpc.Metadata} metadata The request metadata + * @property {grpc~Call} call The call object that will be returned by the client method + * @property {grpc.Channel} channel The channel that will be used to make a request + * @property {grpc~MethodDefinition} methodDefinition The MethodDefinition object that describes this method + * @property {grpc.Client~CallOptions} options The call options passed when making this request + * @property {grpc.Client~requestCallback} callback The callback that will handle the response. + * Only present if this method is unary or client streaming. + */ + +/** + * Call invocation transformer. Has access to the full call properties before a + * call is processed and can modify most of those properties. Some modifications + * will have no effect or may cause problems. + * @name grpc.Client~callInvocationTransformer + * @function + * @param {grpc.Client~CallProperties} callProperties The original call properties + * @return {grpc.Client~CallProperties} The modified call properties. + */ + +/** + * A function that functionally replaces the Channel constructor. + * @name grpc.Client~channelFactory + * @function + * @param {string} target The address of the server to connect to + * @param {grpc.ChannelCredentials} credentials Channel credentials to use when connecting + * @param {grpc~ChannelOptions} options A map of channel options that will be passed to the core. + * The available options are listed in + * [this document]{@link https://grpc.github.io/grpc/core/group__grpc__arg__keys.html}. + * @returns {grpc.Channel} This can either be an actual channel object, or an object with the + * same API. + */ + /** * A generic gRPC client. Primarily useful as a base class for generated clients * @memberof grpc @@ -360,7 +396,19 @@ ClientDuplexStream.prototype.getPeer = getPeer; * @param {string} address Server address to connect to * @param {grpc.credentials~ChannelCredentials} credentials Credentials to use * to connect to the server - * @param {Object} options Options to apply to channel creation + * @param {Object} options Options to apply to channel creation. Any of + * [the channel arguments]{@link https://grpc.github.io/grpc/core/group__grpc__arg__keys.html} + * can be used here in addition to specific client options. + * @param {grpc~Interceptor[]} [options.interceptors] Interceptors to apply to each request + * @param {grpc~InterceptorProvider[]} [options.interceptor_providers] Interceptor providers + * to apply interceptors to each request depending on the method definition. At most + * one of the interceptors and interceptor_providers options may be set. + * @param {grpc.Client~callInvocationTransformer=} options.callInvocationTransformer + * @param {grpc.Channel=} options.channelOverride Channel to use instead of constructing a new one. + * If set, the address, credentials, channel arguments options, and channelFactoryOverride + * option will all be ignored. + * @param {grpc.Client~channelFactory} options.channelFactoryOverride Function to use instead of + * the Channel constructor when creating the Client's channel. */ function Client(address, credentials, options) { var self = this; diff --git a/packages/grpc-native-core/src/server.js b/packages/grpc-native-core/src/server.js index b79ee6fc..f6ce0699 100644 --- a/packages/grpc-native-core/src/server.js +++ b/packages/grpc-native-core/src/server.js @@ -719,7 +719,8 @@ var streamHandlers = { * @memberof grpc * @constructor * @param {Object=} options Options that should be passed to the internal server - * implementation + * implementation. The available options are listed in + * [this document]{@link https://grpc.github.io/grpc/core/group__grpc__arg__keys.html}. * @example * var server = new grpc.Server(); * server.addProtoService(protobuf_service_descriptor, service_implementation); diff --git a/packages/grpc-native-core/templates/package.json.template b/packages/grpc-native-core/templates/package.json.template index 080567c5..db054aa4 100644 --- a/packages/grpc-native-core/templates/package.json.template +++ b/packages/grpc-native-core/templates/package.json.template @@ -77,6 +77,8 @@ "deps/grpc/third_party/nanopb/*.{c,cc,h}", "deps/grpc/third_party/upb/**/*.{c,h}", "deps/grpc/third_party/zlib/**/*.{c,cc,h}", + "deps/grpc/third_party/address_sorting/**/*.{c,h}", + "deps/grpc/third_party/cares/**/*.{c,h}", "binding.gyp" ], "main": "index.js",