SMOODEV-1892: Redis + NATS Backplane backends — cross-pod scale-out#9
Merged
Conversation
Two distributed Backplane impls behind the existing trait, as sibling adapter crates (mirroring adapters/postgres): RedisBackplane (Redis/Valkey pub/sub) and NatsBackplane (NATS subjects). Each wraps a per-pod InMemoryBackplane for local registry + delivery and adds a bus for cross-pod fan-out — publish() delivers to local sockets, then broadcasts a BackplaneEnvelope so every other pod re-resolves the Target against its own registry and delivers to its sockets (origin skips its echo). Same publish() now reaches a socket on any replica → horizontal scale-out and the cross-pod path for non-AI publishers. - lib: Target is Serialize/Deserialize; new shared BackplaneEnvelope wire type. - server: SMOOTH_AGENT_BACKPLANE (memory|redis|valkey|nats) + _URL selection in build_state_from_env_async; default stays single-process in-memory. - tests: cross-pod fan-out proven end-to-end over real Redis + NATS via testcontainers (skip without Docker, like the PG adapter). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 084e167 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
What
Two distributed
Backplaneimplementations behind the trait landed in #7, as sibling adapter crates (mirroringadapters/postgres):adapters/backplane-redis—RedisBackplaneover Redis/Valkey pub/subadapters/backplane-nats—NatsBackplaneover NATS subjectsEach wraps a per-pod
InMemoryBackplane(local registry + delivery) and adds a bus for cross-pod fan-out:publish(Target, event)delivers to local sockets immediately (the returned count), then broadcasts aBackplaneEnvelope; every other pod's subscriber re-resolves theTargetagainst its own registry and delivers to its sockets. The origin pod skips its own echo. This is the classic pub/sub fan-out shape — no shared connection registry, each pod authoritative for its own sockets.Why
The default
InMemoryBackplaneonly reaches sockets on the current process. This makes the samepublish()call reach a socket on any replica — required to run the WS service with >1 pod (horizontal scale-out) and the cross-pod path for non-AI publishers (job status, ingestion progress, notifications). Foundation: ADR-027 / epic SMOODEV-1887.Surface
Targetis nowSerialize/Deserialize; new sharedBackplaneEnvelopewire type so a host's own transport adapter can speak the same format. No runtime dep added to the lib.SMOOTH_AGENT_BACKPLANE(memory|redis/valkey|nats) +SMOOTH_AGENT_BACKPLANE_URLselection inbuild_state_from_env_async. Default stays single-process in-memory — no behavior change for existing deployments.Tests
Cross-pod fan-out proven end-to-end over real Redis and real NATS via testcontainers (two backplane instances = two pods; publish on pod A reaches a socket on pod B; origin pod doesn't double-deliver). Skips cleanly when Docker is unavailable, like the Postgres adapter. fmt + clippy clean (the 2 lib clippy warnings are pre-existing on main).
🤖 Generated with Claude Code