zhchsf / redis_cluster

A redis cluster ruby client gem
MIT License
20 stars 10 forks source link

Proposal to support different Redis client libraries #26

Open nburwell opened 1 year ago

nburwell commented 1 year ago

Hi,

We have appreciated using your gem for a few years now, to connect to our redis cluster. We are in the process of upgrading our Ruby application to use Async (new in Ruby 3) and Async Redis. The Async Redis client has the same interface and works as a mostly drop in replacement within this redis_cluster gem.

The only change we had to do was in initializing redis in the Node class:

module RedisCluster
  class Node
    def self.redis(options)
      # Async Redis requires host & port as a single endpoint argument
      async_client_options = options.dup
      host = async_client_options.delete(:host)
      port = async_client_options.delete(:port)

      endpoint = Async::IO::Endpoint.tcp(host, port)
      Async::Redis::Client.new(endpoint, **async_client_options)
    end
  end
end

We would like to continue using your gem, but also want to clean up our dependencies to avoid pulling in multiple redis libraries. Would you be open to a small refactor of this gem, where this gem becomes a combination of "core" functionality and then has multiple adapter gems that provide the concrete implementation (and dependency management) for a given redis client?

DelayedJob uses this pattern: https://github.com/collectiveidea/delayed_job/wiki/Backends as does DatabaseCleaner: https://github.com/DatabaseCleaner/database_cleaner#list-of-adapters and I think it would work well here.

Proposal:

Let me know your thoughts on the above. If this is a direction you are open to, we could submit a PR with the proposed changes.

zhchsf commented 1 year ago

sorry long times not login github and email.

Is it necessary to continue maintenance this gem? Official gem has supported cluster mode.

or you maintenance in your repo and continue your plan? And this repo's readme will introduce and link to you repo.

nburwell commented 1 year ago

We like the interface of this gem, and we like that it is agnostic to the redis driver itself. Since we are using Async now (and it has its own async-redis gem, which does not support cluster mode), we saw an opportunity to continue using / extending your gem.

If you do not have use for this gem and/or do not plan to maintain it any further, I'm open to this plan:

or you maintenance in your repo and continue your plan? And this repo's readme will introduce and link to you repo.

I can reach out again on this issue thread (or we could just create a PR?) when we have made progress on that and are ready to link to our repo. Thanks!