Skip to content

Commit

Permalink
Add enable_exactly_once_delivery to google_pubsub_subscription (G…
Browse files Browse the repository at this point in the history
…oogleCloudPlatform#5849)

Co-authored-by: upodroid <cy@borg.dev>
  • Loading branch information
upodroid authored and betsy-lichtenberg committed Apr 25, 2022
1 parent 6c681b1 commit 52c40a2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
17 changes: 15 additions & 2 deletions mmv1/products/pubsub/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ objects:
description: |
How long to retain unacknowledged messages in the subscription's
backlog, from the moment a message is published. If
retainAckedMessages is true, then this also configures the retention
retain_acked_messages is true, then this also configures the retention
of acknowledged messages, and thus configures how far back in time a
subscriptions.seek can be done. Defaults to 7 days. Cannot be more
than 7 days (`"604800s"`) or less than 10 minutes (`"600s"`).
Expand Down Expand Up @@ -350,6 +350,19 @@ objects:
If `true`, messages published with the same orderingKey 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.
- !ruby/object:Api::Type::Boolean
name: 'enableExactlyOnceDelivery'
input: true
description: |
If `true`, Pub/Sub provides the following guarantees for the delivery
of a message with a given value of messageId on this Subscriptions':
- The message sent to a subscriber is guaranteed not to be resent before the message's acknowledgement deadline expires.
- An acknowledged message will not be resent to a subscriber.

Note that subscribers may still receive multiple copies of a message when `enable_exactly_once_delivery`
is true if the message was published multiple times by a publisher client. These copies are considered distinct by Pub/Sub and have distinct messageId values
- !ruby/object:Api::Resource
name: 'Schema'
input: true
Expand Down Expand Up @@ -383,4 +396,4 @@ objects:
description: |
The definition of the schema.
This should contain a string representing the full definition of the schema
that is a valid schema definition of the type specified in type.
that is a valid schema definition of the type specified in type.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestAccPubsubSubscription_basic(t *testing.T) {
CheckDestroy: testAccCheckPubsubSubscriptionDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccPubsubSubscription_basic(topic, subscription, "bar", 20),
Config: testAccPubsubSubscription_basic(topic, subscription, "bar", 20, false),
},
{
ResourceName: "google_pubsub_subscription.foo",
Expand All @@ -68,7 +68,7 @@ func TestAccPubsubSubscription_update(t *testing.T) {
CheckDestroy: testAccCheckPubsubSubscriptionDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccPubsubSubscription_basic(topic, subscriptionShort, "bar", 20),
Config: testAccPubsubSubscription_basic(topic, subscriptionShort, "bar", 20, false),
},
{
ResourceName: "google_pubsub_subscription.foo",
Expand All @@ -77,7 +77,7 @@ func TestAccPubsubSubscription_update(t *testing.T) {
ImportStateVerify: true,
},
{
Config: testAccPubsubSubscription_basic(topic, subscriptionShort, "baz", 30),
Config: testAccPubsubSubscription_basic(topic, subscriptionShort, "baz", 30, true),
},
{
ResourceName: "google_pubsub_subscription.foo",
Expand Down Expand Up @@ -209,7 +209,7 @@ resource "google_pubsub_subscription" "foo" {
`, saAccount, topicFoo, subscription)
}

func testAccPubsubSubscription_basic(topic, subscription, label string, deadline int) string {
func testAccPubsubSubscription_basic(topic, subscription, label string, deadline int, exactlyOnceDelivery bool) string {
return fmt.Sprintf(`
resource "google_pubsub_topic" "foo" {
name = "%s"
Expand All @@ -226,8 +226,9 @@ resource "google_pubsub_subscription" "foo" {
minimum_backoff = "60.0s"
}
ack_deadline_seconds = %d
enable_exactly_once_delivery = %t
}
`, topic, subscription, label, deadline)
`, topic, subscription, label, deadline, exactlyOnceDelivery)
}

func testAccPubsubSubscription_topicOnly(topic string) string {
Expand Down

0 comments on commit 52c40a2

Please sign in to comment.