We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 340dcbe commit dbe7509Copy full SHA for dbe7509
internal/routing/shard_picker.go
@@ -11,6 +11,22 @@ type ShardPicker interface {
11
Next(total int) int // returns an index in [0,total)
12
}
13
14
+// StaticShardPicker always returns the same shard index.
15
+type StaticShardPicker struct {
16
+ index int
17
+}
18
+
19
+func NewStaticShardPicker(index int) *StaticShardPicker {
20
+ return &StaticShardPicker{index: index}
21
22
23
+func (p *StaticShardPicker) Next(total int) int {
24
+ if total == 0 || p.index >= total {
25
+ return 0
26
+ }
27
+ return p.index
28
29
30
/*───────────────────────────────
31
Round-robin (default)
32
────────────────────────────────*/
0 commit comments