Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Commit

Permalink
Pass the entire optional parameters to createStub (#1050)
Browse files Browse the repository at this point in the history
To allow additional grpc parameters for constructing Client.
Fix googleapis/gax-nodejs#107
  • Loading branch information
jmuk authored Feb 22, 2017
1 parent caf63b7 commit 3e4574e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 66 deletions.
25 changes: 8 additions & 17 deletions src/main/resources/com/google/api/codegen/nodejs/main.snip
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
var defaults = gaxGrpc.constructSettings(
'{@service.getFullName}',
configData,
clientConfig,
opts.clientConfig,
{'x-goog-api-client': googleApiClient.join(' ')});
@end
@end
Expand Down Expand Up @@ -235,11 +235,11 @@
* @@class
*/
function {@serviceName}(gaxGrpc, grpcClients, opts) {
opts = opts || {};
var servicePath = opts.servicePath || SERVICE_ADDRESS;
var port = opts.port || DEFAULT_SERVICE_PORT;
var sslCreds = opts.sslCreds || null;
var clientConfig = opts.clientConfig || {};
opts = extend({
servicePath: SERVICE_ADDRESS,
port: DEFAULT_SERVICE_PORT,
clientConfig: {}
}, opts);

var googleApiClient = [
'gl-node/' + process.versions.node,
Expand Down Expand Up @@ -283,14 +283,7 @@
this.operationsClient = new gax.lro({
auth: gaxGrpc.auth,
grpc: gaxGrpc.grpc
}).operationsClient({
servicePath: servicePath,
port: port,
sslCreds: sslCreds,
clientConfig: clientConfig,
libName: opts.libName,
libVersion: opts.libVersion
});
}).operationsClient(opts);

this.longrunningDescriptors = {
@join method : longrunningMethods on {@", "}.add(BREAK)
Expand All @@ -312,10 +305,8 @@
this.auth = gaxGrpc.auth;
@join stub : stubs on BREAK.add(BREAK)
var {@stub.name} = gaxGrpc.createStub(
servicePath,
port,
grpcClients.{@stub.fullyQualifiedType},
{sslCreds: sslCreds});
opts);
var {@stub.stubMethodsArrayName} = [
@join method : {@stub.methodNames} on {@","}.add(BREAK)
'{@method}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ var ALL_SCOPES = [
* @class
*/
function LibraryServiceClient(gaxGrpc, grpcClients, opts) {
opts = opts || {};
var servicePath = opts.servicePath || SERVICE_ADDRESS;
var port = opts.port || DEFAULT_SERVICE_PORT;
var sslCreds = opts.sslCreds || null;
var clientConfig = opts.clientConfig || {};
opts = extend({
servicePath: SERVICE_ADDRESS,
port: DEFAULT_SERVICE_PORT,
clientConfig: {}
}, opts);

var googleApiClient = [
'gl-node/' + process.versions.node,
Expand Down Expand Up @@ -135,14 +135,7 @@ function LibraryServiceClient(gaxGrpc, grpcClients, opts) {
this.operationsClient = new gax.lro({
auth: gaxGrpc.auth,
grpc: gaxGrpc.grpc
}).operationsClient({
servicePath: servicePath,
port: port,
sslCreds: sslCreds,
clientConfig: clientConfig,
libName: opts.libName,
libVersion: opts.libVersion
});
}).operationsClient(opts);

this.longrunningDescriptors = {
getBigBook: new gax.LongrunningDescriptor(
Expand All @@ -158,17 +151,15 @@ function LibraryServiceClient(gaxGrpc, grpcClients, opts) {
var defaults = gaxGrpc.constructSettings(
'google.example.library.v1.LibraryService',
configData,
clientConfig,
opts.clientConfig,
{'x-goog-api-client': googleApiClient.join(' ')});

var self = this;

this.auth = gaxGrpc.auth;
var libraryServiceStub = gaxGrpc.createStub(
servicePath,
port,
grpcClients.google.example.library.v1.LibraryService,
{sslCreds: sslCreds});
opts);
var libraryServiceStubMethods = [
'createShelf',
'getShelf',
Expand Down Expand Up @@ -209,10 +200,8 @@ function LibraryServiceClient(gaxGrpc, grpcClients, opts) {
});

var labelerStub = gaxGrpc.createStub(
servicePath,
port,
grpcClients.google.tagger.v1.Labeler,
{sslCreds: sslCreds});
opts);
var labelerStubMethods = [
'addLabel'
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ var ALL_SCOPES = [
* @class
*/
function LibraryServiceClient(gaxGrpc, grpcClients, opts) {
opts = opts || {};
var servicePath = opts.servicePath || SERVICE_ADDRESS;
var port = opts.port || DEFAULT_SERVICE_PORT;
var sslCreds = opts.sslCreds || null;
var clientConfig = opts.clientConfig || {};
opts = extend({
servicePath: SERVICE_ADDRESS,
port: DEFAULT_SERVICE_PORT,
clientConfig: {}
}, opts);

var googleApiClient = [
'gl-node/' + process.versions.node,
Expand Down Expand Up @@ -135,14 +135,7 @@ function LibraryServiceClient(gaxGrpc, grpcClients, opts) {
this.operationsClient = new gax.lro({
auth: gaxGrpc.auth,
grpc: gaxGrpc.grpc
}).operationsClient({
servicePath: servicePath,
port: port,
sslCreds: sslCreds,
clientConfig: clientConfig,
libName: opts.libName,
libVersion: opts.libVersion
});
}).operationsClient(opts);

this.longrunningDescriptors = {
getBigBook: new gax.LongrunningDescriptor(
Expand All @@ -158,17 +151,15 @@ function LibraryServiceClient(gaxGrpc, grpcClients, opts) {
var defaults = gaxGrpc.constructSettings(
'google.example.library.v1.LibraryService',
configData,
clientConfig,
opts.clientConfig,
{'x-goog-api-client': googleApiClient.join(' ')});

var self = this;

this.auth = gaxGrpc.auth;
var libraryServiceStub = gaxGrpc.createStub(
servicePath,
port,
grpcClients.google.example.library.v1.LibraryService,
{sslCreds: sslCreds});
opts);
var libraryServiceStubMethods = [
'createShelf',
'getShelf',
Expand Down Expand Up @@ -209,10 +200,8 @@ function LibraryServiceClient(gaxGrpc, grpcClients, opts) {
});

var labelerStub = gaxGrpc.createStub(
servicePath,
port,
grpcClients.google.tagger.v1.Labeler,
{sslCreds: sslCreds});
opts);
var labelerStubMethods = [
'addLabel'
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ var ALL_SCOPES = [
* @class
*/
function NoTemplatesAPIServiceClient(gaxGrpc, grpcClients, opts) {
opts = opts || {};
var servicePath = opts.servicePath || SERVICE_ADDRESS;
var port = opts.port || DEFAULT_SERVICE_PORT;
var sslCreds = opts.sslCreds || null;
var clientConfig = opts.clientConfig || {};
opts = extend({
servicePath: SERVICE_ADDRESS,
port: DEFAULT_SERVICE_PORT,
clientConfig: {}
}, opts);

var googleApiClient = [
'gl-node/' + process.versions.node,
Expand All @@ -80,17 +80,15 @@ function NoTemplatesAPIServiceClient(gaxGrpc, grpcClients, opts) {
var defaults = gaxGrpc.constructSettings(
'google.cloud.example.v1.NoTemplatesAPIService',
configData,
clientConfig,
opts.clientConfig,
{'x-goog-api-client': googleApiClient.join(' ')});

var self = this;

this.auth = gaxGrpc.auth;
var noTemplatesApiServiceStub = gaxGrpc.createStub(
servicePath,
port,
grpcClients.google.cloud.example.v1.NoTemplatesAPIService,
{sslCreds: sslCreds});
opts);
var noTemplatesApiServiceStubMethods = [
'increment'
];
Expand Down

0 comments on commit 3e4574e

Please sign in to comment.