Skip to content

DOC-7168 Add a connect page for redis-rs (Rust) - #4231

Merged
andy-stark-redis merged 1 commit into
mainfrom
DOC-7168-rust
Oct 12, 2026
Merged

andy-stark-redis merged 1 commit into
mainfrom
DOC-7168-rust

Conversation

@andy-stark-redis

@andy-stark-redis andy-stark-redis commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Adds a connect page for redis-rs, the only Rust client page without one, and links it from rust/_index.md. Part of DOC-7168 (epic DOC-7164). The Ruby page is in a separate PR.

What's on the page

  • Basic connection, sync and async: an ACL user (with a URL or with RedisConnectionInfo), and a Unix socket
  • Redis Cluster, including routing reads to replicas
  • Redis Sentinel: separate credentials for the Sentinels and the data nodes, and connecting to a replica
  • TLS with rustls, including mutual TLS (client certificates)
  • Client-side caching (marked experimental, as upstream marks it)
  • Connection management: sharing a MultiplexedConnection, ConnectionManager, and r2d2 pools
  • Timeouts
  • Protocol selection
  • A link to the existing Entra ID page

redis-rs doesn't support smart client handoffs, so the page leaves them out.

How the examples were tested

All 29 code blocks were built and run against local servers:

  • a standalone server with an ACL user and a Unix socket
  • TLS servers with the client certificate optional, and with it required
  • a cluster of 3 primaries and 3 replicas
  • Sentinel

Each code block was built using only the Cargo.toml features shown next to it, which proves the feature lists are correct. The test copies differed from the page only in ports, hosts, passwords, certificate paths and key names.

Component Version
redis 1.7.1
rustls 0.23.45
tokio 1.53.2
r2d2 0.8.10
Rust 1.90.0
Redis 7.2.7

Please review these points

  • The 500 ms default timeout. Async connections time out after 500 ms by default. So a BLPOP that waits longer fails after about half a second. Later commands on the same connection, and on every copy of it, also time out until the server finishes the BLPOP. The page explains this and shows how to change the timeout.
  • Lost writes after a Sentinel failover. We forced two failovers. After each one, the client kept writing to the old primary until Sentinel turned it into a replica. The old primary then discarded those writes, even though the client had received a success reply for each one: 22 and 21 writes were lost. This matches the caveats added to the other clients' pages in DOC-7167 Add Redis Sentinel connection examples to client connect pages #4229.
  • The caching note. The "Redis v7.4 or later" note in the caching section is copied word for word from the other connect pages. The example itself ran on Redis 7.2.7.

Not changed

The existing Rust pages still pin redis = "1.0.4", while this page uses 1.7.1. Updating them is a follow-up.

🤖 Generated with Claude Code


Note

Low Risk
Documentation-only changes with no runtime or security logic; operational caveats are descriptive rather than altering product behavior.

Overview
Adds the missing Connect to the server doc for redis-rs and links it from the Rust client landing page so readers can find cluster, Sentinel, and TLS setup after the basic examples.

The new connect.md documents sync/async connections (URLs, ACL/RedisConnectionInfo, Unix sockets), Redis Cluster (including replica read routing), Sentinel (split credentials, master vs replica, and explicit failover caveats about stale connections and possible lost writes), TLS with rustls/mTLS, experimental client-side caching (RESP3/async only), connection management (MultiplexedConnection, ConnectionManager, r2d2), timeouts (including the default 500 ms async response timeout vs blocking commands like BLPOP), and RESP2/RESP3 selection. Examples pin redis = "1.7.1"; the landing page still references 1.0.4 (called out as follow-up).

Reviewed by Cursor Bugbot for commit e78a619. Bugbot is set up for automated code reviews on this repo. Configure here.

New rust/connect.md covering sync and async basic connections (ACL
user via URL and RedisConnectionInfo, Unix socket), cluster with replica
read routing, Sentinel, TLS and mutual TLS with rustls, client-side
caching, MultiplexedConnection sharing, ConnectionManager, r2d2 pools,
timeouts, and protocol selection. Linked from rust/_index.md; Entra ID
gets a one-line link to amr.md; smart client handoffs are left out.

All 29 code blocks were built and run against local servers. Each
block's crate used the page's own Cargo.toml lines verbatim, so the
feature lists are proven minimal-and-sufficient. Test copies differed
only in ports, hosts, passwords, cert paths and key names. Versions:
redis 1.7.1 (pinned --precise), rustls 0.23.45, tokio 1.53.2, r2d2
0.8.10, Rust 1.90.0, Redis 7.2.7.

Measured, not inferred: the 500 ms async response timeout fails BLPOP
at ~502 ms and keeps timing out later commands on that multiplexed
connection (and every clone) until the server finishes the block;
the Sentinel get_connection() connection lost 22 and 21 acknowledged
writes across a forced failover, since redis-rs never subscribes to
+switch-master; the rustls provider panic happens with zero or two
providers compiled in, so the mTLS example installs one explicitly.

