package event import ( "hash/fnv" "strconv" ) // PartitionOf maps a stable key (sessionId / listId / sendID, stringified) to a // partition index in [0, n) for the track.partition.{N} ingest scheme // (slask-tracking shell-rebuild §8). fnv1a-64 over the key bytes, so producers // (slask-finder's track.* publisher, slask-tracking's HTTP beacon edge) and // consumers agree on the routing without sharing app code. n <= 1 is a single // partition (index 0). func PartitionOf(key string, n int) int { if n <= 1 { return 0 } h := fnv.New64a() _, _ = h.Write([]byte(key)) return int(h.Sum64() % uint64(n)) } // PartitionRoutingKey is the queue AND routing key for partition i: the queue // track.partition.{i} binds to the catalog exchange with the same key, so a // producer routing to track.partition.{i} lands on exactly that queue. This is // the shared name both the slask-finder producer and the slask-tracking // consumer use, so the partition→queue→consumer map is observable and stable. func PartitionRoutingKey(i int) string { return "track.partition." + strconv.Itoa(i) }