@google-cloud/pubsub 4.11.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +2 -2
  3. package/build/protos/protos.d.ts +6 -6
  4. package/build/protos/protos.js +423 -141
  5. package/build/protos/protos.json +39 -18
  6. package/build/src/debug.js +2 -0
  7. package/build/src/debug.js.map +1 -1
  8. package/build/src/default-options.d.ts +2 -2
  9. package/build/src/default-options.js +3 -3
  10. package/build/src/default-options.js.map +1 -1
  11. package/build/src/exponential-retry.js +4 -1
  12. package/build/src/exponential-retry.js.map +1 -1
  13. package/build/src/histogram.js +3 -0
  14. package/build/src/histogram.js.map +1 -1
  15. package/build/src/iam.js +3 -0
  16. package/build/src/iam.js.map +1 -1
  17. package/build/src/index.d.ts +0 -2
  18. package/build/src/index.js +1 -5
  19. package/build/src/index.js.map +1 -1
  20. package/build/src/lease-manager.d.ts +0 -3
  21. package/build/src/lease-manager.js +14 -19
  22. package/build/src/lease-manager.js.map +1 -1
  23. package/build/src/message-queues.js +31 -23
  24. package/build/src/message-queues.js.map +1 -1
  25. package/build/src/message-stream.js +13 -4
  26. package/build/src/message-stream.js.map +1 -1
  27. package/build/src/publisher/flow-control.js +4 -1
  28. package/build/src/publisher/flow-control.js.map +1 -1
  29. package/build/src/publisher/flow-publisher.js +5 -2
  30. package/build/src/publisher/flow-publisher.js.map +1 -1
  31. package/build/src/publisher/index.d.ts +0 -2
  32. package/build/src/publisher/index.js +9 -6
  33. package/build/src/publisher/index.js.map +1 -1
  34. package/build/src/publisher/message-batch.d.ts +0 -11
  35. package/build/src/publisher/message-batch.js +13 -1
  36. package/build/src/publisher/message-batch.js.map +1 -1
  37. package/build/src/publisher/message-queues.js +10 -3
  38. package/build/src/publisher/message-queues.js.map +1 -1
  39. package/build/src/publisher/publish-error.js +5 -0
  40. package/build/src/publisher/publish-error.js.map +1 -1
  41. package/build/src/publisher/pubsub-message.d.ts +0 -68
  42. package/build/src/pubsub.js +14 -5
  43. package/build/src/pubsub.js.map +1 -1
  44. package/build/src/schema.js +3 -0
  45. package/build/src/schema.js.map +1 -1
  46. package/build/src/snapshot.js +3 -0
  47. package/build/src/snapshot.js.map +1 -1
  48. package/build/src/subscriber.d.ts +11 -15
  49. package/build/src/subscriber.js +84 -26
  50. package/build/src/subscriber.js.map +1 -1
  51. package/build/src/subscription.js +11 -2
  52. package/build/src/subscription.js.map +1 -1
  53. package/build/src/telemetry-tracing.d.ts +2 -220
  54. package/build/src/telemetry-tracing.js +36 -112
  55. package/build/src/telemetry-tracing.js.map +1 -1
  56. package/build/src/temporal.js +8 -8
  57. package/build/src/temporal.js.map +1 -1
  58. package/build/src/topic.js +8 -1
  59. package/build/src/topic.js.map +1 -1
  60. package/build/src/util.js +3 -2
  61. package/build/src/util.js.map +1 -1
  62. package/build/src/v1/publisher_client.d.ts +26 -4
  63. package/build/src/v1/publisher_client.js +232 -90
  64. package/build/src/v1/publisher_client.js.map +1 -1
  65. package/build/src/v1/publisher_proto_list.json +4 -0
  66. package/build/src/v1/schema_service_client.d.ts +24 -3
  67. package/build/src/v1/schema_service_client.js +235 -75
  68. package/build/src/v1/schema_service_client.js.map +1 -1
  69. package/build/src/v1/schema_service_proto_list.json +4 -0
  70. package/build/src/v1/subscriber_client.d.ts +39 -3
  71. package/build/src/v1/subscriber_client.js +327 -97
  72. package/build/src/v1/subscriber_client.js.map +1 -1
  73. package/build/src/v1/subscriber_proto_list.json +4 -0
  74. package/package.json +43 -45
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.SubscriberClient = void 0;
21
21
  const stream_1 = require("stream");
22
22
  const jsonProtos = require("../../protos/protos.json");
23
+ const google_gax_1 = require("google-gax");
23
24
  /**
24
25
  * Client JSON configuration object, loaded from
25
26
  * `src/v1/subscriber_client_config.json`.
@@ -35,6 +36,28 @@ const version = require('../../../package.json').version;
35
36
  * @memberof v1
36
37
  */
