Description
Expose the read_only connection option for standalone clients, matching the implementation already available in Java, Python, Node, Go, and C#.
read_only is a standalone connection mode (distinct from the read_from routing strategy). When enabled, the client:
- Skips primary-node detection during connection initialization, and
- Rejects write commands.
This is useful for connecting to replica-only deployments. It maps to protobuf field read_only = 26 on ConnectionRequest.
Note: read_only is mutually exclusive with NodeDiscoveryMode.DISCOVER_ALL (glide-core rejects the combination because DISCOVER_ALL requires the INFO REPLICATION call that read-only mode skips). Implementing read_only would also unblock porting the read_only + DISCOVER_ALL rejection test that was intentionally omitted in #322 (NodeDiscoveryMode) because PHP had no way to set the flag.
Checklist
- Add a
read_only parameter to ValkeyGlide::connect() (optional, defaults to false).
- Add a
read_only field to the standalone client configuration and constructor-params structs.
- Wire the config to protobuf field
read_only = 26 on ConnectionRequest (standalone only).
- Validate incompatible combinations consistent with glide-core (e.g.
read_only + AZ-affinity read_from strategies; read_only + DISCOVER_ALL).
- Add serialization tests (
ConnectionRequestTest) asserting the protobuf field is set.
- Add integration tests, including the
read_only + DISCOVER_ALL rejection case and replica-only read behavior.
- Update documentation (README + stub docblocks) and CHANGELOG.
Additional Notes
Description
Expose the
read_onlyconnection option for standalone clients, matching the implementation already available in Java, Python, Node, Go, and C#.read_onlyis a standalone connection mode (distinct from theread_fromrouting strategy). When enabled, the client:This is useful for connecting to replica-only deployments. It maps to protobuf field
read_only = 26onConnectionRequest.Note:
read_onlyis mutually exclusive withNodeDiscoveryMode.DISCOVER_ALL(glide-core rejects the combination becauseDISCOVER_ALLrequires theINFO REPLICATIONcall that read-only mode skips). Implementingread_onlywould also unblock porting theread_only+DISCOVER_ALLrejection test that was intentionally omitted in #322 (NodeDiscoveryMode) because PHP had no way to set the flag.Checklist
read_onlyparameter toValkeyGlide::connect()(optional, defaults tofalse).read_onlyfield to the standalone client configuration and constructor-params structs.read_only = 26onConnectionRequest(standalone only).read_only+ AZ-affinityread_fromstrategies;read_only+DISCOVER_ALL).ConnectionRequestTest) asserting the protobuf field is set.read_only+DISCOVER_ALLrejection case and replica-only read behavior.Additional Notes
ClientConfiguration.readOnly->request.ReadOnlyingo/config/config.go.NodeDiscoveryModedocs note it is "mutually exclusive with read-only mode".glide-core/src/client/standalone_client.rs(read-only mode is not compatible with ...).read_only.