Learned: redis-rs async connections time out after 500 ms by default, which breaks long blocking commands
Constraint: each Cargo.toml block lists exactly the features its snippet was built with; don't add features without rebuilding
Rejected: bb8 example | second pool crate for already-multiplexed connections; integration verified in source only
Rejected: #insecure and danger_accept_invalid_hostnames | need tls-rustls-insecure, and build_with_tls resets the hostname flag
Rejected: copying the upstream sentinel.rs rustdoc examples | one passes a URL as a host, one builds a replica client with master_for
Directive: the "Redis v7.4 or later" caching note is sibling-page house wording; caching actually ran on 7.2.7
Gaps: hostname-mismatch TLS not tested; deadpool-redis not covered; sync cluster caching not traced
Recheck: Sentinel failover caveat if redis-rs adds a +switch-master listener or a Sentinel ConnectionManager
Ticket: DOC-7168
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

DOC-7168

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Redis Memory

Found 5 related items from repository history (5 new this commit):

Memory updated at e78a619

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

@andy-stark-redis
andy-stark-redis requested a review from a team October 9, 2026 09:53
@andy-stark-redis andy-stark-redis self-assigned this Oct 9, 2026
@andy-stark-redis andy-stark-redis added the clients Client library docs label Oct 9, 2026
@andy-stark-redis
andy-stark-redis merged commit 8a08557 into main Oct 12, 2026
100 checks passed
@andy-stark-redis
andy-stark-redis deleted the DOC-7168-rust branch October 12, 2026 11:46
andy-stark-redis added a commit that referenced this pull request Oct 12, 2026
Adds a "Connect to Redis Sentinel" section after the cluster section on
the nine connect.md pages (H3 on Jedis to match its neighbors). hiredis
gets a short "not supported" section: v1.4.1 has no Sentinel code.
Ruby and Rust had no connect pages; their Sentinel sections shipped
with the new pages in DOC-7168 (#4230, #4231).

Every snippet ran against a local topology (primary, replica, three
Sentinels, mymaster, quorum 2) in two variants: no auth, and separate
data-node and Sentinel passwords. Test copies differed from the page snippets
only in ports, passwords, and key names. Versions run: redis-py
8.1.0 (GitHub tag source), go-redis v9.23.0, node-redis 6.3.0, ioredis
6.0.0, Jedis 8.0.2, Lettuce 7.8.0, StackExchange.Redis 3.0.0 (NuGet was
blocked; latest is 3.3.1), Predis 3.6.1.

The failover caveats are measured, not inferred. Under a forced
SENTINEL FAILOVER, redis-py, ioredis (default options), a Lettuce
RedisClient connection, Predis, and SE.Redis 3.0.0 kept writing to the
demoted primary for about 10 s, until Sentinel reconfigured it, and the
old primary discarded those acknowledged writes on resync (22 of about
60 in the measured runs). go-redis, node-redis, and Jedis subscribe to
+switch-master and moved within 1-2 s; ioredis with failoverDetector
cut loss to the inherent sub-second window. The .NET page deliberately
has no caveat: 3.3.1 adds an IsStalePrimaryView path that may close the
window, and 3.3.1 couldn't be run here (needs the .NET 10 SDK).

Surprises worth knowing before editing these sections: Jedis
RedisSentinelClient has no replica reads at all; Predis replica routing
is sticky until the first write and the parameters username leaks to
the Sentinels (hence username in each Sentinel URI); go-redis
ReplicaOnly sends writes to the replica too; redis-py sentinel_kwargs
stops socket_* inheritance.

Learned: five of the eight clients on these pages silently lose ~10 s of writes after a graceful Sentinel failover
Constraint: every snippet here is run-verified (some trimmed to fragments of the tested program); re-run any edit against a real Sentinel topology
Rejected: SE.Redis SentinelUser/SentinelPassword options | 3.1.13+, source-read only, never run; page uses SentinelConnect + GetSentinelMasterConnection, which ran on 3.0.0
Rejected: Jedis .serverDefaultProtocol() to silence the 8.x RESP3 WARN | method doesn't exist in 7.x
Directive: add the SE.Redis failover caveat only after testing 3.3.1 or later under a forced failover
Directive: link the go-redis and Lettuce Sentinel URL forms to connection-urls.md once DOC-7165 (#4228) merges
Gaps: no TLS to Sentinels tested on any client; no crash failover, only graceful SENTINEL FAILOVER; SE.Redis 3.3.1 never run
Recheck: SE.Redis credentials example when the .NET 10 SDK is available to run 3.3.1
Ticket: DOC-7167
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clients Client library docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants