Giter Club home page Giter Club logo

go-ketama's People

Contributors

dgryski avatar graywolf avatar

Stargazers

Garret Buell avatar Marcin Bielak avatar Arjun Sunil Kumar avatar Kevin Park avatar  avatar Gurpreet Singh avatar thisChris avatar Dmytro Momot avatar Onyx Gouws avatar Blain Smith avatar Douglas Camata avatar Kemal Akkoyun avatar subhasis maity avatar GuokeCui avatar Jeremy avatar leoluk avatar  avatar nbboy avatar Aki·Peroro avatar  avatar lin avatar  avatar Oliver Eilhard avatar Sem avatar Shenjun Ma avatar  avatar  avatar Yegor Lukash avatar vpromzelev avatar Abhijeet Rastogi avatar Nozomi Morimoto avatar Adam Zell avatar  avatar Christian Muehlhaeuser avatar Omer Katz avatar Kevin avatar  avatar  avatar Julian avatar Chen Chenglong avatar Rob Zienert avatar  avatar 蝙蝠侠 avatar Burak Sezer avatar nicerobot avatar Teodor Pripoae avatar Florian Schlachter avatar pseudocodes avatar Brant Fitzsimmons avatar molon avatar Michii Shunsuke avatar Angus H. avatar 达达 avatar Andy Walker avatar Timesking avatar metakeule avatar Fan Yang avatar Aleksander Ermolaev avatar Pavel <Ven> Gulbin avatar  avatar Mordy Ovits avatar Zack Owens avatar Matt Croydon avatar lestrrat avatar  avatar

Watchers

James Cloos avatar  avatar  avatar  avatar

go-ketama's Issues

Negative weight is accepted

It is possible to create a bucket with negative weight leading to this module not mapping anything:

package main

import (
        "fmt"

        "github.com/dgryski/go-ketama"
)

func main() {
        var buckets []ketama.Bucket

        buckets = append(buckets, ketama.Bucket{"127.0.0.1", -300})
        buckets = append(buckets, ketama.Bucket{"127.0.0.1:11212", 200})
        buckets = append(buckets, ketama.Bucket{"127.0.0.1:11213", 100})

        fmt.Println(buckets)

        c, _ := ketama.New(buckets)

        tests := []string{
                "thing1",
                "thing2",
                "thing3",
                "thing4",
                "thing5",
                "thing6",
                "thing7",
                "thing8",
                "thing9",
                "thing0",
                "thinga",
                "thingb",
                "thingc",
                "thingd",
        }
        for _, test := range tests {
                fmt.Printf("%q -> %q\n", test, c.Hash(test))
        }
}

when executed:

+   $ go run git.sr.ht/~graywolf/gomemcache/foo
[{127.0.0.1 -300} {127.0.0.1:11212 200} {127.0.0.1:11213 100}]
"thing1" -> ""
"thing2" -> ""
"thing3" -> ""
"thing4" -> ""
"thing5" -> ""
"thing6" -> ""
"thing7" -> ""
"thing8" -> ""
"thing9" -> ""
"thing0" -> ""
"thinga" -> ""
"thingb" -> ""
"thingc" -> ""
"thingd" -> ""

Since weight <= 0 does not really make sense, I would propose New() to return an error if such a weight is provided. If you agree I can prepare a patch.

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.