Skip to content

Add support for reading from replicas in non-CLUSTER environments #8

Open
@jgaskins

Description

@jgaskins

I think we can handle this by accepting a list of URIs in Client#initialize and assigning them at random in the connection pool block.

Thinking something like this:

    # Keep this method signature for backwards-compatibility
    def self.new(uri : URI)
      max_idle_pool_size = uri.query_params.fetch("max_idle_pool_size", "25").to_i
      new([uri], max_idle_pool_size)
    end

    def initialize(uris : Array(URI) = [URI.parse("redis:///")], max_idle_pool_size : Int = 25)
      @pool = DB::Pool.new(
        max_idle_pool_size: max_idle_pool_size.to_i32,
      ) { Connection.new(uris.sample) }
    end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions