Skip to content

[Task] Add read_only connection mode support for standalone clients #323

Description

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

  1. Add a read_only parameter to ValkeyGlide::connect() (optional, defaults to false).
  2. Add a read_only field to the standalone client configuration and constructor-params structs.
  3. Wire the config to protobuf field read_only = 26 on ConnectionRequest (standalone only).
  4. Validate incompatible combinations consistent with glide-core (e.g. read_only + AZ-affinity read_from strategies; read_only + DISCOVER_ALL).
  5. Add serialization tests (ConnectionRequestTest) asserting the protobuf field is set.
  6. Add integration tests, including the read_only + DISCOVER_ALL rejection case and replica-only read behavior.
  7. Update documentation (README + stub docblocks) and CHANGELOG.

Additional Notes

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions