folsom icon indicating copy to clipboard operation
folsom copied to clipboard

Feature request: customizable node locators for ketama

Open spkrka opened this issue 9 years ago • 6 comments

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.

spkrka avatar Feb 26 '15 19:02 spkrka

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.

protocol7 avatar Feb 26 '15 19:02 protocol7

@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

azagorneanu avatar Aug 15 '22 13:08 azagorneanu

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 avatar Aug 17 '22 10:08 azagorneanu

@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.

protocol7 avatar Aug 17 '22 11:08 protocol7

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.

spkrka avatar Aug 17 '22 12:08 spkrka

Cool! I will try to send a PR for review. Thanks.

azagorneanu avatar Aug 17 '22 16:08 azagorneanu