Skip to content

Commit

Permalink
feat(subscriber): ordered messages
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored and callmehiphop committed Mar 25, 2019
1 parent 468e1bf commit 1ae4719
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 5 deletions.
18 changes: 18 additions & 0 deletions protos/google/pubsub/v1/pubsub.proto
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,15 @@ message PubsubMessage {
// it receives the `Publish` call. It must not be populated by the
// publisher in a `Publish` call.
google.protobuf.Timestamp publish_time = 4;

// Identifies related messages for which publish order should be respected.
// If a `Subscription` has `enable_message_ordering` set to `true`, messages
// published with the same `ordering_key` value will be delivered to
// subscribers in the order in which they are received by the Pub/Sub system.
// <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
// API might be changed in backward-incompatible ways and is not recommended
// for production use. It is not subject to any SLA or deprecation policy.
string ordering_key = 5;
}

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

// If true, messages published with the same `ordering_key` in `PubsubMessage`
// will be delivered to the subscribers in the order in which they
// are received by the Pub/Sub system. Otherwise, they may be delivered in
// any order.
// <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
// API might be changed in backward-incompatible ways and is not recommended
// for production use. It is not subject to any SLA or deprecation policy.
bool enable_message_ordering = 10;

// A policy that specifies the conditions for this subscription's expiration.
// A subscription is considered active as long as any connected subscriber is
// successfully consuming messages from the subscription or is issuing
Expand Down
18 changes: 18 additions & 0 deletions src/v1/doc/google/pubsub/v1/doc_pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ const Topic = {
*
* This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp}
*
* @property {string} orderingKey
* Identifies related messages for which publish order should be respected.
* If a `Subscription` has `enable_message_ordering` set to `true`, messages
* published with the same `ordering_key` value will be delivered to
* subscribers in the order in which they are received by the Pub/Sub system.
* <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
* API might be changed in backward-incompatible ways and is not recommended
* for production use. It is not subject to any SLA or deprecation policy.
*
* @typedef PubsubMessage
* @memberof google.pubsub.v1
* @see [google.pubsub.v1.PubsubMessage definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/pubsub/v1/pubsub.proto}
Expand Down Expand Up @@ -403,6 +412,15 @@ const DeleteTopicRequest = {
* See <a href="https://cloud.google.com/pubsub/docs/labels"> Creating and
* managing labels</a>.
*
* @property {boolean} enableMessageOrdering
* If true, messages published with the same `ordering_key` in `PubsubMessage`
* will be delivered to the subscribers in the order in which they
* are received by the Pub/Sub system. Otherwise, they may be delivered in
* any order.
* <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
* API might be changed in backward-incompatible ways and is not recommended
* for production use. It is not subject to any SLA or deprecation policy.
*
* @property {Object} expirationPolicy
* A policy that specifies the conditions for this subscription's expiration.
* A subscription is considered active as long as any connected subscriber is
Expand Down
8 changes: 8 additions & 0 deletions src/v1/subscriber_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,14 @@ class SubscriberClient {
* @param {Object.<string, string>} [request.labels]
* See <a href="https://cloud.google.com/pubsub/docs/labels"> Creating and
* managing labels</a>.
* @param {boolean} [request.enableMessageOrdering]
* If true, messages published with the same `ordering_key` in `PubsubMessage`
* will be delivered to the subscribers in the order in which they
* are received by the Pub/Sub system. Otherwise, they may be delivered in
* any order.
* <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
* API might be changed in backward-incompatible ways and is not recommended
* for production use. It is not subject to any SLA or deprecation policy.
* @param {Object} [request.expirationPolicy]
* A policy that specifies the conditions for this subscription's expiration.
* A subscription is considered active as long as any connected subscriber is
Expand Down
10 changes: 5 additions & 5 deletions synth.metadata
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"updateTime": "2019-03-12T11:21:02.533632Z",
"updateTime": "2019-03-23T11:19:52.456128Z",
"sources": [
{
"generator": {
"name": "artman",
"version": "0.16.16",
"dockerImage": "googleapis/artman@sha256:30babbfce7f05a62b1892c63c575aa2c8c502eb4bcc8f3bb90ec83e955d5d319"
"version": "0.16.19",
"dockerImage": "googleapis/artman@sha256:70ba28fda87e032ae44e6df41b7fc342c1b0cce1ed90658c4890eb4f613038c2"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "abd1c9a99c5cd7179d8e5e0c8d4c8e761054cc78",
"internalRef": "237945492"
"sha": "e80435a132c53da26f46daf0787035ee63fb942b",
"internalRef": "239938670"
}
},
{
Expand Down
6 changes: 6 additions & 0 deletions test/gapic-v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,11 +673,13 @@ describe('SubscriberClient', () => {
const topic2 = 'topic2-1139259102';
const ackDeadlineSeconds = 2135351438;
const retainAckedMessages = false;
const enableMessageOrdering = true;
const expectedResponse = {
name: name2,
topic: topic2,
ackDeadlineSeconds: ackDeadlineSeconds,
retainAckedMessages: retainAckedMessages,
enableMessageOrdering: enableMessageOrdering,
};

// Mock Grpc layer
Expand Down Expand Up @@ -747,11 +749,13 @@ describe('SubscriberClient', () => {
const topic = 'topic110546223';
const ackDeadlineSeconds = 2135351438;
const retainAckedMessages = false;
const enableMessageOrdering = true;
const expectedResponse = {
name: name,
topic: topic,
ackDeadlineSeconds: ackDeadlineSeconds,
retainAckedMessages: retainAckedMessages,
enableMessageOrdering: enableMessageOrdering,
};

// Mock Grpc layer
Expand Down Expand Up @@ -825,11 +829,13 @@ describe('SubscriberClient', () => {
const topic = 'topic110546223';
const ackDeadlineSeconds2 = 921632575;
const retainAckedMessages = false;
const enableMessageOrdering = true;
const expectedResponse = {
name: name,
topic: topic,
ackDeadlineSeconds: ackDeadlineSeconds2,
retainAckedMessages: retainAckedMessages,
enableMessageOrdering: enableMessageOrdering,
};

// Mock Grpc layer
Expand Down

0 comments on commit 1ae4719

Please sign in to comment.