Conversation
Aryex
added a commit
that referenced
this pull request
Sep 15, 2026
Signed-off-by: Alex Le <alex.le@improving.com>
Aryex
added this pull request to stack #313
September 15, 2026 16:03
Implement the sharded (cluster-mode) Pub/Sub verbs from Part 4 of the Pub/Sub plan (issue #135): - publish(message, channel, sharded: true) -> SPUBLISH; stays batchable inside pipelined/multi - ssubscribe / sunsubscribe (blocking) and ssubscribe_lazy / sunsubscribe_lazy (non-blocking) - connect-time pubsub: { subscriptions: { sharded: [...] } } The four sharded subscribe verbs and the sharded connection config are cluster-only and raise ArgumentError in standalone. publish(sharded: true) is left un-guarded so it stays batchable; glide-core rejects it in standalone. Adds the Valkey#cluster_mode? predicate, read as a method by the command mixin the same way validate_resp3! reads protocol. Signed-off-by: Alex Le <alex.le@improving.com>
Signed-off-by: Alex Le <alex.le@improving.com>
Aryex
force-pushed
the
alexl/pubsub-part4-cluster
branch
from
September 15, 2026 21:22
8a68a4d to
e334081
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.
Summary
Adds sharded (cluster-mode) Pub/Sub — Part 4 of the Pub/Sub implementation. This exposes the
SPUBLISH/SSUBSCRIBE/SUNSUBSCRIBEfamily so cluster clients can publish and subscribe on shard channels, plus a connect-timesharded:subscription option. Sharded messages are routed by the channel's slot, matching the other GLIDE clients.Issue link
Sub task of #135 Pub/Sub Support — Part 4 of the implementation plan.
Changes
Before, the sharded verbs were documented stubs raising
NotImplementedErrorandpublishrefusedsharded: true. After:publish(message, channel, sharded: true)dispatchesSPUBLISH(wire order<channel> <message>, Ruby signature(message, channel)). Left deliberately un-guarded and batchable — it works insidepipelined/multi, and glide-core rejects it in standalone.ssubscribe(*channels, timeout_ms:)/sunsubscribe(*channels, timeout_ms:)(blocking) andssubscribe_lazy(*channels)/sunsubscribe_lazy(*channels)(non-blocking). Same empty-list asymmetry as the exact verbs:ssubscribe/ssubscribe_lazyreject an empty list,sunsubscribe/sunsubscribe_lazywith no args target all sharded channels.pubsub: { subscriptions: { sharded: [...] } }.Valkey#cluster_mode?predicate.Cluster-mode enforcement (the one design decision): the four subscribe verbs and the connect-time sharded config are cluster-only and raise
ArgumentErrorin standalone. The guard is a privatevalidate_cluster_mode!readingcluster_mode?as a method — mirroring howvalidate_resp3!readsprotocol, keeping the mixin decoupled from client ivars.publish(sharded: true)is intentionally not guarded, so it stays batchable in a pipeline (acluster_mode?call there would break the batch); the core decides.Limitations
cluster_mode: trueand Valkey 7.0.0+.pubsub_shardchannels/pubsub_shardnumsub/get_subscriptionsintrospection is Part 5, not here.Testing
bundle exec rubocop— clean (126 files, no offenses).bundle exec rake test:unit— 417 tests, 0 failures (added ~30 sharded unit tests covering request type, arg order,to_scoercion, timeout parsing, the RESP3 sweep, empty-list rules, the cluster-mode guard, andpublish(sharded:)batchability).bundle exec rake test:standalone— sharded delivery tests skip; the standalone rejection tests (verbs + config) pass.bundle exec rake test:cluster— all 9 sharded integration tests pass, including a cross-slot routing test (distinct hash tags, provingSPUBLISHroutes by channel not subscriber node) and a batchable-pipeline test.Pre-existing, unrelated cluster-suite failures were observed and are not from this change (no Pub/Sub tests among them): the
lib_name/client_info_tagvalidation family (#246, stale native lib), TLS errors (TLS_CERT_DIRunset), and a flakycluster_bumpepochepoch-state assertion.Checklist
git commit -s) per the DCO.bundle exec rubocop) and pass.alexl/pubsub-part3-advanced-subs; retarget tomainafter Part 3 merges.)