From 96c07bab1086510a55a004e9a1b90c30bc723a5c Mon Sep 17 00:00:00 2001 From: sangtran Date: Sat, 29 Aug 2026 01:08:28 +0700 Subject: feat: init base draft support window --- core/hash.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 core/hash.go (limited to 'core/hash.go') diff --git a/core/hash.go b/core/hash.go new file mode 100644 index 0000000..af15546 --- /dev/null +++ b/core/hash.go @@ -0,0 +1,19 @@ +package core + +import "hash/fnv" + +const DefaultMaxParallelism = 128 + +func AssignToKeyGroup(key string, maxParallelism int) int { + + if maxParallelism <= 0 { + maxParallelism = DefaultMaxParallelism + } + + // hash + h := fnv.New32a() + h.Write([]byte(key)) + hash := h.Sum32() + + return int(hash % uint32(maxParallelism)) +} -- cgit v1.3.1