Conversation
Aryex
added this pull request to stack #313
September 14, 2026 16:27
Aryex
force-pushed
the
alexl/pubsub-part3-advanced-subs
branch
from
September 14, 2026 16:30
acf0b4b to
54437c8
Compare
Signed-off-by: Alex Le <alex.le@improving.com>
Aryex
force-pushed
the
alexl/pubsub-part3-advanced-subs
branch
from
September 14, 2026 22:00
54437c8 to
fdd9010
Compare
7 tasks
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.
Summary
This implement the advanced pubsub APIs per part 3 of the implementation plan.
Issue link
Related #135
Changes
The following APIs are added
psubscribe(*patterns, timeout_ms: 0)PSUBSCRIBE_BLOCKING(916)punsubscribe(*patterns, timeout_ms: 0)PUNSUBSCRIBE_BLOCKING(917)subscribe_lazy(*channels)SUBSCRIBE(911)unsubscribe_lazy(*channels)UNSUBSCRIBE(913)psubscribe_lazy(*patterns)PSUBSCRIBE(901)punsubscribe_lazy(*patterns)PUNSUBSCRIBE(908)Callback subscriptions is also added:
Limitations
publish(sharded: true)remainNotImplementedError(Part 4).get_subscriptions, the fivepubsub_*introspection commands, andpubsub(subcommand, *args)remainNotImplementedError(Part 5), so the lazy verbs' documented "read backget_subscriptionsto confirm" workflow is not yet available.validate_pubsub_callback!checksrespond_to?(:call)only. A callable that does not respond toaritypasses construction and then fails insidedeliver, where the blanket rescue drops every message silently.Testing
bundle exec rubocop— 124 files, no offenses.bundle exec rake test:unit— 402 tests, 873 assertions, 0 failures (up from 366; 36 new).test/unit/glide/pubsub_test.rb: 15 new dispatch tests. Request type, argument order and string coercion for all six verbs; timeout coercion for the blocking pair (default0→"0", fractional truncated, sub-millisecond →"1", negative →ArgumentError); a parametrized regression guard that the four lazy verbs send no timeout argument; empty-list behavior per verb. The existing RESP2/nil-protocol sweep was extended to cover all six.test/unit/glide/pubsub_receiver_test.rb(new): 21 tests driving the retainedffi_handlerproc directly with realFFI::MemoryPointerbuffers, so no server is needed. Queue mode unchanged; callback ordering; arity-1 vs arity-2 dispatch; a raising callback neither propagates nor kills the receiver;pop/try_popraise in callback mode;ffi_handlerobject identity retained; non-message push kinds dropped; embedded NUL preserved; and theArgumentErrorvalidation paths.bundle exec ruby -Itest -Ilib test/integration/standalone/valkey_test.rb— 216 tests, 13 failures, all pre-existinglib_name/client_info_tagassertions unrelated to Pub/Sub, identical to the base branch's baseline. No Pub/Sub test fails.Integration coverage is deliberately not in this PR. Nothing yet exercises
psubscribe→ publish →#pattern, the lazy verbs' eventual delivery, or callback mode against a live server.test/integration/valkey/pubsub_test.rbnow runs in both standalone and cluster (viaTestClusterPubSub), so those tests must be mode-safe; they will follow in a separate PR rather than being added unrun.bundle exec rake test:clusterhas not been run against this stack.Checklist
Before submitting the PR make sure the following are checked:
git commit -s) per the DCO.bundle exec rubocop) and pass.