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

Group based PeerPicker #32

Open
delphi329 opened this issue Aug 21, 2014 · 2 comments
Open

Group based PeerPicker #32

delphi329 opened this issue Aug 21, 2014 · 2 comments

Comments

@delphi329
Copy link

Hi,

This is a question. The newGroup function is private
func newGroup(name string, cacheBytes int64, getter Getter, peers PeerPicker) *Group

That means I can't pass my own PeerPicker when creating a group. As such, the default HttpPool's PeerPicker is used. Why is this restriction?

I may not understand groupchache correctly. If so correct me. My understanding is the default PeerPicker is portPicker in HttpPool. It uses consistenthash.Map to hash a string into groupcache peers, whether or not a particular peer has created a particular group or not. Suppose I have three processes running groupcache: p1, p2, and p3. And I have two groups: g1, g2. Assume we have the following peer to group mapping:
p1: g1, g2
p2: g2, g3
p3: g1, g3

If in p2 if I call

g2 := groupcache.NewGroup("g2", 10<<20, g2Getter)
g2.Get(ctx, "foo", groupcache.StringSink(&s))

and if "foo" is hashed to p3 where there is no group "g2" will that result in "foo" never cached?

I am adding peer/group auto discover with zookeeper, where grouphook will add itself to zk. Then a group based PeerPicker can be written to only hash the key to those peers that have the group. However, since newGroup with user defined picker is private, I can't find a way to set my own group based PeerPicker.

Thanks,

-John

@dvirsky
Copy link

dvirsky commented Aug 21, 2014

I think the assumption is that all peers in the pool expose the same groups. Groups differ eventually in the application's perspective, only by the fetcher function.

So if you have different groups in the same program instance, all instances of the program should expose the same groups. And if these are not instances of the same program, you should have separate pools anyway (this is what I do, BTW).

@mdentonSkyport
Copy link
Contributor

For those wondering, this pull request adds support for using different peers per group: #69

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants