Skip to content

feat: enhance RedisClusterTemplate for CI and hybrid environments#211

Merged
joshrotenberg merged 2 commits intomainfrom
feat/redis-cluster-enhancements
Jan 5, 2026
Merged

feat: enhance RedisClusterTemplate for CI and hybrid environments#211
joshrotenberg merged 2 commits intomainfrom
feat/redis-cluster-enhancements

Conversation

@joshrotenberg
Copy link
Copy Markdown
Owner

Summary

This PR adds features to improve RedisClusterTemplate usability in CI environments and hybrid local/CI setups, addressing issues #207, #208, #209, and #210.

Changes

RedisClusterConnection (#207)

  • Add new() constructor for direct node list creation without needing a template
  • Add with_password() for authenticated connections
  • Add nodes() getter for accessing the node list

Environment Configuration (#208)

  • Add from_env() to configure templates via environment variables:
    • REDIS_CLUSTER_PORT_BASE: Base port (default: 7000)
    • REDIS_CLUSTER_NUM_MASTERS: Number of masters (default: 3)
    • REDIS_CLUSTER_NUM_REPLICAS: Replicas per master (default: 0)
    • REDIS_CLUSTER_PASSWORD: Optional password
  • Add getter methods: get_port_base(), get_num_masters(), get_num_replicas()

Health Check Helpers (#209)

  • Add is_ready() to check if cluster state is "ok"
  • Add wait_until_ready(timeout) for polling until cluster is ready
  • Add TemplateError::Timeout variant for timeout errors

Hybrid Setup Support (#210)

  • Add detect_existing() to find running clusters at configured ports
  • Add start_or_detect(timeout) - uses existing cluster if available, otherwise starts new one

Usage Example

// Works in both CI (uses existing cluster) and local (starts new cluster)
let template = RedisClusterTemplate::from_env("test-cluster");
let conn = template.start_or_detect(Duration::from_secs(60)).await?;

println!("Cluster ready at: {}", conn.nodes_string());

Testing

  • All 760 unit tests pass
  • Added 5 new tests for the new functionality

Closes #207, #208, #209, #210

Add new features to improve usability in CI environments and hybrid local/CI setups:

RedisClusterConnection (#207):
- Add new() constructor for direct node list creation
- Add with_password() for authenticated connections
- Add nodes() getter for accessing node list

Environment configuration (#208):
- Add from_env() to configure templates via environment variables
- Supports REDIS_CLUSTER_PORT_BASE, REDIS_CLUSTER_NUM_MASTERS,
  REDIS_CLUSTER_NUM_REPLICAS, REDIS_CLUSTER_PASSWORD
- Add get_port_base(), get_num_masters(), get_num_replicas() getters

Health check helpers (#209):
- Add is_ready() to check if cluster state is ok
- Add wait_until_ready(timeout) for polling until ready
- Add TemplateError::Timeout variant for timeout errors

Hybrid setup support (#210):
- Add detect_existing() to find running clusters at configured ports
- Add start_or_detect(timeout) for best-of-both-worlds CI/local support

Closes #207, #208, #209, #210
@joshrotenberg joshrotenberg merged commit 81bb5a7 into main Jan 5, 2026
11 checks passed
@joshrotenberg joshrotenberg deleted the feat/redis-cluster-enhancements branch January 5, 2026 20:34
@github-actions github-actions Bot mentioned this pull request Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add RedisClusterConnection::new() constructor

1 participant