stathat / consistent Goto Github PK
View Code? Open in Web Editor NEWConsistent hash package for Go.
License: MIT License
Consistent hash package for Go.
License: MIT License
https://github.com/stathat/consistent/blob/master/consistent.go#L239
I don't see any difference when the 'if' statement is absence.
Lines 161 to 164 in 30ea17e
seems like i
is never greater than len(c.sortedHashes)
i = sort.Search(len(c.sortedHashes), f)
if i == len(c.sortedHashes) {
i = 0
}
Get https://stathat.com/c/consistent?go-get=1: x509: certificate has expired or is not yet valid
Please see strava/go.serversets#7 for more details. That library uses a vendored version of this consistent hash library. What I'm seeing is a distribution like:
58856 - 10.0.16.69:11211
18389 - 10.0.22.188:11211
22755 - 10.0.26.214:11211
(count - server for 10k random strings)
This uneven distribution is what we're seeing in production so I don't think it's an issue with the random key generation. Have you guys encountered this before? Am I using the code wrong?
I failed go get stathat.com/c/consistent.
Do you have a problem about this?
i can not find the meaning of reallocating and what is the judgement about.
Can someone explain it?
//reallocate if we're holding on to too much (1/4th)
if cap(c.sortedHashes)/(c.NumberOfReplicas*4) > len(c.circle) {
hashes = nil
}
Hi patrickxb
I guess your SSL certificate is expired ?
Today I try to update consistent package and go the error below ~
Fetching https://stathat.com/c/consistent?go-get=1
https fetch failed: Get https://stathat.com/c/consistent?go-get=1: x509: certificate has expired or is not yet valid
Thank you
I have a confuse that Line 265 in consistent.go.
//reallocate if we're holding on to too much (1/4th)
if cap(c.sortedHashes)/(c.NumberOfReplicas*4) > len(c.circle) {
hashes = nil
}
You stated that it is 1/4, how about this bellow.
if cap(c.sortedHashes)/4 > len(c.circle) {
hashes = nil
}
$ go get -v -d stathat.com/c/consistent
Fetching https://stathat.com/c/consistent?go-get=1
https fetch failed.
import "stathat.com/c/consistent": https fetch: Get https://stathat.com/c/consistent?go-get=1: dial tcp 50.17.204.11:443: getsockopt: connection refused
package stathat.com/c/consistent: unrecognized import path "stathat.com/c/consistent"
If add or remove method called.
it updates the members map and the cycle map by the node names, buy count filed increase or decrease every times.
if add or remove called multi times for a same node, the count value is incorrect.
i think we should take crc32 hash value conflict in add function, as shown in
// need c.Lock() before calling
func (c *Consistent) add(elt string) {
for i := 0; i < c.NumberOfReplicas; i++ {
c.circle[c.hashKey(c.eltKey(elt, i))] = elt
}
c.members[elt] = true
c.updateSortedHashes()
c.count++
}
the c.hashKey(c.eltKey(elt, i))
may return a conflict, i.e., a duplicate crc32 hash value and in such a situation we can not guarantee that we can have specified NumberOfReplicas for each node.
For more info, an example can be get in carbon
def add_node(self, node):
self.nodes.add(node)
for i in range(self.replica_count):
replica_key = "%s:%d" % (node, i)
position = self.compute_ring_position(replica_key)
while position in [r[0] for r in self.ring]:
position = position + 1
entry = (position, node)
bisect.insort(self.ring, entry)
Hi! I got this error when I tried to go get. Would you mind taking a look?
package stathat.com/c/consistent: unrecognised import path "stathat.com/c/consistent" (https fetch: Get https://stathat.com/c/consistent?go-get=1: x509: certificate has expired or is not yet valid)```
Hi, please adding go.mod and release a version at your convenience.
Please instead of “Look at godoc” provide a link to hosted package documentation in the README.
http://godoc.org/github.com/stathat/consistent
This would allow people to check out the examples as well as documentation without the necessity of a running go environment and cloning the library, then opening their local godoc.
The cert for https://stathat.com/ has expired, so go get stathat.com/c/consistent
fails.
First I cannot get your package when I turn on my proxy in http://www.stathat.com/c/consistent
It get 500 Error
if I turn off proxy , I can get your package,but I cannot get other important dependency
I don't know why you put the import path not from github
whatever it sucks
When I only have 2 elements, but execute Add 3 times, at this time c.count == 3, after that GetN(3) is executed, if start == 0, then the for loop will fall into an infinite loop, because i can never Return to 0, which means that the exit condition of start != i cannot be met, because the minimum value of i is 1, and len(res) is 2, which is always less than n, and the loop cannot exit.
This issue came up earlier #24
Seems like the https certificate expired again. I tried the following command as suggested in the previous issue but get the same error
$: go get github.com/stathat/consistent@master
go: stathat.com/c/[email protected]: unrecognized import path "stathat.com/c/consistent" (https fetch: Get https://stathat.com/c/consistent?go-get=1: x509: certificate has expired or is not yet valid)
go: error loading module requirements
A hash collision is possible at /consistent.go#L76. That means the consistency of results is dependent on the order of Add() calls.
I think the easiest fix is to get rid of Consistent.circle altogether and just use .sortedHashes to keep something like struct {hash uint32, key string}.
search() would have to be updated to compare not just the hashes but key values too.
Regardless of this bug, Consistent.circle adds unnecessary complexity.
Hello, your https certificate has expired today, the package is no longer available, can you fix it?
what a nice code!
I have a confuse that Line 248 in consistent.go
hashes := c.sortedHashes[:0]
it seems that this line is not necessary ,maybe we could replace like the code below directly?
hashes := []uint32
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.