37
38
  class SubscriberClient {
39
+ _terminated = false;
40
+ _opts;
41
+ _providedCustomServicePath;
42
+ _gaxModule;
43
+ _gaxGrpc;
44
+ _protos;
45
+ _defaults;
46
+ _universeDomain;
47
+ _servicePath;
48
+ _log = google_gax_1.loggingUtils.log('pubsub');
49
+ auth;
50
+ descriptors = {
51
+ page: {},
52
+ stream: {},
53
+ longrunning: {},
54
+ batching: {},
55
+ };
56
+ warn;
57
+ innerApiCalls;
58
+ iamClient;
59
+ pathTemplates;
60
+ subscriberStub;
38
61
  /**
39
62
  * Construct an instance of SubscriberClient.
40
63
  *
@@ -57,7 +80,7 @@ class SubscriberClient {
57
80
  * Developer's Console, e.g. 'grape-spaceship-123'. We will also check
58
81
  * the environment variable GCLOUD_PROJECT for your project ID. If your
59
82
  * app is running in an environment which supports
60
- * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
83
+ * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials},
61
84
  * your project ID will be detected automatically.
62
85
  * @param {string} [options.apiEndpoint] - The domain name of the
63
86
  * API remote host.
@@ -75,35 +98,29 @@ class SubscriberClient {
75
98
  * ```
76
99
  */
77
100
  constructor(opts, gaxInstance) {
78
- var _a, _b, _c, _d, _e;
79
- this._terminated = false;
80
- this.descriptors = {
81
- page: {},
82
- stream: {},
83
- longrunning: {},
84
- batching: {},
85
- };
86
101
  // Ensure that options include all the required fields.
87
102
  const staticMembers = this.constructor;
88
- if ((opts === null || opts === void 0 ? void 0 : opts.universe_domain) &&
89
- (opts === null || opts === void 0 ? void 0 : opts.universeDomain) &&
90
- (opts === null || opts === void 0 ? void 0 : opts.universe_domain) !== (opts === null || opts === void 0 ? void 0 : opts.universeDomain)) {
103
+ if (opts?.universe_domain &&
104
+ opts?.universeDomain &&
105
+ opts?.universe_domain !== opts?.universeDomain) {
91
106
  throw new Error('Please set either universe_domain or universeDomain, but not both.');
92
107
  }
93
108
  const universeDomainEnvVar = typeof process === 'object' && typeof process.env === 'object'
94
109
  ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
95
110
  : undefined;
96
111
  this._universeDomain =
97
- (_c = (_b = (_a = opts === null || opts === void 0 ? void 0 : opts.universeDomain) !== null && _a !== void 0 ? _a : opts === null || opts === void 0 ? void 0 : opts.universe_domain) !== null && _b !== void 0 ? _b : universeDomainEnvVar) !== null && _c !== void 0 ? _c : 'googleapis.com';
112
+ opts?.universeDomain ??
113
+ opts?.universe_domain ??
114
+ universeDomainEnvVar ??
115
+ 'googleapis.com';
98
116
  this._servicePath = 'pubsub.' + this._universeDomain;
99
- const servicePath = (opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint) || this._servicePath;
100
- this._providedCustomServicePath = !!((opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint));
101
- const port = (opts === null || opts === void 0 ? void 0 : opts.port) || staticMembers.port;
102
- const clientConfig = (_d = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _d !== void 0 ? _d : {};
103
- const fallback = (_e = opts === null || opts === void 0 ? void 0 : opts.fallback) !== null && _e !== void 0 ? _e : (typeof window !== 'undefined' && typeof (window === null || window === void 0 ? void 0 : window.fetch) === 'function');
117
+ const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath;
118
+ this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint);
119
+ const port = opts?.port || staticMembers.port;
120
+ const clientConfig = opts?.clientConfig ?? {};
121
+ const fallback = opts?.fallback ??
122
+ (typeof window !== 'undefined' && typeof window?.fetch === 'function');
104
123
  opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
105
- // Request numeric enum values if REST transport is used.
106
- opts.numericEnums = true;
107
124
  // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
108
125
  if (servicePath !== this._servicePath && !('scopes' in opts)) {
109
126
  opts['scopes'] = staticMembers.scopes;
@@ -225,7 +242,7 @@ class SubscriberClient {
225
242
  const callPromise = this.subscriberStub.then(stub => (...args) => {
226
243
  if (this._terminated) {
227
244
  if (methodName in this.descriptors.stream) {
228
- const stream = new stream_1.PassThrough();
245
+ const stream = new stream_1.PassThrough({ objectMode: true });
229
246
  setImmediate(() => {
230
247
  stream.emit('error', new this._gaxModule.GoogleError('The client has already been closed.'));
231
248
  });
@@ -310,7 +327,6 @@ class SubscriberClient {
310
327
  return this.auth.getProjectId();
311
328
  }
312
329
  createSubscription(request, optionsOrCallback, callback) {
313
- var _a;
314
330
  request = request || {};
315
331
  let options;
316
332
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -325,13 +341,26 @@ class SubscriberClient {
325
341
  options.otherArgs.headers = options.otherArgs.headers || {};
326
342
  options.otherArgs.headers['x-goog-request-params'] =
327
343
  this._gaxModule.routingHeader.fromParams({
328
- name: (_a = request.name) !== null && _a !== void 0 ? _a : '',
344
+ name: request.name ?? '',
329
345
  });
330
- this.initialize();
331
- return this.innerApiCalls.createSubscription(request, options, callback);
346
+ this.initialize().catch(err => {
347
+ throw err;
348
+ });
349
+ this._log.info('createSubscription request %j', request);
350
+ const wrappedCallback = callback
351
+ ? (error, response, options, rawResponse) => {
352
+ this._log.info('createSubscription response %j', response);
353
+ callback(error, response, options, rawResponse); // We verified callback above.
354
+ }
355
+ : undefined;
356
+ return this.innerApiCalls
357
+ .createSubscription(request, options, wrappedCallback)
358
+ ?.then(([response, options, rawResponse]) => {
359
+ this._log.info('createSubscription response %j', response);
360
+ return [response, options, rawResponse];
361
+ });
332
362
  }
333
363
  getSubscription(request, optionsOrCallback, callback) {
334
- var _a;
335
364
  request = request || {};
336
365
  let options;
337
366
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -346,13 +375,26 @@ class SubscriberClient {
346
375
  options.otherArgs.headers = options.otherArgs.headers || {};
347
376
  options.otherArgs.headers['x-goog-request-params'] =
348
377
  this._gaxModule.routingHeader.fromParams({
349
- subscription: (_a = request.subscription) !== null && _a !== void 0 ? _a : '',
378
+ subscription: request.subscription ?? '',
350
379
  });
351
- this.initialize();
352
- return this.innerApiCalls.getSubscription(request, options, callback);
380
+ this.initialize().catch(err => {
381
+ throw err;
382
+ });
383
+ this._log.info('getSubscription request %j', request);
384
+ const wrappedCallback = callback
385
+ ? (error, response, options, rawResponse) => {
386
+ this._log.info('getSubscription response %j', response);
387
+ callback(error, response, options, rawResponse); // We verified callback above.
388
+ }
389
+ : undefined;
390
+ return this.innerApiCalls
391
+ .getSubscription(request, options, wrappedCallback)
392
+ ?.then(([response, options, rawResponse]) => {
393
+ this._log.info('getSubscription response %j', response);
394
+ return [response, options, rawResponse];
395
+ });
353
396
  }
354
397
  updateSubscription(request, optionsOrCallback, callback) {
355
- var _a;
356
398
  request = request || {};
357
399
  let options;
358
400
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -367,13 +409,26 @@ class SubscriberClient {
367
409
  options.otherArgs.headers = options.otherArgs.headers || {};
368
410
  options.otherArgs.headers['x-goog-request-params'] =
369
411
  this._gaxModule.routingHeader.fromParams({
370
- 'subscription.name': (_a = request.subscription.name) !== null && _a !== void 0 ? _a : '',
412
+ 'subscription.name': request.subscription.name ?? '',
371
413
  });
372
- this.initialize();
373
- return this.innerApiCalls.updateSubscription(request, options, callback);
414
+ this.initialize().catch(err => {
415
+ throw err;
416
+ });
417
+ this._log.info('updateSubscription request %j', request);
418
+ const wrappedCallback = callback
419
+ ? (error, response, options, rawResponse) => {
420
+ this._log.info('updateSubscription response %j', response);
421
+ callback(error, response, options, rawResponse); // We verified callback above.
422
+ }
423
+ : undefined;
424
+ return this.innerApiCalls
425
+ .updateSubscription(request, options, wrappedCallback)
426
+ ?.then(([response, options, rawResponse]) => {
427
+ this._log.info('updateSubscription response %j', response);
428
+ return [response, options, rawResponse];
429
+ });
374
430
  }
375
431
  deleteSubscription(request, optionsOrCallback, callback) {
376
- var _a;
377
432
  request = request || {};
378
433
  let options;
379
434
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -388,13 +443,26 @@ class SubscriberClient {
388
443
  options.otherArgs.headers = options.otherArgs.headers || {};
389
444
  options.otherArgs.headers['x-goog-request-params'] =
390
445
  this._gaxModule.routingHeader.fromParams({
391
- subscription: (_a = request.subscription) !== null && _a !== void 0 ? _a : '',
446
+ subscription: request.subscription ?? '',
392
447
  });
393
- this.initialize();
394
- return this.innerApiCalls.deleteSubscription(request, options, callback);
448
+ this.initialize().catch(err => {
449
+ throw err;
450
+ });
451
+ this._log.info('deleteSubscription request %j', request);
452
+ const wrappedCallback = callback
453
+ ? (error, response, options, rawResponse) => {
454
+ this._log.info('deleteSubscription response %j', response);
455
+ callback(error, response, options, rawResponse); // We verified callback above.
456
+ }
457
+ : undefined;
458
+ return this.innerApiCalls
459
+ .deleteSubscription(request, options, wrappedCallback)
460
+ ?.then(([response, options, rawResponse]) => {
461
+ this._log.info('deleteSubscription response %j', response);
462
+ return [response, options, rawResponse];
463
+ });
395
464
  }
396
465
  modifyAckDeadline(request, optionsOrCallback, callback) {
397
- var _a;
398
466
  request = request || {};
399
467
  let options;
400
468
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -409,13 +477,26 @@ class SubscriberClient {
409
477
  options.otherArgs.headers = options.otherArgs.headers || {};
410
478
  options.otherArgs.headers['x-goog-request-params'] =
411
479
  this._gaxModule.routingHeader.fromParams({
412
- subscription: (_a = request.subscription) !== null && _a !== void 0 ? _a : '',
480
+ subscription: request.subscription ?? '',
413
481
  });
414
- this.initialize();
415
- return this.innerApiCalls.modifyAckDeadline(request, options, callback);
482
+ this.initialize().catch(err => {
483
+ throw err;
484
+ });
485
+ this._log.info('modifyAckDeadline request %j', request);
486
+ const wrappedCallback = callback
487
+ ? (error, response, options, rawResponse) => {
488
+ this._log.info('modifyAckDeadline response %j', response);
489
+ callback(error, response, options, rawResponse); // We verified callback above.
490
+ }
491
+ : undefined;
492
+ return this.innerApiCalls
493
+ .modifyAckDeadline(request, options, wrappedCallback)
494
+ ?.then(([response, options, rawResponse]) => {
495
+ this._log.info('modifyAckDeadline response %j', response);
496
+ return [response, options, rawResponse];
497
+ });
416
498
  }
417
499
  acknowledge(request, optionsOrCallback, callback) {
418
- var _a;
419
500
  request = request || {};
420
501
  let options;
421
502
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -430,13 +511,26 @@ class SubscriberClient {
430
511
  options.otherArgs.headers = options.otherArgs.headers || {};
431
512
  options.otherArgs.headers['x-goog-request-params'] =
432
513
  this._gaxModule.routingHeader.fromParams({
433
- subscription: (_a = request.subscription) !== null && _a !== void 0 ? _a : '',
514
+ subscription: request.subscription ?? '',
434
515
  });
435
- this.initialize();
436
- return this.innerApiCalls.acknowledge(request, options, callback);
516
+ this.initialize().catch(err => {
517
+ throw err;
518
+ });
519
+ this._log.info('acknowledge request %j', request);
520
+ const wrappedCallback = callback
521
+ ? (error, response, options, rawResponse) => {
522
+ this._log.info('acknowledge response %j', response);
523
+ callback(error, response, options, rawResponse); // We verified callback above.
524
+ }
525
+ : undefined;
526
+ return this.innerApiCalls
527
+ .acknowledge(request, options, wrappedCallback)
528
+ ?.then(([response, options, rawResponse]) => {
529
+ this._log.info('acknowledge response %j', response);
530
+ return [response, options, rawResponse];
531
+ });
437
532
  }
438
533
  pull(request, optionsOrCallback, callback) {
439
- var _a;
440
534
  request = request || {};
441
535
  let options;
442
536
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -451,13 +545,26 @@ class SubscriberClient {
451
545
  options.otherArgs.headers = options.otherArgs.headers || {};
452
546
  options.otherArgs.headers['x-goog-request-params'] =
453
547
  this._gaxModule.routingHeader.fromParams({
454
- subscription: (_a = request.subscription) !== null && _a !== void 0 ? _a : '',
548
+ subscription: request.subscription ?? '',
455
549
  });
456
- this.initialize();
457
- return this.innerApiCalls.pull(request, options, callback);
550
+ this.initialize().catch(err => {
551
+ throw err;
552
+ });
553
+ this._log.info('pull request %j', request);
554
+ const wrappedCallback = callback
555
+ ? (error, response, options, rawResponse) => {
556
+ this._log.info('pull response %j', response);
557
+ callback(error, response, options, rawResponse); // We verified callback above.
558
+ }
559
+ : undefined;
560
+ return this.innerApiCalls
561
+ .pull(request, options, wrappedCallback)
562
+ ?.then(([response, options, rawResponse]) => {
563
+ this._log.info('pull response %j', response);
564
+ return [response, options, rawResponse];
565
+ });
458
566
  }
459
567
  modifyPushConfig(request, optionsOrCallback, callback) {
460
- var _a;
461
568
  request = request || {};
462
569
  let options;
463
570
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -472,13 +579,26 @@ class SubscriberClient {
472
579
  options.otherArgs.headers = options.otherArgs.headers || {};
473
580
  options.otherArgs.headers['x-goog-request-params'] =
474
581
  this._gaxModule.routingHeader.fromParams({
475
- subscription: (_a = request.subscription) !== null && _a !== void 0 ? _a : '',
582
+ subscription: request.subscription ?? '',
476
583
  });
477
- this.initialize();
478
- return this.innerApiCalls.modifyPushConfig(request, options, callback);
584
+ this.initialize().catch(err => {
585
+ throw err;
586
+ });
587
+ this._log.info('modifyPushConfig request %j', request);
588
+ const wrappedCallback = callback
589
+ ? (error, response, options, rawResponse) => {
590
+ this._log.info('modifyPushConfig response %j', response);
591
+ callback(error, response, options, rawResponse); // We verified callback above.
592
+ }
593
+ : undefined;
594
+ return this.innerApiCalls
595
+ .modifyPushConfig(request, options, wrappedCallback)
596
+ ?.then(([response, options, rawResponse]) => {
597
+ this._log.info('modifyPushConfig response %j', response);
598
+ return [response, options, rawResponse];
599
+ });
479
600
  }
480
601
  getSnapshot(request, optionsOrCallback, callback) {
481
- var _a;
482
602
  request = request || {};
483
603
  let options;
484
604
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -493,13 +613,26 @@ class SubscriberClient {
493
613
  options.otherArgs.headers = options.otherArgs.headers || {};
494
614
  options.otherArgs.headers['x-goog-request-params'] =
495
615
  this._gaxModule.routingHeader.fromParams({
496
- snapshot: (_a = request.snapshot) !== null && _a !== void 0 ? _a : '',
616
+ snapshot: request.snapshot ?? '',
497
617
  });
498
- this.initialize();
499
- return this.innerApiCalls.getSnapshot(request, options, callback);
618
+ this.initialize().catch(err => {
619
+ throw err;
620
+ });
621
+ this._log.info('getSnapshot request %j', request);
622
+ const wrappedCallback = callback
623
+ ? (error, response, options, rawResponse) => {
624
+ this._log.info('getSnapshot response %j', response);
625
+ callback(error, response, options, rawResponse); // We verified callback above.
626
+ }
627
+ : undefined;
628
+ return this.innerApiCalls
629
+ .getSnapshot(request, options, wrappedCallback)
630
+ ?.then(([response, options, rawResponse]) => {
631
+ this._log.info('getSnapshot response %j', response);
632
+ return [response, options, rawResponse];
633
+ });
500
634
  }
501
635
  createSnapshot(request, optionsOrCallback, callback) {
502
- var _a;
503
636
  request = request || {};
504
637
  let options;
505
638
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -514,13 +647,26 @@ class SubscriberClient {
514
647
  options.otherArgs.headers = options.otherArgs.headers || {};
515
648
  options.otherArgs.headers['x-goog-request-params'] =
516
649
  this._gaxModule.routingHeader.fromParams({
517
- name: (_a = request.name) !== null && _a !== void 0 ? _a : '',
650
+ name: request.name ?? '',
518
651
  });
519
- this.initialize();
520
- return this.innerApiCalls.createSnapshot(request, options, callback);
652
+ this.initialize().catch(err => {
653
+ throw err;
654
+ });
655
+ this._log.info('createSnapshot request %j', request);
656
+ const wrappedCallback = callback
657
+ ? (error, response, options, rawResponse) => {
658
+ this._log.info('createSnapshot response %j', response);
659
+ callback(error, response, options, rawResponse); // We verified callback above.
660
+ }
661
+ : undefined;
662
+ return this.innerApiCalls
663
+ .createSnapshot(request, options, wrappedCallback)
664
+ ?.then(([response, options, rawResponse]) => {
665
+ this._log.info('createSnapshot response %j', response);
666
+ return [response, options, rawResponse];
667
+ });
521
668
  }
522
669
  updateSnapshot(request, optionsOrCallback, callback) {
523
- var _a;
524
670
  request = request || {};
525
671
  let options;
526
672
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -535,13 +681,26 @@ class SubscriberClient {
535
681
  options.otherArgs.headers = options.otherArgs.headers || {};
536
682
  options.otherArgs.headers['x-goog-request-params'] =
537
683
  this._gaxModule.routingHeader.fromParams({
538
- 'snapshot.name': (_a = request.snapshot.name) !== null && _a !== void 0 ? _a : '',
684
+ 'snapshot.name': request.snapshot.name ?? '',
539
685
  });
540
- this.initialize();
541
- return this.innerApiCalls.updateSnapshot(request, options, callback);
686
+ this.initialize().catch(err => {
687
+ throw err;
688
+ });
689
+ this._log.info('updateSnapshot request %j', request);
690
+ const wrappedCallback = callback
691
+ ? (error, response, options, rawResponse) => {
692
+ this._log.info('updateSnapshot response %j', response);
693
+ callback(error, response, options, rawResponse); // We verified callback above.
694
+ }
695
+ : undefined;
696
+ return this.innerApiCalls
697
+ .updateSnapshot(request, options, wrappedCallback)
698
+ ?.then(([response, options, rawResponse]) => {
699
+ this._log.info('updateSnapshot response %j', response);
700
+ return [response, options, rawResponse];
701
+ });
542
702
  }
543
703
  deleteSnapshot(request, optionsOrCallback, callback) {
544
- var _a;
545
704
  request = request || {};
546
705
  let options;
547
706
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -556,13 +715,26 @@ class SubscriberClient {
556
715
  options.otherArgs.headers = options.otherArgs.headers || {};
557
716
  options.otherArgs.headers['x-goog-request-params'] =
558
717
  this._gaxModule.routingHeader.fromParams({
559
- snapshot: (_a = request.snapshot) !== null && _a !== void 0 ? _a : '',
718
+ snapshot: request.snapshot ?? '',
560
719
  });
561
- this.initialize();
562
- return this.innerApiCalls.deleteSnapshot(request, options, callback);
720
+ this.initialize().catch(err => {
721
+ throw err;
722
+ });
723
+ this._log.info('deleteSnapshot request %j', request);
724
+ const wrappedCallback = callback
725
+ ? (error, response, options, rawResponse) => {
726
+ this._log.info('deleteSnapshot response %j', response);
727
+ callback(error, response, options, rawResponse); // We verified callback above.
728
+ }
729
+ : undefined;
730
+ return this.innerApiCalls
731
+ .deleteSnapshot(request, options, wrappedCallback)
732
+ ?.then(([response, options, rawResponse]) => {
733
+ this._log.info('deleteSnapshot response %j', response);
734
+ return [response, options, rawResponse];
735
+ });
563
736
  }
564
737
  seek(request, optionsOrCallback, callback) {
565
- var _a;
566
738
  request = request || {};
567
739
  let options;
568
740
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -577,10 +749,24 @@ class SubscriberClient {
577
749
  options.otherArgs.headers = options.otherArgs.headers || {};
578
750
  options.otherArgs.headers['x-goog-request-params'] =
579
751
  this._gaxModule.routingHeader.fromParams({
580
- subscription: (_a = request.subscription) !== null && _a !== void 0 ? _a : '',
752
+ subscription: request.subscription ?? '',
581
753
  });
582
- this.initialize();
583
- return this.innerApiCalls.seek(request, options, callback);
754
+ this.initialize().catch(err => {
755
+ throw err;
756
+ });
757
+ this._log.info('seek request %j', request);
758
+ const wrappedCallback = callback
759
+ ? (error, response, options, rawResponse) => {
760
+ this._log.info('seek response %j', response);
761
+ callback(error, response, options, rawResponse); // We verified callback above.
762
+ }
763
+ : undefined;
764
+ return this.innerApiCalls
765
+ .seek(request, options, wrappedCallback)
766
+ ?.then(([response, options, rawResponse]) => {
767
+ this._log.info('seek response %j', response);
768
+ return [response, options, rawResponse];
769
+ });
584
770
  }
585
771
  /**
586
772
  * Establishes a stream with the server, which sends messages down to the
@@ -599,13 +785,17 @@ class SubscriberClient {
599
785
  * will emit objects representing {@link protos.google.pubsub.v1.StreamingPullResponse|StreamingPullResponse} on 'data' event asynchronously.
600
786
  * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation }
601
787
  * for more details and examples.
788
+ * @example <caption>include:samples/generated/v1/subscriber.streaming_pull.js</caption>
789
+ * region_tag:pubsub_v1_generated_Subscriber_StreamingPull_async
602
790
  */
603
791
  streamingPull(options) {
604
- this.initialize();
792
+ this.initialize().catch(err => {
793
+ throw err;
794
+ });
795
+ this._log.info('streamingPull stream %j', options);
605
796
  return this.innerApiCalls.streamingPull(null, options);
606
797
  }
607
798
  listSubscriptions(request, optionsOrCallback, callback) {
608
- var _a;
609
799
  request = request || {};
610
800
  let options;
611
801
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -620,13 +810,27 @@ class SubscriberClient {
620
810
  options.otherArgs.headers = options.otherArgs.headers || {};
621
811
  options.otherArgs.headers['x-goog-request-params'] =
622
812
  this._gaxModule.routingHeader.fromParams({
623
- project: (_a = request.project) !== null && _a !== void 0 ? _a : '',
813
+ project: request.project ?? '',
624
814
  });
625
- this.initialize();
626
- return this.innerApiCalls.listSubscriptions(request, options, callback);
815
+ this.initialize().catch(err => {
816
+ throw err;
817
+ });
818
+ const wrappedCallback = callback
819
+ ? (error, values, nextPageRequest, rawResponse) => {
820
+ this._log.info('listSubscriptions values %j', values);
821
+ callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
822
+ }
823
+ : undefined;
824
+ this._log.info('listSubscriptions request %j', request);
825
+ return this.innerApiCalls
826
+ .listSubscriptions(request, options, wrappedCallback)
827
+ ?.then(([response, input, output]) => {
828
+ this._log.info('listSubscriptions values %j', response);
829
+ return [response, input, output];
830
+ });
627
831
  }
628
832
  /**
629
- * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
833
+ * Equivalent to `listSubscriptions`, but returns a NodeJS Stream object.
630
834
  * @param {Object} request
631
835
  * The request object that will be sent.
632
836
  * @param {string} request.project
@@ -650,18 +854,20 @@ class SubscriberClient {
650
854
  * for more details and examples.
651
855
  */
652
856
  listSubscriptionsStream(request, options) {
653
- var _a;
654
857
  request = request || {};
655
858
  options = options || {};
656
859
  options.otherArgs = options.otherArgs || {};
657
860
  options.otherArgs.headers = options.otherArgs.headers || {};
658
861
  options.otherArgs.headers['x-goog-request-params'] =
659
862
  this._gaxModule.routingHeader.fromParams({
660
- project: (_a = request.project) !== null && _a !== void 0 ? _a : '',
863
+ project: request.project ?? '',
661
864
  });
662
865
  const defaultCallSettings = this._defaults['listSubscriptions'];
663
866
  const callSettings = defaultCallSettings.merge(options);
664
- this.initialize();
867
+ this.initialize().catch(err => {
868
+ throw err;
869
+ });
870
+ this._log.info('listSubscriptions stream %j', request);
665
871
  return this.descriptors.page.listSubscriptions.createStream(this.innerApiCalls.listSubscriptions, request, callSettings);
666
872
  }
667
873
  /**
@@ -688,24 +894,27 @@ class SubscriberClient {
688
894
  * so you can stop the iteration when you don't need more results.
689
895
  * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
690
896
  * for more details and examples.
897
+ * @example <caption>include:samples/generated/v1/subscriber.list_subscriptions.js</caption>
898
+ * region_tag:pubsub_v1_generated_Subscriber_ListSubscriptions_async
691
899
  */
692
900
  listSubscriptionsAsync(request, options) {
693
- var _a;
694
901
  request = request || {};
695
902
  options = options || {};
696
903
  options.otherArgs = options.otherArgs || {};
697
904
  options.otherArgs.headers = options.otherArgs.headers || {};
698
905
  options.otherArgs.headers['x-goog-request-params'] =
699
906
  this._gaxModule.routingHeader.fromParams({
700
- project: (_a = request.project) !== null && _a !== void 0 ? _a : '',
907
+ project: request.project ?? '',
701
908
  });
702
909
  const defaultCallSettings = this._defaults['listSubscriptions'];
703
910
  const callSettings = defaultCallSettings.merge(options);
704
- this.initialize();
911
+ this.initialize().catch(err => {
912
+ throw err;
913
+ });
914
+ this._log.info('listSubscriptions iterate %j', request);
705
915
  return this.descriptors.page.listSubscriptions.asyncIterate(this.innerApiCalls['listSubscriptions'], request, callSettings);
706
916
  }
707
917
  listSnapshots(request, optionsOrCallback, callback) {
708
- var _a;
709
918
  request = request || {};
710
919
  let options;
711
920
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -720,13 +929,27 @@ class SubscriberClient {
720
929
  options.otherArgs.headers = options.otherArgs.headers || {};
721
930
  options.otherArgs.headers['x-goog-request-params'] =
722
931
  this._gaxModule.routingHeader.fromParams({
723
- project: (_a = request.project) !== null && _a !== void 0 ? _a : '',
932
+ project: request.project ?? '',
724
933
  });
725
- this.initialize();
726
- return this.innerApiCalls.listSnapshots(request, options, callback);
934
+ this.initialize().catch(err => {
935
+ throw err;
936
+ });
937
+ const wrappedCallback = callback
938
+ ? (error, values, nextPageRequest, rawResponse) => {
939
+ this._log.info('listSnapshots values %j', values);
940
+ callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
941
+ }
942
+ : undefined;
943
+ this._log.info('listSnapshots request %j', request);
944
+ return this.innerApiCalls
945
+ .listSnapshots(request, options, wrappedCallback)
946
+ ?.then(([response, input, output]) => {
947
+ this._log.info('listSnapshots values %j', response);
948
+ return [response, input, output];
949
+ });
727
950
  }
728
951
  /**
729
- * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
952
+ * Equivalent to `listSnapshots`, but returns a NodeJS Stream object.
730
953
  * @param {Object} request
731
954
  * The request object that will be sent.
732
955
  * @param {string} request.project
@@ -750,18 +973,20 @@ class SubscriberClient {
750
973
  * for more details and examples.
751
974
  */
752
975
  listSnapshotsStream(request, options) {
753
- var _a;
754
976
  request = request || {};
755
977
  options = options || {};
756
978
  options.otherArgs = options.otherArgs || {};
757
979
  options.otherArgs.headers = options.otherArgs.headers || {};
758
980
  options.otherArgs.headers['x-goog-request-params'] =
759
981
  this._gaxModule.routingHeader.fromParams({
760
- project: (_a = request.project) !== null && _a !== void 0 ? _a : '',
982
+ project: request.project ?? '',
761
983
  });
762
984
  const defaultCallSettings = this._defaults['listSnapshots'];
763
985
  const callSettings = defaultCallSettings.merge(options);
764
- this.initialize();
986
+ this.initialize().catch(err => {
987
+ throw err;
988
+ });
989
+ this._log.info('listSnapshots stream %j', request);
765
990
  return this.descriptors.page.listSnapshots.createStream(this.innerApiCalls.listSnapshots, request, callSettings);
766
991
  }
767
992
  /**
@@ -788,20 +1013,24 @@ class SubscriberClient {
788
1013
  * so you can stop the iteration when you don't need more results.
789
1014
  * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
790
1015
  * for more details and examples.
1016
+ * @example <caption>include:samples/generated/v1/subscriber.list_snapshots.js</caption>
1017
+ * region_tag:pubsub_v1_generated_Subscriber_ListSnapshots_async
791
1018
  */
792
1019
  listSnapshotsAsync(request, options) {
793
- var _a;
794
1020
  request = request || {};
795
1021
  options = options || {};
796
1022
  options.otherArgs = options.otherArgs || {};
797
1023
  options.otherArgs.headers = options.otherArgs.headers || {};
798
1024
  options.otherArgs.headers['x-goog-request-params'] =
799
1025
  this._gaxModule.routingHeader.fromParams({
800
- project: (_a = request.project) !== null && _a !== void 0 ? _a : '',
1026
+ project: request.project ?? '',
801
1027
  });
802
1028
  const defaultCallSettings = this._defaults['listSnapshots'];
803
1029
  const callSettings = defaultCallSettings.merge(options);
804
- this.initialize();
1030
+ this.initialize().catch(err => {
1031
+ throw err;
1032
+ });
1033
+ this._log.info('listSnapshots iterate %j', request);
805
1034
  return this.descriptors.page.listSnapshots.asyncIterate(this.innerApiCalls['listSnapshots'], request, callSettings);
806
1035
  }
807
1036
  /**
@@ -1066,9 +1295,10 @@ class SubscriberClient {
1066
1295
  close() {
1067
1296
  if (this.subscriberStub && !this._terminated) {
1068
1297
  return this.subscriberStub.then(stub => {
1298
+ this._log.info('ending gRPC channel');
1069
1299
  this._terminated = true;
1070
1300
  stub.close();
1071
- this.iamClient.close();
1301
+ void this.iamClient.close();
1072
1302
  });
1073
1303
  }
1074
1304
  return Promise.resolve();