Skip to content

Commit 1ae4719

Browse files
yoshi-automationcallmehiphop
authored andcommitted
feat(subscriber): ordered messages
1 parent 468e1bf commit 1ae4719

File tree

5 files changed

+55
-5
lines changed

5 files changed

+55
-5
lines changed

protos/google/pubsub/v1/pubsub.proto

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,15 @@ message PubsubMessage {
406406
// it receives the `Publish` call. It must not be populated by the
407407
// publisher in a `Publish` call.
408408
google.protobuf.Timestamp publish_time = 4;
409+
410+
// Identifies related messages for which publish order should be respected.
411+
// If a `Subscription` has `enable_message_ordering` set to `true`, messages
412+
// published with the same `ordering_key` value will be delivered to
413+
// subscribers in the order in which they are received by the Pub/Sub system.
414+
// <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
415+
// API might be changed in backward-incompatible ways and is not recommended
416+
// for production use. It is not subject to any SLA or deprecation policy.
417+
string ordering_key = 5;
409418
}
410419

411420
// Request for the GetTopic method.
@@ -607,6 +616,15 @@ message Subscription {
607616
// managing labels</a>.
608617
map<string, string> labels = 9;
609618

619+
// If true, messages published with the same `ordering_key` in `PubsubMessage`
620+
// will be delivered to the subscribers in the order in which they
621+
// are received by the Pub/Sub system. Otherwise, they may be delivered in
622+
// any order.
623+
// <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
624+
// API might be changed in backward-incompatible ways and is not recommended
625+
// for production use. It is not subject to any SLA or deprecation policy.
626+
bool enable_message_ordering = 10;
627+
610628
// A policy that specifies the conditions for this subscription's expiration.
611629
// A subscription is considered active as long as any connected subscriber is
612630
// successfully consuming messages from the subscription or is issuing

src/v1/doc/google/pubsub/v1/doc_pubsub.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ const Topic = {
9595
*
9696
* This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp}
9797
*
98+
* @property {string} orderingKey
99+
* Identifies related messages for which publish order should be respected.
100+
* If a `Subscription` has `enable_message_ordering` set to `true`, messages
101+
* published with the same `ordering_key` value will be delivered to
102+
* subscribers in the order in which they are received by the Pub/Sub system.
103+
* <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
104+
* API might be changed in backward-incompatible ways and is not recommended
105+
* for production use. It is not subject to any SLA or deprecation policy.
106+
*
98107
* @typedef PubsubMessage
99108
* @memberof google.pubsub.v1
100109
* @see [google.pubsub.v1.PubsubMessage definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/pubsub/v1/pubsub.proto}
@@ -403,6 +412,15 @@ const DeleteTopicRequest = {
403412
* See <a href="https://cloud.google.com/pubsub/docs/labels"> Creating and
404413
* managing labels</a>.
405414
*
415+
* @property {boolean} enableMessageOrdering
416+
* If true, messages published with the same `ordering_key` in `PubsubMessage`
417+
* will be delivered to the subscribers in the order in which they
418+
* are received by the Pub/Sub system. Otherwise, they may be delivered in
419+
* any order.
420+
* <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
421+
* API might be changed in backward-incompatible ways and is not recommended
422+
* for production use. It is not subject to any SLA or deprecation policy.
423+
*
406424
* @property {Object} expirationPolicy
407425
* A policy that specifies the conditions for this subscription's expiration.
408426
* A subscription is considered active as long as any connected subscriber is

src/v1/subscriber_client.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,14 @@ class SubscriberClient {
364364
* @param {Object.<string, string>} [request.labels]
365365
* See <a href="https://cloud.google.com/pubsub/docs/labels"> Creating and
366366
* managing labels</a>.
367+
* @param {boolean} [request.enableMessageOrdering]
368+
* If true, messages published with the same `ordering_key` in `PubsubMessage`
369+
* will be delivered to the subscribers in the order in which they
370+
* are received by the Pub/Sub system. Otherwise, they may be delivered in
371+
* any order.
372+
* <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
373+
* API might be changed in backward-incompatible ways and is not recommended
374+
* for production use. It is not subject to any SLA or deprecation policy.
367375
* @param {Object} [request.expirationPolicy]
368376
* A policy that specifies the conditions for this subscription's expiration.
369377
* A subscription is considered active as long as any connected subscriber is

synth.metadata

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{
2-
"updateTime": "2019-03-12T11:21:02.533632Z",
2+
"updateTime": "2019-03-23T11:19:52.456128Z",
33
"sources": [
44
{
55
"generator": {
66
"name": "artman",
7-
"version": "0.16.16",
8-
"dockerImage": "googleapis/artman@sha256:30babbfce7f05a62b1892c63c575aa2c8c502eb4bcc8f3bb90ec83e955d5d319"
7+
"version": "0.16.19",
8+
"dockerImage": "googleapis/artman@sha256:70ba28fda87e032ae44e6df41b7fc342c1b0cce1ed90658c4890eb4f613038c2"
99
}
1010
},
1111
{
1212
"git": {
1313
"name": "googleapis",
1414
"remote": "https://github.com/googleapis/googleapis.git",
15-
"sha": "abd1c9a99c5cd7179d8e5e0c8d4c8e761054cc78",
16-
"internalRef": "237945492"
15+
"sha": "e80435a132c53da26f46daf0787035ee63fb942b",
16+
"internalRef": "239938670"
1717
}
1818
},
1919
{

test/gapic-v1.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,11 +673,13 @@ describe('SubscriberClient', () => {
673673
const topic2 = 'topic2-1139259102';
674674
const ackDeadlineSeconds = 2135351438;
675675
const retainAckedMessages = false;
676+
const enableMessageOrdering = true;
676677
const expectedResponse = {
677678
name: name2,
678679
topic: topic2,
679680
ackDeadlineSeconds: ackDeadlineSeconds,
680681
retainAckedMessages: retainAckedMessages,
682+
enableMessageOrdering: enableMessageOrdering,
681683
};
682684

683685
// Mock Grpc layer
@@ -747,11 +749,13 @@ describe('SubscriberClient', () => {
747749
const topic = 'topic110546223';
748750
const ackDeadlineSeconds = 2135351438;
749751
const retainAckedMessages = false;
752+
const enableMessageOrdering = true;
750753
const expectedResponse = {
751754
name: name,
752755
topic: topic,
753756
ackDeadlineSeconds: ackDeadlineSeconds,
754757
retainAckedMessages: retainAckedMessages,
758+
enableMessageOrdering: enableMessageOrdering,
755759
};
756760

757761
// Mock Grpc layer
@@ -825,11 +829,13 @@ describe('SubscriberClient', () => {
825829
const topic = 'topic110546223';
826830
const ackDeadlineSeconds2 = 921632575;
827831
const retainAckedMessages = false;
832+
const enableMessageOrdering = true;
828833
const expectedResponse = {
829834
name: name,
830835
topic: topic,
831836
ackDeadlineSeconds: ackDeadlineSeconds2,
832837
retainAckedMessages: retainAckedMessages,
838+
enableMessageOrdering: enableMessageOrdering,
833839
};
834840

835841
// Mock Grpc layer

0 commit comments

Comments
 (0)