@google-cloud/pubsub 3.0.1 → 3.1.1

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.
@@ -2064,6 +2064,10 @@
2064
2064
  "syntax": {
2065
2065
  "type": "string",
2066
2066
  "id": 12
2067
+ },
2068
+ "edition": {
2069
+ "type": "string",
2070
+ "id": 13
2067
2071
  }
2068
2072
  }
2069
2073
  },
@@ -2891,6 +2895,19 @@
2891
2895
  "end": {
2892
2896
  "type": "int32",
2893
2897
  "id": 4
2898
+ },
2899
+ "semantic": {
2900
+ "type": "Semantic",
2901
+ "id": 5
2902
+ }
2903
+ },
2904
+ "nested": {
2905
+ "Semantic": {
2906
+ "values": {
2907
+ "NONE": 0,
2908
+ "SET": 1,
2909
+ "ALIAS": 2
2910
+ }
2894
2911
  }
2895
2912
  }
2896
2913
  }
@@ -13,12 +13,16 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { Duration } from './temporal';
16
17
  export declare const defaultOptions: {
17
18
  subscription: {
18
19
  maxOutstandingMessages: number;
19
20
  maxOutstandingBytes: number;
21
+ minAckDeadline: undefined;
22
+ maxAckDeadline: Duration;
20
23
  maxExtensionMinutes: number;
21
24
  maxStreams: number;
25
+ ackDeadline: number;
22
26
  };
23
27
  publish: {
24
28
  maxOutstandingMessages: number;
@@ -16,6 +16,7 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.defaultOptions = void 0;
19
+ const temporal_1 = require("./temporal");
19
20
  // These options will be used library-wide. They're specified here so that
20
21
  // they can be changed easily in the future.
21
22
  exports.defaultOptions = {
@@ -26,12 +27,18 @@ exports.defaultOptions = {
26
27
  // The maximum amount of message data that may be queued for receiving,
27
28
  // in bytes, with the default lease manager.
28
29
  maxOutstandingBytes: 100 * 1024 * 1024,
30
+ // The minimum length of time a message's lease will be extended by.
31
+ minAckDeadline: undefined,
32
+ // The maximum length of time a message's lease will be extended by.
33
+ maxAckDeadline: temporal_1.Duration.from({ minutes: 10 }),
29
34
  // The maximum number of minutes that a message's lease will ever
30
35
  // be extended.
31
36
  maxExtensionMinutes: 60,
32
37
  // The maximum number of subscription streams/threads that will ever
33
38
  // be opened.
34
39
  maxStreams: 5,
40
+ // The starting number of seconds that ack deadlines will be extended.
41
+ ackDeadline: 10,
35
42
  },
36
43
  publish: {
37
44
  // The maximum number of messages we'll batch up for publish().
@@ -1 +1 @@
1
- {"version":3,"file":"default-options.js","sourceRoot":"","sources":["../../src/default-options.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,0EAA0E;AAC1E,4CAA4C;AAC/B,QAAA,cAAc,GAAG;IAC5B,YAAY,EAAE;QACZ,mEAAmE;QACnE,kCAAkC;QAClC,sBAAsB,EAAE,IAAI;QAE5B,uEAAuE;QACvE,4CAA4C;QAC5C,mBAAmB,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;QAEtC,iEAAiE;QACjE,eAAe;QACf,mBAAmB,EAAE,EAAE;QAEvB,oEAAoE;QACpE,aAAa;QACb,UAAU,EAAE,CAAC;KACd;IAED,OAAO,EAAE;QACP,+DAA+D;QAC/D,sBAAsB,EAAE,GAAG;QAE3B,mEAAmE;QACnE,mBAAmB,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI;QAEpC,yEAAyE;QACzE,cAAc,EAAE,EAAE;KACnB;CACF,CAAC"}
1
+ {"version":3,"file":"default-options.js","sourceRoot":"","sources":["../../src/default-options.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,yCAAoC;AAEpC,0EAA0E;AAC1E,4CAA4C;AAC/B,QAAA,cAAc,GAAG;IAC5B,YAAY,EAAE;QACZ,mEAAmE;QACnE,kCAAkC;QAClC,sBAAsB,EAAE,IAAI;QAE5B,uEAAuE;QACvE,4CAA4C;QAC5C,mBAAmB,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;QAEtC,oEAAoE;QACpE,cAAc,EAAE,SAAS;QAEzB,oEAAoE;QACpE,cAAc,EAAE,mBAAQ,CAAC,IAAI,CAAC,EAAC,OAAO,EAAE,EAAE,EAAC,CAAC;QAE5C,iEAAiE;QACjE,eAAe;QACf,mBAAmB,EAAE,EAAE;QAEvB,oEAAoE;QACpE,aAAa;QACb,UAAU,EAAE,CAAC;QAEb,sEAAsE;QACtE,WAAW,EAAE,EAAE;KAChB;IAED,OAAO,EAAE;QACP,+DAA+D;QAC/D,sBAAsB,EAAE,GAAG;QAE3B,mEAAmE;QACnE,mBAAmB,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI;QAEpC,yEAAyE;QACzE,cAAc,EAAE,EAAE;KACnB;CACF,CAAC"}
@@ -94,5 +94,6 @@ export { Message, SubscriberOptions } from './subscriber';
94
94
  export { Schema, CreateSchemaResponse, ISchema, SchemaType, SchemaTypes, ICreateSchemaRequest, SchemaEncoding, SchemaView, SchemaViews, Encodings, SchemaMessageMetadata, } from './schema';
95
95
  export { PushConfig, SubscriptionMetadata, SubscriptionOptions, SubscriptionCloseCallback, CreateSubscriptionOptions, CreateSubscriptionCallback, CreateSubscriptionResponse, GetSubscriptionOptions, GetSubscriptionCallback, GetSubscriptionResponse, GetSubscriptionMetadataCallback, GetSubscriptionMetadataResponse, SetSubscriptionMetadataCallback, SetSubscriptionMetadataResponse, Subscription, } from './subscription';
96
96
  export { CreateTopicCallback, CreateTopicResponse, GetTopicCallback, GetTopicResponse, GetTopicOptions, GetTopicMetadataCallback, GetTopicMetadataResponse, GetTopicSubscriptionsCallback, GetTopicSubscriptionsResponse, SetTopicMetadataCallback, SetTopicMetadataResponse, Topic, TopicMetadata, } from './topic';
97
+ export { Duration, TotalOfUnit, DurationLike } from './temporal';
97
98
  import * as protos from '../protos/protos';
98
99
  export { protos };
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.protos = exports.Topic = exports.Subscription = exports.Encodings = exports.SchemaViews = exports.SchemaTypes = exports.Schema = exports.Message = exports.Snapshot = exports.PubSub = exports.PublishError = exports.IAM = exports.v1 = void 0;
18
+ exports.protos = exports.Duration = exports.Topic = exports.Subscription = exports.Encodings = exports.SchemaViews = exports.SchemaTypes = exports.Schema = exports.Message = exports.Snapshot = exports.PubSub = exports.PublishError = exports.IAM = exports.v1 = void 0;
19
19
  /**
20
20
  * @namespace google.pubsub.v1
21
21
  */
@@ -104,6 +104,8 @@ var subscription_1 = require("./subscription");
104
104
  Object.defineProperty(exports, "Subscription", { enumerable: true, get: function () { return subscription_1.Subscription; } });
105
105
  var topic_1 = require("./topic");
106
106
  Object.defineProperty(exports, "Topic", { enumerable: true, get: function () { return topic_1.Topic; } });
107
+ var temporal_1 = require("./temporal");
108
+ Object.defineProperty(exports, "Duration", { enumerable: true, get: function () { return temporal_1.Duration; } });
107
109
  if (process.env.DEBUG_GRPC) {
108
110
  console.info('gRPC logging set to verbose');
109
111
  const grpc = require('google-gax').grpc;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;GAEG;AACH;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;GAWG;AACH,2BAA2B;AACnB,gBAAE;AAEV,6BAUe;AADb,0FAAA,GAAG,OAAA;AAIL,2DAAuD;AAA/C,6GAAA,YAAY,OAAA;AAEpB,mCAckB;AAFhB,gGAAA,MAAM,OAAA;AAGR,uCAMoB;AADlB,oGAAA,QAAQ,OAAA;AAEV,2CAAwD;AAAhD,qGAAA,OAAO,OAAA;AACf,mCAYkB;AAXhB,gGAAA,MAAM,OAAA;AAIN,qGAAA,WAAW,OAAA;AAIX,qGAAA,WAAW,OAAA;AACX,mGAAA,SAAS,OAAA;AAGX,+CAgBwB;AADtB,4GAAA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C,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACxB,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;CAC/C;AACD,2CAA2C;AACnC,wBAAM"}
@@ -36,7 +36,7 @@ export interface FlowControlOptions {
36
36
  * allow message data to consume. (Default: 100MB) It's possible that this
37
37
  * value will be exceeded, since messages are received in batches.
38
38
  * @property {number} [maxExtensionMinutes=60] The maximum duration (in minutes)
39
- * to extend the message deadline before redelivering.
39
+ * to extend the message deadline before redelivering.
40
40
  * @property {number} [maxMessages=1000] The desired number of messages to allow
41
41
  * in memory before pausing the message stream. Unless allowExcessMessages
42
42
  * is set to false, it is very likely that this value will be exceeded since
@@ -30,7 +30,7 @@ const default_options_1 = require("./default-options");
30
30
  * allow message data to consume. (Default: 100MB) It's possible that this
31
31
  * value will be exceeded, since messages are received in batches.
32
32
  * @property {number} [maxExtensionMinutes=60] The maximum duration (in minutes)
33
- * to extend the message deadline before redelivering.
33
+ * to extend the message deadline before redelivering.
34
34
  * @property {number} [maxMessages=1000] The desired number of messages to allow
35
35
  * in memory before pausing the message stream. Unless allowExcessMessages
36
36
  * is set to false, it is very likely that this value will be exceeded since
@@ -23,6 +23,7 @@ import { BatchOptions } from './message-queues';
23
23
  import { MessageStreamOptions } from './message-stream';
24
24
  import { Subscription } from './subscription';
25
25
  import { SubscriberClient } from './v1';
26
+ import { Duration } from './temporal';
26
27
  export declare type PullResponse = google.pubsub.v1.IStreamingPullResponse;
27
28
  export declare type SubscriptionProperties = google.pubsub.v1.StreamingPullResponse.ISubscriptionProperties;
28
29
  /**
@@ -109,19 +110,18 @@ export declare class Message {
109
110
  */
110
111
  nack(): void;
111
112
  }
112
- export interface SubscriberOptions {
113
- ackDeadline?: number;
114
- batching?: BatchOptions;
115
- flowControl?: FlowControlOptions;
116
- useLegacyFlowControl?: boolean;
117
- streamingOptions?: MessageStreamOptions;
118
- enableOpenTelemetryTracing?: boolean;
119
- }
120
113
  /**
121
114
  * @typedef {object} SubscriberOptions
122
115
  * @property {number} [ackDeadline=10] Acknowledge deadline in seconds. If left
123
- * unset the initial value will be 10 seconds, but it will evolve into the
124
- * 99th percentile time it takes to acknowledge a message.
116
+ * unset, the initial value will be 10 seconds, but it will evolve into the
117
+ * 99th percentile time it takes to acknowledge a message, subject to the
118
+ * limitations of minAckDeadline and maxAckDeadline. If ackDeadline is set
119
+ * by the user, then the min/max values will be set to match it. New code
120
+ * should prefer setting minAckDeadline and maxAckDeadline directly.
121
+ * @property {Duration} [minAckDeadline] The minimum time that ackDeadline should
122
+ * ever have, while it's under library control.
123
+ * @property {Duration} [maxAckDeadline] The maximum time that ackDeadline should
124
+ * ever have, while it's under library control.
125
125
  * @property {BatchOptions} [batching] Request batching options.
126
126
  * @property {FlowControlOptions} [flowControl] Flow control options.
127
127
  * @property {boolean} [useLegacyFlowControl] Disables enforcing flow control
@@ -129,6 +129,17 @@ export interface SubscriberOptions {
129
129
  * of only enforcing flow control at the client side.
130
130
  * @property {MessageStreamOptions} [streamingOptions] Streaming options.
131
131
  */
132
+ export interface SubscriberOptions {
133
+ /** @deprecated Use minAckDeadline and maxAckDeadline. */
134
+ ackDeadline?: number;
135
+ minAckDeadline?: Duration;
136
+ maxAckDeadline?: Duration;
137
+ batching?: BatchOptions;
138
+ flowControl?: FlowControlOptions;
139
+ useLegacyFlowControl?: boolean;
140
+ streamingOptions?: MessageStreamOptions;
141
+ enableOpenTelemetryTracing?: boolean;
142
+ }
132
143
  /**
133
144
  * Subscriber class is used to manage all message related functionality.
134
145
  *
@@ -147,7 +158,6 @@ export declare class Subscriber extends EventEmitter {
147
158
  private _acks;
148
159
  private _histogram;
149
160
  private _inventory;
150
- private _isUserSetDeadline;
151
161
  private _useOpentelemetry;
152
162
  private _latencies;
153
163
  private _modAcks;
@@ -159,7 +169,28 @@ export declare class Subscriber extends EventEmitter {
159
169
  subscriptionProperties?: SubscriptionProperties;
160
170
  constructor(subscription: Subscription, options?: {});
161
171
  /**
162
- * Sets our subscription properties from the first incoming message.
172
+ * Update our ack extension time that will be used by the lease manager
173
+ * for sending modAcks.
174
+ *
175
+ * Should not be called from outside this class, except for unit tests.
176
+ *
177
+ * @param {number} [ackTimeSeconds] The number of seconds that the last
178
+ * ack took after the message was received. If this is undefined, then
179
+ * we won't update the histogram, but we will still recalculate the
180
+ * ackDeadline based on the situation.
181
+ *
182
+ * @private
183
+ */
184
+ updateAckDeadline(ackTimeSeconds?: number): void;
185
+ private getMinMaxDeadlines;
186
+ /**
187
+ * Returns true if an exactly once subscription has been detected.
188
+ *
189
+ * @private
190
+ */
191
+ get isExactlyOnce(): boolean;
192
+ /**
193
+ * Sets our subscription properties from incoming messages.
163
194
  *
164
195
  * @param {SubscriptionProperties} subscriptionProperties The new properties.
165
196
  * @private
@@ -29,6 +29,7 @@ const message_stream_1 = require("./message-stream");
29
29
  const default_options_1 = require("./default-options");
30
30
  const opentelemetry_tracing_1 = require("./opentelemetry-tracing");
31
31
  const util_1 = require("./util");
32
+ const temporal_1 = require("./temporal");
32
33
  /**
33
34
  * Date object with nanosecond precision. Supports all standard Date arguments
34
35
  * in addition to several custom types.
@@ -187,18 +188,7 @@ class Message {
187
188
  }
188
189
  }
189
190
  exports.Message = Message;
190
- /**
191
- * @typedef {object} SubscriberOptions
192
- * @property {number} [ackDeadline=10] Acknowledge deadline in seconds. If left
193
- * unset the initial value will be 10 seconds, but it will evolve into the
194
- * 99th percentile time it takes to acknowledge a message.
195
- * @property {BatchOptions} [batching] Request batching options.
196
- * @property {FlowControlOptions} [flowControl] Flow control options.
197
- * @property {boolean} [useLegacyFlowControl] Disables enforcing flow control
198
- * settings at the Cloud PubSub server and uses the less accurate method
199
- * of only enforcing flow control at the client side.
200
- * @property {MessageStreamOptions} [streamingOptions] Streaming options.
201
- */
191
+ const minAckDeadlineForExactlyOnce = temporal_1.Duration.from({ seconds: 60 });
202
192
  /**
203
193
  * Subscriber class is used to manage all message related functionality.
204
194
  *
@@ -211,12 +201,11 @@ exports.Message = Message;
211
201
  class Subscriber extends events_1.EventEmitter {
212
202
  constructor(subscription, options = {}) {
213
203
  super();
214
- this.ackDeadline = 10;
204
+ this.ackDeadline = default_options_1.defaultOptions.subscription.ackDeadline;
215
205
  this.maxMessages = default_options_1.defaultOptions.subscription.maxOutstandingMessages;
216
206
  this.maxBytes = default_options_1.defaultOptions.subscription.maxOutstandingBytes;
217
207
  this.useLegacyFlowControl = false;
218
208
  this.isOpen = false;
219
- this._isUserSetDeadline = false;
220
209
  this._useOpentelemetry = false;
221
210
  this._histogram = new histogram_1.Histogram({ min: 10, max: 600 });
222
211
  this._latencies = new histogram_1.Histogram();
@@ -225,19 +214,82 @@ class Subscriber extends events_1.EventEmitter {
225
214
  this.setOptions(options);
226
215
  }
227
216
  /**
228
- * Sets our subscription properties from the first incoming message.
217
+ * Update our ack extension time that will be used by the lease manager
218
+ * for sending modAcks.
219
+ *
220
+ * Should not be called from outside this class, except for unit tests.
221
+ *
222
+ * @param {number} [ackTimeSeconds] The number of seconds that the last
223
+ * ack took after the message was received. If this is undefined, then
224
+ * we won't update the histogram, but we will still recalculate the
225
+ * ackDeadline based on the situation.
226
+ *
227
+ * @private
228
+ */
229
+ updateAckDeadline(ackTimeSeconds) {
230
+ // Start with the value we already have.
231
+ let ackDeadline = this.ackDeadline;
232
+ // If we got an ack time reading, update the histogram (and ackDeadline).
233
+ if (ackTimeSeconds) {
234
+ this._histogram.add(ackTimeSeconds);
235
+ ackDeadline = this._histogram.percentile(99);
236
+ }
237
+ // Grab our current min/max deadline values, based on whether exactly-once
238
+ // is enabled, and the defaults.
239
+ const [minDeadline, maxDeadline] = this.getMinMaxDeadlines();
240
+ if (minDeadline) {
241
+ ackDeadline = Math.max(ackDeadline, minDeadline.totalOf('second'));
242
+ }
243
+ if (maxDeadline) {
244
+ ackDeadline = Math.min(ackDeadline, maxDeadline.totalOf('second'));
245
+ }
246
+ // Set the bounded result back.
247
+ this.ackDeadline = ackDeadline;
248
+ }
249
+ getMinMaxDeadlines() {
250
+ var _a, _b;
251
+ // If this is an exactly-once subscription, and the user didn't set their
252
+ // own minimum ack periods, set it to the default for exactly-once.
253
+ const defaultMinDeadline = this.isExactlyOnce
254
+ ? minAckDeadlineForExactlyOnce
255
+ : default_options_1.defaultOptions.subscription.minAckDeadline;
256
+ const defaultMaxDeadline = default_options_1.defaultOptions.subscription.maxAckDeadline;
257
+ // Pull in any user-set min/max.
258
+ const minDeadline = (_a = this._options.minAckDeadline) !== null && _a !== void 0 ? _a : defaultMinDeadline;
259
+ const maxDeadline = (_b = this._options.maxAckDeadline) !== null && _b !== void 0 ? _b : defaultMaxDeadline;
260
+ return [minDeadline, maxDeadline];
261
+ }
262
+ /**
263
+ * Returns true if an exactly once subscription has been detected.
264
+ *
265
+ * @private
266
+ */
267
+ get isExactlyOnce() {
268
+ if (!this.subscriptionProperties) {
269
+ return false;
270
+ }
271
+ return !!this.subscriptionProperties.exactlyOnceDeliveryEnabled;
272
+ }
273
+ /**
274
+ * Sets our subscription properties from incoming messages.
229
275
  *
230
276
  * @param {SubscriptionProperties} subscriptionProperties The new properties.
231
277
  * @private
232
278
  */
233
279
  setSubscriptionProperties(subscriptionProperties) {
280
+ const previouslyEnabled = this.isExactlyOnce;
234
281
  this.subscriptionProperties = subscriptionProperties;
235
- // If this is an exactly-once subscription, warn the user that they may have difficulty.
282
+ // If this is an exactly-once subscription...
236
283
  if (this.subscriptionProperties.exactlyOnceDeliveryEnabled) {
284
+ // Warn the user that they may have difficulty.
237
285
  this._errorLog.doMaybe(() => console.error('WARNING: Exactly-once subscriptions are not yet supported ' +
238
286
  'by the Node client library. This feature will be added ' +
239
287
  'in a future release.'));
240
288
  }
289
+ // Update ackDeadline in case the flag switched.
290
+ if (previouslyEnabled !== this.isExactlyOnce) {
291
+ this.updateAckDeadline();
292
+ }
241
293
  }
242
294
  /**
243
295
  * The 99th percentile of request latencies.
@@ -274,11 +326,8 @@ class Subscriber extends events_1.EventEmitter {
274
326
  * @private
275
327
  */
276
328
  async ack(message) {
277
- if (!this._isUserSetDeadline) {
278
- const ackTimeSeconds = (Date.now() - message.received) / 1000;
279
- this._histogram.add(ackTimeSeconds);
280
- this.ackDeadline = this._histogram.percentile(99);
281
- }
329
+ const ackTimeSeconds = (Date.now() - message.received) / 1000;
330
+ this.updateAckDeadline(ackTimeSeconds);
282
331
  this._acks.add(message);
283
332
  await this._acks.onFlush();
284
333
  this._inventory.remove(message);
@@ -369,9 +418,13 @@ class Subscriber extends events_1.EventEmitter {
369
418
  setOptions(options) {
370
419
  this._options = options;
371
420
  this._useOpentelemetry = options.enableOpenTelemetryTracing || false;
372
- if (options.ackDeadline) {
373
- this.ackDeadline = options.ackDeadline;
374
- this._isUserSetDeadline = true;
421
+ // The user-set ackDeadline value basically pegs the extension time.
422
+ // We'll emulate it by overwriting min/max.
423
+ const passedAckDeadline = options.ackDeadline;
424
+ if (passedAckDeadline !== undefined) {
425
+ this.ackDeadline = passedAckDeadline;
426
+ options.minAckDeadline = temporal_1.Duration.from({ seconds: passedAckDeadline });
427
+ options.maxAckDeadline = temporal_1.Duration.from({ seconds: passedAckDeadline });
375
428
  }
376
429
  this.useLegacyFlowControl = options.useLegacyFlowControl || false;
377
430
  if (options.flowControl) {
@@ -1 +1 @@
1
- {"version":3,"file":"subscriber.js","sourceRoot":"","sources":["../../src/subscriber.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,6DAAmE;AACnE,yDAA+D;AAC/D,uDAAkD;AAClD,mCAAoC;AACpC,4CAA+D;AAC/D,8EAAuE;AAGvE,2CAAsC;AACtC,mDAAiE;AACjE,qDAAqE;AACrE,qDAAqE;AAErE,uDAAiD;AAEjD,mEAAmD;AACnD,iCAAiC;AAMjC;;;;;;GAMG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAa,OAAO;IAYlB;;;;;OAKG;IACH,YACE,GAAe,EACf,EAAC,KAAK,EAAE,OAAO,EAAE,eAAe,EAAoC;QAE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C,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;SACxC;QAED,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;CACF;AA5bD,gCA4bC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Simplified interface analogous to the tc39 Temporal.Duration
3
+ * parameter to from(). This doesn't support the full gamut (years, days).
4
+ */
5
+ export interface DurationLike {
6
+ hours?: number;
7
+ minutes?: number;
8
+ seconds?: number;
9
+ millis?: number;
10
+ }
11
+ /**
12
+ * Simplified list of values to pass to Duration.totalOf(). This
13
+ * list is taken from the tc39 Temporal.Duration proposal, but
14
+ * larger and smaller units have been left off.
15
+ */
16
+ export declare type TotalOfUnit = 'hour' | 'minute' | 'second' | 'millisecond';
17
+ /**
18
+ * Duration class with an interface similar to the tc39 Temporal
19
+ * proposal. Since it's not fully finalized, and polyfills have
20
+ * inconsistent compatibility, for now this shim class will be
21
+ * used to set durations in Pub/Sub.
22
+ *
23
+ * This class will remain here for at least the next major version,
24
+ * eventually to be replaced by the tc39 Temporal built-in.
25
+ *
26
+ * https://tc39.es/proposal-temporal/docs/duration.html
27
+ */
28
+ export declare class Duration {
29
+ private millis;
30
+ private static secondInMillis;
31
+ private static minuteInMillis;
32
+ private static hourInMillis;
33
+ private constructor();
34
+ /**
35
+ * Calculates the total number of units of type 'totalOf' that would
36
+ * fit inside this duration.
37
+ */
38
+ totalOf(totalOf: TotalOfUnit): number;
39
+ /**
40
+ * Creates a Duration from a DurationLike, which is an object
41
+ * containing zero or more of the following: hours, seconds,
42
+ * minutes, millis.
43
+ */
44
+ static from(durationLike: DurationLike): Duration;
45
+ }
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ // Copyright 2022 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.Duration = void 0;
17
+ /**
18
+ * Duration class with an interface similar to the tc39 Temporal
19
+ * proposal. Since it's not fully finalized, and polyfills have
20
+ * inconsistent compatibility, for now this shim class will be
21
+ * used to set durations in Pub/Sub.
22
+ *
23
+ * This class will remain here for at least the next major version,
24
+ * eventually to be replaced by the tc39 Temporal built-in.
25
+ *
26
+ * https://tc39.es/proposal-temporal/docs/duration.html
27
+ */
28
+ class Duration {
29
+ constructor(millis) {
30
+ this.millis = millis;
31
+ }
32
+ /**
33
+ * Calculates the total number of units of type 'totalOf' that would
34
+ * fit inside this duration.
35
+ */
36
+ totalOf(totalOf) {
37
+ switch (totalOf) {
38
+ case 'hour':
39
+ return this.millis / Duration.hourInMillis;
40
+ case 'minute':
41
+ return this.millis / Duration.minuteInMillis;
42
+ case 'second':
43
+ return this.millis / Duration.secondInMillis;
44
+ case 'millisecond':
45
+ return this.millis;
46
+ default:
47
+ throw new Error(`Invalid unit in call to totalOf(): ${totalOf}`);
48
+ }
49
+ }
50
+ /**
51
+ * Creates a Duration from a DurationLike, which is an object
52
+ * containing zero or more of the following: hours, seconds,
53
+ * minutes, millis.
54
+ */
55
+ static from(durationLike) {
56
+ var _a, _b, _c, _d;
57
+ let millis = (_a = durationLike.millis) !== null && _a !== void 0 ? _a : 0;
58
+ millis += ((_b = durationLike.seconds) !== null && _b !== void 0 ? _b : 0) * Duration.secondInMillis;
59
+ millis += ((_c = durationLike.minutes) !== null && _c !== void 0 ? _c : 0) * Duration.minuteInMillis;
60
+ millis += ((_d = durationLike.hours) !== null && _d !== void 0 ? _d : 0) * Duration.hourInMillis;
61
+ return new Duration(millis);
62
+ }
63
+ }
64
+ exports.Duration = Duration;
65
+ Duration.secondInMillis = 1000;
66
+ Duration.minuteInMillis = Duration.secondInMillis * 60;
67
+ Duration.hourInMillis = Duration.minuteInMillis * 60;
68
+ //# sourceMappingURL=temporal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"temporal.js","sourceRoot":"","sources":["../../src/temporal.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;AA6BjC;;;;;;;;;;GAUG;AACH,MAAa,QAAQ;IAOnB,YAAoB,MAAc;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,OAAoB;QAC1B,QAAQ,OAAO,EAAE;YACf,KAAK,MAAM;gBACT,OAAO,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,YAAY,CAAC;YAC7C,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,cAAc,CAAC;YAC/C,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,cAAc,CAAC;YAC/C,KAAK,aAAa;gBAChB,OAAO,IAAI,CAAC,MAAM,CAAC;YACrB;gBACE,MAAM,IAAI,KAAK,CAAC,sCAAsC,OAAO,EAAE,CAAC,CAAC;SACpE;IACH,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAAC,YAA0B;;QACpC,IAAI,MAAM,GAAG,MAAA,YAAY,CAAC,MAAM,mCAAI,CAAC,CAAC;QACtC,MAAM,IAAI,CAAC,MAAA,YAAY,CAAC,OAAO,mCAAI,CAAC,CAAC,GAAG,QAAQ,CAAC,cAAc,CAAC;QAChE,MAAM,IAAI,CAAC,MAAA,YAAY,CAAC,OAAO,mCAAI,CAAC,CAAC,GAAG,QAAQ,CAAC,cAAc,CAAC;QAChE,MAAM,IAAI,CAAC,MAAA,YAAY,CAAC,KAAK,mCAAI,CAAC,CAAC,GAAG,QAAQ,CAAC,YAAY,CAAC;QAE5D,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;;AA1CH,4BA2CC;AAxCgB,uBAAc,GAAG,IAAI,CAAC;AACtB,uBAAc,GAAG,QAAQ,CAAC,cAAc,GAAG,EAAE,CAAC;AAC9C,qBAAY,GAAG,QAAQ,CAAC,cAAc,GAAG,EAAE,CAAC"}
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
- import * as gax from 'google-gax';
3
- import { Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, IamClient, IamProtos } from 'google-gax';
2
+ import type * as gax from 'google-gax';
3
+ import type { Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, IamClient, IamProtos } from 'google-gax';
4
4
  import { Transform } from 'stream';
5
5
  import * as protos from '../../protos/protos';
6
6
  /**
@@ -35,7 +35,7 @@ export declare class PublisherClient {
35
35
  *
36
36
  * @param {object} [options] - The configuration object.
37
37
  * The options accepted by the constructor are described in detail
38
- * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
38
+ * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
39
39
  * The common options are:
40
40
  * @param {object} [options.credentials] - Credentials object.
41
41
  * @param {string} [options.credentials.client_email]
@@ -58,13 +58,19 @@ export declare class PublisherClient {
58
58
  * API remote host.
59
59
  * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
60
60
  * Follows the structure of {@link gapicConfig}.
61
- * @param {boolean} [options.fallback] - Use HTTP fallback mode.
62
- * In fallback mode, a special browser-compatible transport implementation is used
63
- * instead of gRPC transport. In browser context (if the `window` object is defined)
64
- * the fallback mode is enabled automatically; set `options.fallback` to `false`
65
- * if you need to override this behavior.
66
- */
67
- constructor(opts?: ClientOptions);
61
+ * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
62
+ * Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
63
+ * For more information, please check the
64
+ * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
65
+ * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
66
+ * need to avoid loading the default gRPC version and want to use the fallback
67
+ * HTTP implementation. Load only fallback version and pass it to the constructor:
68
+ * ```
69
+ * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
70
+ * const client = new PublisherClient({fallback: 'rest'}, gax);
71
+ * ```
72
+ */
73
+ constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);
68
74
  /**
69
75
  * Initialize the client.
70
76
  * Performs asynchronous operations (such as authentication) and prepares the client.