Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal to support different Redis client libraries #26

Open
nburwell opened this issue Jul 13, 2023 · 2 comments
Open

Proposal to support different Redis client libraries #26

nburwell opened this issue Jul 13, 2023 · 2 comments

Comments

@nburwell
Copy link
Contributor

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:

  • For backwards compatibility (since hiredis is the default driver), leave the redis_cluster gem name and gemspec as is - it would require redis and hiredis still.
  • Create a new gemspec in the same repo, called redis_cluster-core.gemspec and release a new gem to Rubygems: redis_cluster-core
    • This will not have any dependencies on redis libraries
  • Create new gems (nested folders in this repo, which could be moved to new repos eventually), of the following:
    • redis_cluster-redis-rb
    • redis_cluster-hiredis
    • redis_cluster-async-redis
  • Each of these gems would have a dependency to redis_cluster-core and to the specific redis gem, and would implement the RedisCluster::Node::Redis method
  • Consuming services would use the specific adapter gem in their Gemfile
  • This would be a good time to bump to version 1.0

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
Copy link
Owner

zhchsf commented Aug 13, 2023

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
Copy link
Contributor Author

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!

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

No branches or pull requests

2 participants