@google-cloud/pubsub 2.18.1 → 2.18.2
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 +7 -0
- package/build/src/iam.d.ts +180 -0
- package/build/src/iam.js +2 -172
- package/build/src/iam.js.map +1 -1
- package/build/src/index.d.ts +12 -4
- package/build/src/index.js +12 -4
- package/build/src/index.js.map +1 -1
- package/build/src/publisher/flow-publisher.d.ts +6 -0
- package/build/src/publisher/flow-publisher.js +6 -0
- package/build/src/publisher/flow-publisher.js.map +1 -1
- package/build/src/publisher/index.d.ts +35 -0
- package/build/src/publisher/index.js +0 -35
- package/build/src/publisher/index.js.map +1 -1
- package/build/src/pubsub.d.ts +354 -4
- package/build/src/pubsub.js +28 -322
- package/build/src/pubsub.js.map +1 -1
- package/build/src/schema.d.ts +9 -4
- package/build/src/schema.js +9 -4
- package/build/src/schema.js.map +1 -1
- package/build/src/snapshot.d.ts +87 -0
- package/build/src/snapshot.js +2 -79
- package/build/src/snapshot.js.map +1 -1
- package/build/src/subscriber.d.ts +6 -0
- package/build/src/subscriber.js +6 -0
- package/build/src/subscriber.js.map +1 -1
- package/build/src/subscription.d.ts +439 -9
- package/build/src/subscription.js +24 -400
- package/build/src/subscription.js.map +1 -1
- package/build/src/topic.d.ts +466 -1
- package/build/src/topic.js +17 -417
- package/build/src/topic.js.map +1 -1
- package/build/src/v1/publisher_client.d.ts +262 -0
- package/build/src/v1/publisher_client.js +6 -244
- package/build/src/v1/publisher_client.js.map +1 -1
- package/build/src/v1/schema_service_client.d.ts +165 -0
- package/build/src/v1/schema_service_client.js +2 -153
- package/build/src/v1/schema_service_client.js.map +1 -1
- package/build/src/v1/subscriber_client.d.ts +566 -0
- package/build/src/v1/subscriber_client.js +6 -534
- package/build/src/v1/subscriber_client.js.map +1 -1
- package/package.json +2 -2
package/build/src/topic.d.ts
CHANGED
|
@@ -51,13 +51,17 @@ export declare type MessageOptions = PubsubMessage & {
|
|
|
51
51
|
* @param {PublishOptions} [options] Publisher configuration object.
|
|
52
52
|
*
|
|
53
53
|
* @example
|
|
54
|
+
* ```
|
|
54
55
|
* const {PubSub} = require('@google-cloud/pubsub');
|
|
55
56
|
* const pubsub = new PubSub();
|
|
56
57
|
*
|
|
57
58
|
* const topic = pubsub.topic('my-topic');
|
|
58
59
|
*
|
|
59
|
-
*
|
|
60
|
+
* ```
|
|
61
|
+
* @example To enable message ordering, set `enableMessageOrdering` to true. Please note that this does not persist to an actual topic.
|
|
62
|
+
* ```
|
|
60
63
|
* const topic = pubsub.topic('ordered-topic', {enableMessageOrdering: true});
|
|
64
|
+
* ```
|
|
61
65
|
*/
|
|
62
66
|
export declare class Topic {
|
|
63
67
|
name: string;
|
|
@@ -69,34 +73,440 @@ export declare class Topic {
|
|
|
69
73
|
publisher: Publisher;
|
|
70
74
|
getSubscriptionsStream: () => ObjectStream<Subscription>;
|
|
71
75
|
constructor(pubsub: PubSub, name: string, options?: PublishOptions);
|
|
76
|
+
/**
|
|
77
|
+
* Immediately sends all remaining queued data. This is mostly useful
|
|
78
|
+
* if you are planning to call close() on the PubSub object that holds
|
|
79
|
+
* the server connections.
|
|
80
|
+
*
|
|
81
|
+
* @param {EmptyCallback} [callback] Callback function.
|
|
82
|
+
* @returns {Promise<EmptyResponse>}
|
|
83
|
+
*/
|
|
72
84
|
flush(): Promise<void>;
|
|
73
85
|
flush(callback: EmptyCallback): void;
|
|
86
|
+
/**
|
|
87
|
+
* Create a topic.
|
|
88
|
+
*
|
|
89
|
+
* @param {object} [gaxOpts] Request configuration options, outlined
|
|
90
|
+
* here: https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html.
|
|
91
|
+
* @param {CreateTopicCallback} [callback] Callback function.
|
|
92
|
+
* @returns {Promise<CreateTopicResponse>}
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```
|
|
96
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
97
|
+
* const pubsub = new PubSub();
|
|
98
|
+
*
|
|
99
|
+
* const topic = pubsub.topic('my-topic');
|
|
100
|
+
*
|
|
101
|
+
* topic.create((err, topic, apiResponse) => {
|
|
102
|
+
* if (!err) {
|
|
103
|
+
* // The topic was created successfully.
|
|
104
|
+
* }
|
|
105
|
+
* });
|
|
106
|
+
*
|
|
107
|
+
* //-
|
|
108
|
+
* // If the callback is omitted, we'll return a Promise.
|
|
109
|
+
* //-
|
|
110
|
+
* topic.create().then((data) => {
|
|
111
|
+
* const topic = data[0];
|
|
112
|
+
* const apiResponse = data[1];
|
|
113
|
+
* });
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
74
116
|
create(gaxOpts?: CallOptions): Promise<CreateTopicResponse>;
|
|
75
117
|
create(callback: CreateTopicCallback): void;
|
|
76
118
|
create(gaxOpts: CallOptions, callback: CreateTopicCallback): void;
|
|
119
|
+
/**
|
|
120
|
+
* Create a subscription to this topic.
|
|
121
|
+
*
|
|
122
|
+
* @see [Subscriptions: create API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/create}
|
|
123
|
+
*
|
|
124
|
+
* @throws {Error} If subscription name is omitted.
|
|
125
|
+
*
|
|
126
|
+
* @param {string} name The name of the subscription.
|
|
127
|
+
* @param {CreateSubscriptionRequest} [options] See a
|
|
128
|
+
* [Subscription
|
|
129
|
+
* resource](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions).
|
|
130
|
+
* @param {CreateSubscriptionCallback} [callback] Callback function.
|
|
131
|
+
* @returns {Promise<CreateSubscriptionResponse>}
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```
|
|
135
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
136
|
+
* const pubsub = new PubSub();
|
|
137
|
+
*
|
|
138
|
+
* const topic = pubsub.topic('my-topic');
|
|
139
|
+
* const callback = function(err, subscription, apiResponse) {};
|
|
140
|
+
*
|
|
141
|
+
* // Without specifying any options.
|
|
142
|
+
* topic.createSubscription('newMessages', callback);
|
|
143
|
+
*
|
|
144
|
+
* // With options.
|
|
145
|
+
* topic.createSubscription('newMessages', {
|
|
146
|
+
* ackDeadlineSeconds: 90
|
|
147
|
+
* }, callback);
|
|
148
|
+
*
|
|
149
|
+
* //-
|
|
150
|
+
* // If the callback is omitted, we'll return a Promise.
|
|
151
|
+
* //-
|
|
152
|
+
* topic.createSubscription('newMessages').then((data) => {
|
|
153
|
+
* const subscription = data[0];
|
|
154
|
+
* const apiResponse = data[1];
|
|
155
|
+
* });
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
77
158
|
createSubscription(name: string, callback: CreateSubscriptionCallback): void;
|
|
78
159
|
createSubscription(name: string, options?: CreateSubscriptionOptions): Promise<CreateSubscriptionResponse>;
|
|
79
160
|
createSubscription(name: string, options: CreateSubscriptionOptions, callback: CreateSubscriptionCallback): void;
|
|
161
|
+
/**
|
|
162
|
+
* Delete the topic. This will not delete subscriptions to this topic.
|
|
163
|
+
*
|
|
164
|
+
* @see [Topics: delete API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/delete}
|
|
165
|
+
*
|
|
166
|
+
* @param {object} [gaxOpts] Request configuration options, outlined
|
|
167
|
+
* here: https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html.
|
|
168
|
+
* @param {function} [callback] The callback function.
|
|
169
|
+
* @param {?error} callback.err An error returned while making this
|
|
170
|
+
* request.
|
|
171
|
+
* @param {object} callback.apiResponse Raw API response.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```
|
|
175
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
176
|
+
* const pubsub = new PubSub();
|
|
177
|
+
*
|
|
178
|
+
* const topic = pubsub.topic('my-topic');
|
|
179
|
+
*
|
|
180
|
+
* topic.delete((err, apiResponse) => {});
|
|
181
|
+
*
|
|
182
|
+
* //-
|
|
183
|
+
* // If the callback is omitted, we'll return a Promise.
|
|
184
|
+
* //-
|
|
185
|
+
* topic.delete().then((data) => {
|
|
186
|
+
* const apiResponse = data[0];
|
|
187
|
+
* });
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
80
190
|
delete(callback: EmptyCallback): void;
|
|
81
191
|
delete(gaxOpts?: CallOptions): Promise<EmptyResponse>;
|
|
82
192
|
delete(gaxOpts: CallOptions, callback: EmptyCallback): void;
|
|
193
|
+
/**
|
|
194
|
+
* @typedef {array} TopicExistsResponse
|
|
195
|
+
* @property {boolean} 0 Whether the topic exists
|
|
196
|
+
*/
|
|
197
|
+
/**
|
|
198
|
+
* @callback TopicExistsCallback
|
|
199
|
+
* @param {?Error} err Request error, if any.
|
|
200
|
+
* @param {boolean} exists Whether the topic exists.
|
|
201
|
+
*/
|
|
202
|
+
/**
|
|
203
|
+
* Check if a topic exists.
|
|
204
|
+
*
|
|
205
|
+
* @param {TopicExistsCallback} [callback] Callback function.
|
|
206
|
+
* @returns {Promise<TopicExistsResponse>}
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```
|
|
210
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
211
|
+
* const pubsub = new PubSub();
|
|
212
|
+
*
|
|
213
|
+
* const topic = pubsub.topic('my-topic');
|
|
214
|
+
*
|
|
215
|
+
* topic.exists((err, exists) => {});
|
|
216
|
+
*
|
|
217
|
+
* //-
|
|
218
|
+
* // If the callback is omitted, we'll return a Promise.
|
|
219
|
+
* //-
|
|
220
|
+
* topic.exists().then((data) => {
|
|
221
|
+
* const exists = data[0];
|
|
222
|
+
* });
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
83
225
|
exists(): Promise<ExistsResponse>;
|
|
84
226
|
exists(callback: ExistsCallback): void;
|
|
227
|
+
/**
|
|
228
|
+
* @typedef {array} GetTopicResponse
|
|
229
|
+
* @property {Topic} 0 The {@link Topic}.
|
|
230
|
+
* @property {object} 1 The full API response.
|
|
231
|
+
*/
|
|
232
|
+
/**
|
|
233
|
+
* @callback GetTopicCallback
|
|
234
|
+
* @param {?Error} err Request error, if any.
|
|
235
|
+
* @param {Topic} topic The {@link Topic}.
|
|
236
|
+
* @param {object} apiResponse The full API response.
|
|
237
|
+
*/
|
|
238
|
+
/**
|
|
239
|
+
* Get a topic if it exists.
|
|
240
|
+
*
|
|
241
|
+
* @param {object} [gaxOpts] Request configuration options, outlined
|
|
242
|
+
* here: https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html.
|
|
243
|
+
* @param {boolean} [gaxOpts.autoCreate=false] Automatically create the topic
|
|
244
|
+
* does not already exist.
|
|
245
|
+
* @param {GetTopicCallback} [callback] Callback function.
|
|
246
|
+
* @returns {Promise<GetTopicResponse>}
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* ```
|
|
250
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
251
|
+
* const pubsub = new PubSub();
|
|
252
|
+
*
|
|
253
|
+
* const topic = pubsub.topic('my-topic');
|
|
254
|
+
*
|
|
255
|
+
* topic.get((err, topic, apiResponse) => {
|
|
256
|
+
* // The `topic` data has been populated.
|
|
257
|
+
* });
|
|
258
|
+
*
|
|
259
|
+
* //-
|
|
260
|
+
* // If the callback is omitted, we'll return a Promise.
|
|
261
|
+
* //-
|
|
262
|
+
* topic.get().then((data) => {
|
|
263
|
+
* const topic = data[0];
|
|
264
|
+
* const apiResponse = data[1];
|
|
265
|
+
* });
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
85
268
|
get(callback: GetTopicCallback): void;
|
|
86
269
|
get(gaxOpts?: GetTopicOptions): Promise<GetTopicResponse>;
|
|
87
270
|
get(gaxOpts: GetTopicOptions, callback: GetTopicCallback): void;
|
|
271
|
+
/**
|
|
272
|
+
* @typedef {array} GetTopicMetadataResponse
|
|
273
|
+
* @property {object} 0 The full API response.
|
|
274
|
+
*/
|
|
275
|
+
/**
|
|
276
|
+
* @callback GetTopicMetadataCallback
|
|
277
|
+
* @param {?Error} err Request error, if any.
|
|
278
|
+
* @param {object} apiResponse The full API response.
|
|
279
|
+
*/
|
|
280
|
+
/**
|
|
281
|
+
* Get the official representation of this topic from the API.
|
|
282
|
+
*
|
|
283
|
+
* @see [Topics: get API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/get}
|
|
284
|
+
*
|
|
285
|
+
* @param {object} [gaxOpts] Request configuration options, outlined
|
|
286
|
+
* here: https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html.
|
|
287
|
+
* @param {GetTopicMetadataCallback} [callback] Callback function.
|
|
288
|
+
* @returns {Promise<GetTopicMetadataResponse>}
|
|
289
|
+
*
|
|
290
|
+
* @example
|
|
291
|
+
* ```
|
|
292
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
293
|
+
* const pubsub = new PubSub();
|
|
294
|
+
*
|
|
295
|
+
* const topic = pubsub.topic('my-topic');
|
|
296
|
+
*
|
|
297
|
+
* topic.getMetadata((err, apiResponse) => {});
|
|
298
|
+
*
|
|
299
|
+
* //-
|
|
300
|
+
* // If the callback is omitted, we'll return a Promise.
|
|
301
|
+
* //-
|
|
302
|
+
* topic.getMetadata().then((data) => {
|
|
303
|
+
* const apiResponse = data[0];
|
|
304
|
+
* });
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
88
307
|
getMetadata(callback: GetTopicMetadataCallback): void;
|
|
89
308
|
getMetadata(gaxOpts: CallOptions, callback: GetTopicMetadataCallback): void;
|
|
90
309
|
getMetadata(gaxOpts?: CallOptions): Promise<GetTopicMetadataResponse>;
|
|
310
|
+
/**
|
|
311
|
+
* Get a list of the subscriptions registered to this topic. You may
|
|
312
|
+
* optionally provide a query object as the first argument to customize the
|
|
313
|
+
* response.
|
|
314
|
+
*
|
|
315
|
+
* Your provided callback will be invoked with an error object if an API error
|
|
316
|
+
* occurred or an array of {module:pubsub/subscription} objects.
|
|
317
|
+
*
|
|
318
|
+
* @see [Subscriptions: list API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics.subscriptions/list}
|
|
319
|
+
*
|
|
320
|
+
* @param {GetSubscriptionsRequest} [query] Query object for listing subscriptions.
|
|
321
|
+
* @param {GetSubscriptionsCallback} [callback] Callback function.
|
|
322
|
+
* @returns {Promise<GetSubscriptionsResponse>}
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```
|
|
326
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
327
|
+
* const pubsub = new PubSub();
|
|
328
|
+
*
|
|
329
|
+
* const topic = pubsub.topic('my-topic');
|
|
330
|
+
*
|
|
331
|
+
* topic.getSubscriptions((err, subscriptions) => {
|
|
332
|
+
* // subscriptions is an array of `Subscription` objects.
|
|
333
|
+
* });
|
|
334
|
+
*
|
|
335
|
+
* // Customize the query.
|
|
336
|
+
* topic.getSubscriptions({
|
|
337
|
+
* pageSize: 3
|
|
338
|
+
* }, callback);
|
|
339
|
+
*
|
|
340
|
+
* //-
|
|
341
|
+
* // If the callback is omitted, we'll return a Promise.
|
|
342
|
+
* //-
|
|
343
|
+
* topic.getSubscriptions().then((data) => {
|
|
344
|
+
* const subscriptions = data[0];
|
|
345
|
+
* });
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
91
348
|
getSubscriptions(callback: GetTopicSubscriptionsCallback): void;
|
|
92
349
|
getSubscriptions(options: PageOptions, callback: GetTopicSubscriptionsCallback): void;
|
|
93
350
|
getSubscriptions(options?: PageOptions): Promise<GetTopicSubscriptionsResponse>;
|
|
351
|
+
/**
|
|
352
|
+
* Publish the provided message.
|
|
353
|
+
*
|
|
354
|
+
* @deprecated Please use {@link Topic#publishMessage}.
|
|
355
|
+
*
|
|
356
|
+
* @throws {TypeError} If data is not a Buffer object.
|
|
357
|
+
* @throws {TypeError} If any value in `attributes` object is not a string.
|
|
358
|
+
*
|
|
359
|
+
* @param {buffer} data The message data. This must come in the form of a
|
|
360
|
+
* Buffer object.
|
|
361
|
+
* @param {object.<string, string>} [attributes] Attributes for this message.
|
|
362
|
+
* @param {PublishCallback} [callback] Callback function.
|
|
363
|
+
* @returns {Promise<PublishResponse>}
|
|
364
|
+
*
|
|
365
|
+
* @example
|
|
366
|
+
* ```
|
|
367
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
368
|
+
* const pubsub = new PubSub();
|
|
369
|
+
*
|
|
370
|
+
* const topic = pubsub.topic('my-topic');
|
|
371
|
+
* const data = Buffer.from('Hello, world!');
|
|
372
|
+
*
|
|
373
|
+
* const callback = (err, messageId) => {
|
|
374
|
+
* if (err) {
|
|
375
|
+
* // Error handling omitted.
|
|
376
|
+
* }
|
|
377
|
+
* };
|
|
378
|
+
*
|
|
379
|
+
* topic.publish(data, callback);
|
|
380
|
+
*
|
|
381
|
+
* ```
|
|
382
|
+
* @example Optionally you can provide an object containing attributes for the message. Note that all values in the object must be strings.
|
|
383
|
+
* ```
|
|
384
|
+
* const attributes = {
|
|
385
|
+
* key: 'value'
|
|
386
|
+
* };
|
|
387
|
+
*
|
|
388
|
+
* topic.publish(data, attributes, callback);
|
|
389
|
+
*
|
|
390
|
+
* ```
|
|
391
|
+
* @example If the callback is omitted, we'll return a Promise.
|
|
392
|
+
* ```
|
|
393
|
+
* topic.publish(data).then((messageId) => {});
|
|
394
|
+
* ```
|
|
395
|
+
*/
|
|
94
396
|
publish(data: Buffer, attributes?: Attributes): Promise<string>;
|
|
95
397
|
publish(data: Buffer, callback: PublishCallback): void;
|
|
96
398
|
publish(data: Buffer, attributes: Attributes, callback: PublishCallback): void;
|
|
399
|
+
/**
|
|
400
|
+
* Publish the provided JSON. It should be noted that all messages published
|
|
401
|
+
* are done so in the form of a Buffer. This is simply a convenience method
|
|
402
|
+
* that will transform JSON into a Buffer before publishing.
|
|
403
|
+
* {@link Subscription} objects will always return message data in the form of
|
|
404
|
+
* a Buffer, so any JSON published will require manual deserialization.
|
|
405
|
+
*
|
|
406
|
+
* @deprecated Please use the `json` option via {@link Topic#publishMessage}.
|
|
407
|
+
*
|
|
408
|
+
* @throws {Error} If non-object data is provided.
|
|
409
|
+
*
|
|
410
|
+
* @param {object} json The JSON data to publish.
|
|
411
|
+
* @param {object} [attributes] Attributes for this message.
|
|
412
|
+
* @param {PublishCallback} [callback] Callback function.
|
|
413
|
+
* @returns {Promise<PublishResponse>}
|
|
414
|
+
*
|
|
415
|
+
* @example
|
|
416
|
+
* ```
|
|
417
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
418
|
+
* const pubsub = new PubSub();
|
|
419
|
+
* const topic = pubsub.topic('my-topic');
|
|
420
|
+
*
|
|
421
|
+
* const data = {
|
|
422
|
+
* foo: 'bar'
|
|
423
|
+
* };
|
|
424
|
+
*
|
|
425
|
+
* const callback = (err, messageId) => {
|
|
426
|
+
* if (err) {
|
|
427
|
+
* // Error handling omitted.
|
|
428
|
+
* }
|
|
429
|
+
* };
|
|
430
|
+
*
|
|
431
|
+
* topic.publishJSON(data, callback);
|
|
432
|
+
*
|
|
433
|
+
* ```
|
|
434
|
+
* @example Optionally you can provide an object containing attributes for the message. Note that all values in the object must be strings.
|
|
435
|
+
* ```
|
|
436
|
+
* const attributes = {
|
|
437
|
+
* key: 'value'
|
|
438
|
+
* };
|
|
439
|
+
*
|
|
440
|
+
* topic.publishJSON(data, attributes, callback);
|
|
441
|
+
*
|
|
442
|
+
* ```
|
|
443
|
+
* @example If the callback is omitted, we'll return a Promise.
|
|
444
|
+
* ```
|
|
445
|
+
* topic.publishJSON(data).then((messageId) => {});
|
|
446
|
+
* ```
|
|
447
|
+
*/
|
|
97
448
|
publishJSON(json: object, attributes?: Attributes): Promise<string>;
|
|
98
449
|
publishJSON(json: object, callback: PublishCallback): void;
|
|
99
450
|
publishJSON(json: object, attributes: Attributes, callback: PublishCallback): void;
|
|
451
|
+
/**
|
|
452
|
+
* @typedef {object} MessageOptions
|
|
453
|
+
* @property {buffer} [data] The message data.
|
|
454
|
+
* @property {object} [json] Convenience property to publish JSON data. This
|
|
455
|
+
* will transform the provided JSON into a Buffer before publishing.
|
|
456
|
+
* {@link Subscription} objects will always return message data in the
|
|
457
|
+
* form of a Buffer, so any JSON published will require manual
|
|
458
|
+
* deserialization.
|
|
459
|
+
* @property {object.<string, string>} [attributes] Attributes for this
|
|
460
|
+
* message.
|
|
461
|
+
* @property {string} [orderingKey] A message ordering key.
|
|
462
|
+
*/
|
|
463
|
+
/**
|
|
464
|
+
* Publish the provided message.
|
|
465
|
+
*
|
|
466
|
+
* @throws {TypeError} If data is not a Buffer object.
|
|
467
|
+
* @throws {TypeError} If any value in `attributes` object is not a string.
|
|
468
|
+
*
|
|
469
|
+
* @param {MessageOptions} message Message object.
|
|
470
|
+
* @param {PublishCallback} [callback] Callback function.
|
|
471
|
+
* @returns {Promise<PublishResponse>}
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* ```
|
|
475
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
476
|
+
* const pubsub = new PubSub();
|
|
477
|
+
* const topic = pubsub.topic('my-topic');
|
|
478
|
+
*
|
|
479
|
+
* const data = Buffer.from('Hello, world!');
|
|
480
|
+
*
|
|
481
|
+
* const callback = (err, messageId) => {
|
|
482
|
+
* if (err) {
|
|
483
|
+
* // Error handling omitted.
|
|
484
|
+
* }
|
|
485
|
+
* };
|
|
486
|
+
*
|
|
487
|
+
* topic.publishMessage({data}, callback);
|
|
488
|
+
*
|
|
489
|
+
* ```
|
|
490
|
+
* @example Publish JSON message data.
|
|
491
|
+
* ```
|
|
492
|
+
* const json = {foo: 'bar'};
|
|
493
|
+
*
|
|
494
|
+
* topic.publishMessage({json}, callback);
|
|
495
|
+
*
|
|
496
|
+
* ```
|
|
497
|
+
* @example To publish messages in order (this is still experimental), make sure message ordering is enabled and provide an ordering key
|
|
498
|
+
* ```
|
|
499
|
+
* const topic = pubsub.topic('ordered-topic', {messageOrdering: true});
|
|
500
|
+
* const orderingKey = 'my-key';
|
|
501
|
+
*
|
|
502
|
+
* topic.publishMessage({data, orderingKey}, callback);
|
|
503
|
+
*
|
|
504
|
+
* ```
|
|
505
|
+
* @example If the callback is omitted, we'll return a Promise.
|
|
506
|
+
* ```
|
|
507
|
+
* const [messageId] = await topic.publishMessage({data});
|
|
508
|
+
* ```
|
|
509
|
+
*/
|
|
100
510
|
publishMessage(message: MessageOptions): Promise<[string]>;
|
|
101
511
|
publishMessage(message: MessageOptions, callback: PublishCallback): void;
|
|
102
512
|
/**
|
|
@@ -122,6 +532,7 @@ export declare class Topic {
|
|
|
122
532
|
* @param {string} orderingKey The ordering key in question.
|
|
123
533
|
*
|
|
124
534
|
* @example
|
|
535
|
+
* ```
|
|
125
536
|
* const {PubSub} = require('@google-cloud/pubsub');
|
|
126
537
|
* const pubsub = new PubSub();
|
|
127
538
|
* const topic = pubsub.topic('my-topic', {messageOrdering: true});
|
|
@@ -134,8 +545,56 @@ export declare class Topic {
|
|
|
134
545
|
* topic.resumePublishing(orderingKey);
|
|
135
546
|
* }
|
|
136
547
|
* });
|
|
548
|
+
* ```
|
|
137
549
|
*/
|
|
138
550
|
resumePublishing(orderingKey: string): void;
|
|
551
|
+
/**
|
|
552
|
+
* @typedef {array} SetTopicMetadataResponse
|
|
553
|
+
* @property {object} 0 The full API response.
|
|
554
|
+
*/
|
|
555
|
+
/**
|
|
556
|
+
* @callback SetTopicMetadataCallback
|
|
557
|
+
* @param {?Error} err Request error, if any.
|
|
558
|
+
* @param {object} apiResponse The full API response.
|
|
559
|
+
*/
|
|
560
|
+
/**
|
|
561
|
+
* Updates the topic.
|
|
562
|
+
*
|
|
563
|
+
* @see [UpdateTopicRequest API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#google.pubsub.v1.UpdateTopicRequest}
|
|
564
|
+
*
|
|
565
|
+
* @param {object} metadata The fields to update. This should be structured
|
|
566
|
+
* like a {@link
|
|
567
|
+
* https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics#Topic|Topic
|
|
568
|
+
* object}.
|
|
569
|
+
* @param {object} [gaxOpts] Request configuration options, outlined
|
|
570
|
+
* here: https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html.
|
|
571
|
+
* @param {SetTopicMetadataCallback} [callback] Callback function.
|
|
572
|
+
* @returns {Promise<SetTopicMetadataResponse>}
|
|
573
|
+
*
|
|
574
|
+
* @example
|
|
575
|
+
* ```
|
|
576
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
577
|
+
* const pubsub = new PubSub();
|
|
578
|
+
*
|
|
579
|
+
* const topic = pubsub.topic('my-topic');
|
|
580
|
+
* const metadata = {
|
|
581
|
+
* labels: {foo: 'bar'}
|
|
582
|
+
* };
|
|
583
|
+
*
|
|
584
|
+
* topic.setMetadata(metadata, err => {
|
|
585
|
+
* if (err) {
|
|
586
|
+
* // Error handling omitted.
|
|
587
|
+
* }
|
|
588
|
+
* });
|
|
589
|
+
*
|
|
590
|
+
* ```
|
|
591
|
+
* @example If the callback is omitted, we'll return a Promise.
|
|
592
|
+
* ```
|
|
593
|
+
* topic.setMetadata(metadata).then((data) => {
|
|
594
|
+
* const apiResponse = data[0];
|
|
595
|
+
* });
|
|
596
|
+
* ```
|
|
597
|
+
*/
|
|
139
598
|
setMetadata(options: TopicMetadata, gaxOpts?: CallOptions): Promise<SetTopicMetadataResponse>;
|
|
140
599
|
setMetadata(options: TopicMetadata, callback: SetTopicMetadataCallback): void;
|
|
141
600
|
setMetadata(options: TopicMetadata, gaxOpts: CallOptions, callback: SetTopicMetadataCallback): void;
|
|
@@ -145,6 +604,7 @@ export declare class Topic {
|
|
|
145
604
|
* @param {PublishOptions} options The publisher options.
|
|
146
605
|
*
|
|
147
606
|
* @example
|
|
607
|
+
* ```
|
|
148
608
|
* const {PubSub} = require('@google-cloud/pubsub');
|
|
149
609
|
* const pubsub = new PubSub();
|
|
150
610
|
*
|
|
@@ -155,6 +615,7 @@ export declare class Topic {
|
|
|
155
615
|
* maxMilliseconds: 10
|
|
156
616
|
* }
|
|
157
617
|
* });
|
|
618
|
+
* ```
|
|
158
619
|
*/
|
|
159
620
|
setPublishOptions(options: PublishOptions): void;
|
|
160
621
|
/**
|
|
@@ -162,6 +623,7 @@ export declare class Topic {
|
|
|
162
623
|
* back into {@link Topic#setPublishOptions}.
|
|
163
624
|
*
|
|
164
625
|
* @example
|
|
626
|
+
* ```
|
|
165
627
|
* const {PubSub} = require('@google-cloud/pubsub');
|
|
166
628
|
* const pubsub = new PubSub();
|
|
167
629
|
*
|
|
@@ -170,6 +632,7 @@ export declare class Topic {
|
|
|
170
632
|
* const defaults = topic.getPublishOptionDefaults();
|
|
171
633
|
* defaults.batching.maxMilliseconds = 10;
|
|
172
634
|
* topic.setPublishOptions(defaults);
|
|
635
|
+
* ```
|
|
173
636
|
*/
|
|
174
637
|
getPublishOptionDefaults(): PublishOptions;
|
|
175
638
|
/**
|
|
@@ -184,6 +647,7 @@ export declare class Topic {
|
|
|
184
647
|
* @return {Subscription}
|
|
185
648
|
*
|
|
186
649
|
* @example
|
|
650
|
+
* ```
|
|
187
651
|
* const {PubSub} = require('@google-cloud/pubsub');
|
|
188
652
|
* const pubsub = new PubSub();
|
|
189
653
|
*
|
|
@@ -199,6 +663,7 @@ export declare class Topic {
|
|
|
199
663
|
* // message.attributes = Attributes of the message.
|
|
200
664
|
* // message.publishTime = Timestamp when Pub/Sub received the message.
|
|
201
665
|
* });
|
|
666
|
+
* ```
|
|
202
667
|
*/
|
|
203
668
|
subscription(name: string, options?: SubscriptionOptions): Subscription;
|
|
204
669
|
/**
|