Skip to content

Conversation

@szuecs
Copy link
Member

@szuecs szuecs commented Jan 6, 2026

Feature: net package valkey ring client implementation

This is the basic block to have another Swarmer implementation to implement for example cluster*Ratelimit filters.
In order to allow migration from redis to valkey, this is the first step out of two.

ref #3799
valkey command sheet: https://valkey.io/commands

@szuecs szuecs added the minor no risk changes, for example new filters label Jan 6, 2026
@szuecs szuecs force-pushed the feature/valkey-ring branch from 36b312d to e746986 Compare January 12, 2026 16:53
szuecs added 16 commits January 13, 2026 16:33
Signed-off-by: Sandor Szücs <[email protected]>
Signed-off-by: Sandor Szücs <[email protected]>
refactor: sort imports

Signed-off-by: Sandor Szücs <[email protected]>
doc: fix valkeytest package doc

Signed-off-by: Sandor Szücs <[email protected]>
nop: cleanup
feature: enable users to pass metrics interfae for example for tests passing mockmetrics

Signed-off-by: Sandor Szücs <[email protected]>
feature: valkey lua script

Signed-off-by: Sandor Szücs <[email protected]>
feature: optional OTel client

Signed-off-by: Sandor Szücs <[email protected]>
Signed-off-by: Sandor Szücs <[email protected]>
…aths

feature: tracing and add default tracer
test: add tests for valkey.Hook

Signed-off-by: Sandor Szücs <[email protected]>
@szuecs szuecs force-pushed the feature/valkey-ring branch 2 times, most recently from 29d58b4 to 59ea15d Compare January 13, 2026 15:33
@szuecs szuecs marked this pull request as ready for review January 13, 2026 21:53
@szuecs szuecs requested a review from MustafaSaber January 13, 2026 21:53

// maps int to client for sharding, trades memory for concurrent access
// most operations only have to use this lock-free structure
shards [ringSize]valkey.Client
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this data structure is the key for the lock free access

if i%shardSize == 0 {
cur++
}
vr.shards[i] = clients[cur]
Copy link
Member Author

@szuecs szuecs Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we set the values of the lock free data structure, if we get called by SetAddr() , for example scliang-out valkey instances


// shardForKey does the lookup for valkey most operations to find the valkey ring shard
func (vr *valkeyRing) shardForKey(key string) valkey.Client {
return vr.shards[xxhash.Sum64String(key)%ringSize]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the O(1) lock free lookup of the valkey client connected to the right shard

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

Labels

enhancement minor no risk changes, for example new filters

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants