From 3c5c74896183690e99b2f9117408bea0f66529ce Mon Sep 17 00:00:00 2001 From: Blake Gentry Date: Thu, 24 Sep 2026 19:04:23 -0500 Subject: [PATCH] avoid retries in subscription example The subscription example leaves a failed job eligible for retry. When it runs again before shutdown, a second failure event stays buffered and breaks the expected output after the client stops. Limit that job to one attempt and expect its discarded state. The example now produces one failed-job event regardless of CI timing. --- example_subscription_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/example_subscription_test.go b/example_subscription_test.go index 1c548c684..52a042306 100644 --- a/example_subscription_test.go +++ b/example_subscription_test.go @@ -83,7 +83,8 @@ func Example_subscription() { if err != nil { panic(err) } - _, err = riverClient.Insert(ctx, SubscriptionArgs{Fail: true}, nil) + // Limit the failed job to one attempt so it produces one event. + _, err = riverClient.Insert(ctx, SubscriptionArgs{Fail: true}, &river.InsertOpts{MaxAttempts: 1}) if err != nil { panic(err) } @@ -124,7 +125,7 @@ func Example_subscription() { // Output: // Got job with state: completed - // Got job with state: available + // Got job with state: discarded // Got job with state: cancelled // Client stopped // Channel is closed