Skip to content

Commit 78c178b

Browse files
authored
docs(pubsub): update allowed message retention duration by server (#8559)
1 parent 1cf8cf1 commit 78c178b

File tree

2 files changed

+45
-46
lines changed

2 files changed

+45
-46
lines changed

pubsub/integration_test.go

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,55 +1968,54 @@ func TestIntegration_TopicRetention(t *testing.T) {
19681968
c := integrationTestClient(ctx, t)
19691969
defer c.Close()
19701970

1971-
testutil.Retry(t, 5, 1*time.Second, func(r *testutil.R) {
1972-
tc := TopicConfig{
1973-
RetentionDuration: 50 * time.Minute,
1974-
}
1975-
topic, err := createTopicWithRetry(ctx, t, c, topicIDs.New(), &tc)
1976-
if err != nil {
1977-
r.Errorf("failed to create topic: %v", err)
1978-
}
1979-
defer topic.Delete(ctx)
1980-
defer topic.Stop()
1971+
tc := TopicConfig{
1972+
RetentionDuration: 31 * 24 * time.Hour, // max retention duration
1973+
}
19811974

1982-
newDur := 11 * time.Minute
1983-
cfg, err := topic.Update(ctx, TopicConfigToUpdate{
1984-
RetentionDuration: newDur,
1985-
})
1986-
if err != nil {
1987-
r.Errorf("failed to update topic: %v", err)
1988-
}
1989-
if got := cfg.RetentionDuration; got != newDur {
1990-
r.Errorf("cfg.RetentionDuration, got: %v, want: %v", got, newDur)
1991-
}
1975+
topic, err := createTopicWithRetry(ctx, t, c, topicIDs.New(), &tc)
1976+
if err != nil {
1977+
t.Fatalf("failed to create topic: %v", err)
1978+
}
1979+
defer topic.Delete(ctx)
1980+
defer topic.Stop()
19921981

1993-
// Create a subscription on the topic and read TopicMessageRetentionDuration.
1994-
s, err := createSubWithRetry(ctx, t, c, subIDs.New(), SubscriptionConfig{
1995-
Topic: topic,
1996-
})
1997-
if err != nil {
1998-
r.Errorf("failed to create subscription: %v", err)
1999-
}
2000-
defer s.Delete(ctx)
2001-
sCfg, err := s.Config(ctx)
2002-
if err != nil {
2003-
r.Errorf("failed to get sub config: %v", err)
2004-
}
2005-
if got := sCfg.TopicMessageRetentionDuration; got != newDur {
2006-
r.Errorf("sCfg.TopicMessageRetentionDuration, got: %v, want: %v", got, newDur)
2007-
}
1982+
newDur := 11 * time.Minute
1983+
cfg, err := topic.Update(ctx, TopicConfigToUpdate{
1984+
RetentionDuration: newDur,
1985+
})
1986+
if err != nil {
1987+
t.Fatalf("failed to update topic: %v", err)
1988+
}
1989+
if got := cfg.RetentionDuration; got != newDur {
1990+
t.Fatalf("cfg.RetentionDuration, got: %v, want: %v", got, newDur)
1991+
}
20081992

2009-
// Clear retention duration by setting to a negative value.
2010-
cfg, err = topic.Update(ctx, TopicConfigToUpdate{
2011-
RetentionDuration: -1 * time.Minute,
2012-
})
2013-
if err != nil {
2014-
t.Fatal(err)
2015-
}
2016-
if got := cfg.RetentionDuration; got != nil {
2017-
t.Fatalf("expected cleared retention duration, got: %v", got)
2018-
}
1993+
// Create a subscription on the topic and read TopicMessageRetentionDuration.
1994+
s, err := createSubWithRetry(ctx, t, c, subIDs.New(), SubscriptionConfig{
1995+
Topic: topic,
1996+
})
1997+
if err != nil {
1998+
t.Fatalf("failed to create subscription: %v", err)
1999+
}
2000+
defer s.Delete(ctx)
2001+
sCfg, err := s.Config(ctx)
2002+
if err != nil {
2003+
t.Fatalf("failed to get sub config: %v", err)
2004+
}
2005+
if got := sCfg.TopicMessageRetentionDuration; got != newDur {
2006+
t.Fatalf("sCfg.TopicMessageRetentionDuration, got: %v, want: %v", got, newDur)
2007+
}
2008+
2009+
// Clear retention duration by setting to a negative value.
2010+
cfg, err = topic.Update(ctx, TopicConfigToUpdate{
2011+
RetentionDuration: -1 * time.Minute,
20192012
})
2013+
if err != nil {
2014+
t.Fatal(err)
2015+
}
2016+
if got := cfg.RetentionDuration; got != nil {
2017+
t.Fatalf("expected cleared retention duration, got: %v", got)
2018+
}
20202019
}
20212020

20222021
func TestIntegration_ExactlyOnceDelivery_PublishReceive(t *testing.T) {

pubsub/topic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ type TopicConfig struct {
228228
// timestamp](https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time)
229229
// that is up to `RetentionDuration` in the past. If this field is
230230
// not set, message retention is controlled by settings on individual
231-
// subscriptions. Cannot be more than 7 days or less than 10 minutes.
231+
// subscriptions. Cannot be more than 31 days or less than 10 minutes.
232232
//
233233
// For more information, see https://cloud.google.com/pubsub/docs/replay-overview#topic_message_retention.
234234
RetentionDuration optional.Duration

0 commit comments

Comments
 (0)