Skip to content

Dynamically create hash ring #25

Description

@klinquist

Assuming I have X servers for a given service - and I want all the parameters (vnodes, weight) to be the same, is there any way to just say...

var correct_server_number = ring.getresult(number_of_servers,"foo bar")

Right now I'm doing something that seems ridiculous, but it may be the most efficient way.. supports up to 10 servers...

var ring = [       new HashRing(["1"]),
             new HashRing(["1","2"])
             new HashRing(["1","2","3"])
             new HashRing(["1","2","3","4"])
             new HashRing(["1","2","3","4","5"])
             new HashRing(["1","2","3","4","5","6"])
             new HashRing(["1","2","3","4","5","6","7"])
             new HashRing(["1","2","3","4","5","6","7","8"])
             new HashRing(["1","2","3","4","5","6","7","8","9"])
             new HashRing(["1","2","3","4","5","6","7","8","9","10"])
           ]


var correct_server_number = ring[number_of_servers].get("foo bar");

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