feat(pubsub): implement streaming keep-alive logic - #34653
Open
torreypayne wants to merge 10 commits into
Open
Conversation
torreypayne
force-pushed
the
pubsub-streaming-keepalive
branch
2 times, most recently
from
June 23, 2026 04:52
cf5df9b to
b1acc8a
Compare
torreypayne
marked this pull request as ready for review
June 23, 2026 15:54
torreypayne
force-pushed
the
pubsub-streaming-keepalive
branch
2 times, most recently
from
June 23, 2026 17:29
94e9f14 to
ad59cd2
Compare
robertvoinescu-work
left a comment
There was a problem hiding this comment.
LGTM from a functional perspective. Just a few minor comments.
torreypayne
force-pushed
the
pubsub-streaming-keepalive
branch
2 times, most recently
from
June 26, 2026 20:41
ca925d3 to
e53a9bd
Compare
This comment was marked as resolved.
This comment was marked as resolved.
torreypayne
force-pushed
the
pubsub-streaming-keepalive
branch
from
June 30, 2026 15:53
26bcbb1 to
24055fd
Compare
This comment was marked as resolved.
This comment was marked as resolved.
aandreassa
requested changes
Jul 1, 2026
quartzmo
requested changes
Jul 1, 2026
torreypayne
force-pushed
the
pubsub-streaming-keepalive
branch
2 times, most recently
from
July 7, 2026 15:36
2fa07a4 to
cca4878
Compare
quartzmo
approved these changes
Jul 7, 2026
torreypayne
commented
Jul 7, 2026
quartzmo
approved these changes
Jul 8, 2026
torreypayne
commented
Jul 16, 2026
torreypayne
force-pushed
the
pubsub-streaming-keepalive
branch
2 times, most recently
from
July 16, 2026 18:43
43562dd to
f4927d5
Compare
aandreassa
requested changes
Jul 21, 2026
torreypayne
force-pushed
the
pubsub-streaming-keepalive
branch
3 times, most recently
from
July 22, 2026 21:53
5bdc0a7 to
d589b24
Compare
torreypayne
force-pushed
the
pubsub-streaming-keepalive
branch
2 times, most recently
from
July 23, 2026 20:57
4e59244 to
d998c4f
Compare
Implement bi-directional keep-alive pings and pong liveness monitoring for Cloud Pub/Sub StreamingPull streams in Ruby. - Set protocol_version = 1 in initial StreamingPullRequest to negotiate keep-alive support. - Extract KeepaliveMonitor collaborator class to manage keep-alive ping/pong timestamps, liveness checks, and timeout restarts cleanly. - Disable liveness monitor evaluation during reconnect backoff and handshake phases to prevent false-positive restarts. - Add unit, integration, and live acceptance test suites.
torreypayne
force-pushed
the
pubsub-streaming-keepalive
branch
from
July 23, 2026 21:19
346a70c to
3d9d3d1
Compare
aandreassa
requested changes
Jul 23, 2026
…undant check for '.is_a?(Stream)'
…st boilerplate and encapsulation
…or user context per PR feedback
…PR review feedback
torreypayne
commented
Jul 27, 2026
torreypayne
force-pushed
the
pubsub-streaming-keepalive
branch
3 times, most recently
from
July 27, 2026 23:35
b90712f to
509de9d
Compare
torreypayne
force-pushed
the
pubsub-streaming-keepalive
branch
from
July 27, 2026 23:36
509de9d to
1ad64d2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Implements proactive streaming keep-alive logic and connection health monitoring in
Google::Cloud::PubSub::MessageListener::Stream, mirroring the design implemented in the .NET Pub/Sub client (dotnet#15649).Long-running bi-directional gRPC streaming pull connections (
StreamingPull) can experience silent TCP drops, intermediary network timeouts, or read deadlocks during periods of low message volume. This change introduces background timer tasks to push regular keep-alive requests and actively monitor server Pong timestamps.Key Changes
protocol_version = 1on the initialStreamingPullRequestprotobuf to enable bi-directional stream keep-alive support.@stream_keepalive_task) to dispatch emptyStreamingPullRequestpings at regular intervals (default 30 seconds), regardless of current lease inventory volume.@pong_monitor_taskto inspect timestamps (@last_ping_at,@last_pong_at). If a keep-alive response is overdue by more thanpong_deadlineseconds (default 15 seconds), the monitor raisesRestartStreamto safely recycle the connection and back off.@last_ping_at = now if @last_pong_at >= @last_ping_at) to ensure consecutive un-ponged pings cannot overwrite the timestamp of an overdue request.Testing & Validation
keepalive_test.rb): Added targeted unit test coverage asserting protocol version flags, timer intervals, deadline timeouts, and non-disruptive Pong handling.helical-zone-771) across simulated TCP socket hangs, sub-millisecond deadline starvation, and post-recovery downstream message delivery.Fixes b/427319802