Giter Club home page Giter Club logo

Comments (8)

ioolkos avatar ioolkos commented on September 25, 2024 1

@zuiderkwast I suppose the client always knows whether it's connecting to a standalone or a cluster. Your suggestion sounds great to me, in any case!

from ered.

ioolkos avatar ioolkos commented on September 25, 2024

@zuiderkwast is it possible to connect to a standalone node, with PR #41 ?

from ered.

zuiderkwast avatar zuiderkwast commented on September 25, 2024

Even without #41, it's possible to connect to a single node using the ered_client module. #41 does make things a little more clear though with functions like ered:connect_client for connecting to a single instance.

It's not possible to use a standalone instance as if it were a cluster though, with the same functions, but actually I don't think we want to do this automatically. Cluster and standalone deployments are very different. Standalone mode allows SELECT and cross-slot commands, for example, which are forbidden in cluster mode.

from ered.

ioolkos avatar ioolkos commented on September 25, 2024

@zuiderkwast Thanks a lot for your useful information! Currently we're using eredis in VerneMQ so we cannot connect to a Redis cluster yet. And ered's stated goal is to replace both previous libraries, isn't it. In any case, I'll try to do some testing based on your suggestions.

from ered.

zuiderkwast avatar zuiderkwast commented on September 25, 2024

Yes, ered implements the functionality for single instance and cluster, but the API has a preference for cluster. This was done before I was the maintainer of this project. Now, I've been trying to make the API look nice for single instance too.

An idea: We use a tuple like {cluster, Pid} or {standalone, Pid} as the ered instance reference, returned by ered:connect functions. Then we can use the same functions like ered:command/N for both of them and it can dispatch to the right module based on the tuple. That's future work, if you like the idea. (ssl:connect and gen_tcp:connect return tuples like this, so it's not that strange.)

I've been busy with other work though.

from ered.

ioolkos avatar ioolkos commented on September 25, 2024

I've now written my plugin using ered:start_link/2 as main entry point. As expected, this only works for a cluster, not a standalone (standalone gets the unmapped_slots error). A question, though: with the idea proposed above, will ered be able to figure out by itself whether it connects to a standalone or a cluster?

from ered.

zuiderkwast avatar zuiderkwast commented on September 25, 2024

A question, though: with the idea proposed above, will ered be able to figure out by itself whether it connects to a standalone or a cluster?

It would be possible to auto-detect, but I think it's better that users connect explicitly to cluster or standalone. I'm thinking ered:connect(Host, Port, Opts) for standalone and ered:connect_cluster(AddressesAndPorts, Opts) for cluster. After that, ered:command(EredRef, Command) and similar can be used for both kinds of instances.

from ered.

ioolkos avatar ioolkos commented on September 25, 2024

Sounds great. That interface is perfect at least for me, as the client (the plugin) always knows whether it connects to a cluster or not.
Let me know if I can test (or do anything helpful). No worry & no hurry for anyone :)
I think it'll be a cool library to use and like the unified approach in it.

from ered.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.