Skip to content

Commit 1dad07a

Browse files
authored
pubsub: clarify subscriber shutdown doc (#2487)
In the doc, we just wait for done.get() to return before closing the Subscriber. This commit makes clear that done.get() in the doc is an example condition. Updates #2485.
1 parent 540734e commit 1dad07a

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/SubscriberSnippets.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ public void failed(Subscriber.State from, Throwable failure) {
8282
subscriber.startAsync();
8383

8484
// Wait for a stop signal.
85+
// In a server, this might be a signal to stop serving.
86+
// In this example, the signal is just a dummy Future.
8587
done.get();
88+
8689
subscriber.stopAsync().awaitTerminated();
8790
}
8891

google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/Subscriber.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,10 @@ public FlowControlSettings getFlowControlSettings() {
222222
* subscriber.startAsync();
223223
*
224224
* // Wait for a stop signal.
225+
* // In a server, this might be a signal to stop serving.
226+
* // In this example, the signal is just a dummy Future.
225227
* done.get();
228+
*
226229
* subscriber.stopAsync().awaitTerminated();
227230
* }</pre>
228231
*/

0 commit comments

Comments
 (0)