folsom
folsom copied to clipboard
Feature request: customizable node locators for ketama
It would be nice to be able to tweak the actual node location logic in the ketama setup (hash key to integer, hash machines + node number to virtual nodes in a ring, et.c.) to make it easier to be compatible with other ketama implementations (such as spymemcached). This would make a lot of transitions easier.
I got a branch somewhere where I refactored out a hasher interface for this exact purpose. When I get the cycled I can dig it up.
@spkrka @protocol7 I'm trying to migrate from another memcached library to Folsom and I'm also missing this feature. I need to be able to customize the call to Continuum.findClient(byte[] key)
.
For example I want to customize so that all the keys that start with some common prefix go to the same node:
-
prefix1-sufix1
key - goes to node 1 -
prefix1-sufix2
key - goes to node 1 -
prefix2-sufix3
key - goes to node 2
Some kind of SessionLocator
or NodeLocator
abstractization would be nice to have. Then we can provide custom implementations or extend/reuse the existing ones(e.g. KetamaSessionLocator
).
@azagorneanu I never got around to finishing up my branch, but I would still agree that a node locator would be a nice abstraction to have pluggable. If you're up for proposing a PR, I would be happy to take a look.
I agree it would be useful. I tried playing around with adding something, but without having an explicit use case in mind it is harder, so I would also prefer having a proposal to review.
Cool! I will try to send a PR for review. Thanks.