@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.
- package/CHANGELOG.md +14 -0
- package/README.md +2 -2
- package/build/protos/protos.d.ts +6 -6
- package/build/protos/protos.js +423 -141
- package/build/protos/protos.json +39 -18
- package/build/src/debug.js +2 -0
- package/build/src/debug.js.map +1 -1
- package/build/src/default-options.d.ts +2 -2
- package/build/src/default-options.js +3 -3
- package/build/src/default-options.js.map +1 -1
- package/build/src/exponential-retry.js +4 -1
- package/build/src/exponential-retry.js.map +1 -1
- package/build/src/histogram.js +3 -0
- package/build/src/histogram.js.map +1 -1
- package/build/src/iam.js +3 -0
- package/build/src/iam.js.map +1 -1
- package/build/src/index.d.ts +0 -2
- package/build/src/index.js +1 -5
- package/build/src/index.js.map +1 -1
- package/build/src/lease-manager.d.ts +0 -3
- package/build/src/lease-manager.js +14 -19
- package/build/src/lease-manager.js.map +1 -1
- package/build/src/message-queues.js +31 -23
- package/build/src/message-queues.js.map +1 -1
- package/build/src/message-stream.js +13 -4
- package/build/src/message-stream.js.map +1 -1
- package/build/src/publisher/flow-control.js +4 -1
- package/build/src/publisher/flow-control.js.map +1 -1
- package/build/src/publisher/flow-publisher.js +5 -2
- package/build/src/publisher/flow-publisher.js.map +1 -1
- package/build/src/publisher/index.d.ts +0 -2
- package/build/src/publisher/index.js +9 -6
- package/build/src/publisher/index.js.map +1 -1
- package/build/src/publisher/message-batch.d.ts +0 -11
- package/build/src/publisher/message-batch.js +13 -1
- package/build/src/publisher/message-batch.js.map +1 -1
- package/build/src/publisher/message-queues.js +10 -3
- package/build/src/publisher/message-queues.js.map +1 -1
- package/build/src/publisher/publish-error.js +5 -0
- package/build/src/publisher/publish-error.js.map +1 -1
- package/build/src/publisher/pubsub-message.d.ts +0 -68
- package/build/src/pubsub.js +14 -5
- package/build/src/pubsub.js.map +1 -1
- package/build/src/schema.js +3 -0
- package/build/src/schema.js.map +1 -1
- package/build/src/snapshot.js +3 -0
- package/build/src/snapshot.js.map +1 -1
- package/build/src/subscriber.d.ts +11 -15
- package/build/src/subscriber.js +84 -26
- package/build/src/subscriber.js.map +1 -1
- package/build/src/subscription.js +11 -2
- package/build/src/subscription.js.map +1 -1
- package/build/src/telemetry-tracing.d.ts +2 -220
- package/build/src/telemetry-tracing.js +36 -112
- package/build/src/telemetry-tracing.js.map +1 -1
- package/build/src/temporal.js +8 -8
- package/build/src/temporal.js.map +1 -1
- package/build/src/topic.js +8 -1
- package/build/src/topic.js.map +1 -1
- package/build/src/util.js +3 -2
- package/build/src/util.js.map +1 -1
- package/build/src/v1/publisher_client.d.ts +26 -4
- package/build/src/v1/publisher_client.js +232 -90
- package/build/src/v1/publisher_client.js.map +1 -1
- package/build/src/v1/publisher_proto_list.json +4 -0
- package/build/src/v1/schema_service_client.d.ts +24 -3
- package/build/src/v1/schema_service_client.js +235 -75
- package/build/src/v1/schema_service_client.js.map +1 -1
- package/build/src/v1/schema_service_proto_list.json +4 -0
- package/build/src/v1/subscriber_client.d.ts +39 -3
- package/build/src/v1/subscriber_client.js +327 -97
- package/build/src/v1/subscriber_client.js.map +1 -1
- package/build/src/v1/subscriber_proto_list.json +4 -0
- 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://
|
|
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 (
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
112
|
+
opts?.universeDomain ??
|
|
113
|
+
opts?.universe_domain ??
|
|
114
|
+
universeDomainEnvVar ??
|
|
115
|
+
'googleapis.com';
|
|
98
116
|
this._servicePath = 'pubsub.' + this._universeDomain;
|
|
99
|
-
const servicePath =
|
|
100
|
-
this._providedCustomServicePath = !!(
|
|
101
|
-
const port =
|
|
102
|
-
const clientConfig =
|
|
103
|
-
const fallback =
|
|
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:
|
|
344
|
+
name: request.name ?? '',
|
|
329
345
|
});
|
|
330
|
-
this.initialize()
|
|
331
|
-
|
|
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:
|
|
378
|
+
subscription: request.subscription ?? '',
|
|
350
379
|
});
|
|
351
|
-
this.initialize()
|
|
352
|
-
|
|
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':
|
|
412
|
+
'subscription.name': request.subscription.name ?? '',
|
|
371
413
|
});
|
|
372
|
-
this.initialize()
|
|
373
|
-
|
|
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:
|
|
446
|
+
subscription: request.subscription ?? '',
|
|
392
447
|
});
|
|
393
|
-
this.initialize()
|
|
394
|
-
|
|
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:
|
|
480
|
+
subscription: request.subscription ?? '',
|
|
413
481
|
});
|
|
414
|
-
this.initialize()
|
|
415
|
-
|
|
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:
|
|
514
|
+
subscription: request.subscription ?? '',
|
|
434
515
|
});
|
|
435
|
-
this.initialize()
|
|
436
|
-
|
|
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:
|
|
548
|
+
subscription: request.subscription ?? '',
|
|
455
549
|
});
|
|
456
|
-
this.initialize()
|
|
457
|
-
|
|
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:
|
|
582
|
+
subscription: request.subscription ?? '',
|
|
476
583
|
});
|
|
477
|
-
this.initialize()
|
|
478
|
-
|
|
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:
|
|
616
|
+
snapshot: request.snapshot ?? '',
|
|
497
617
|
});
|
|
498
|
-
this.initialize()
|
|
499
|
-
|
|
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:
|
|
650
|
+
name: request.name ?? '',
|
|
518
651
|
});
|
|
519
|
-
this.initialize()
|
|
520
|
-
|
|
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':
|
|
684
|
+
'snapshot.name': request.snapshot.name ?? '',
|
|
539
685
|
});
|
|
540
|
-
this.initialize()
|
|
541
|
-
|
|
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:
|
|
718
|
+
snapshot: request.snapshot ?? '',
|
|
560
719
|
});
|
|
561
|
-
this.initialize()
|
|
562
|
-
|
|
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:
|
|
752
|
+
subscription: request.subscription ?? '',
|
|
581
753
|
});
|
|
582
|
-
this.initialize()
|
|
583
|
-
|
|
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:
|
|
813
|
+
project: request.project ?? '',
|
|
624
814
|
});
|
|
625
|
-
this.initialize()
|
|
626
|
-
|
|
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 `
|
|
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:
|
|
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:
|
|
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:
|
|
932
|
+
project: request.project ?? '',
|
|
724
933
|
});
|
|
725
|
-
this.initialize()
|
|
726
|
-
|
|
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 `
|
|
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:
|
|
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:
|
|
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();
|