77
func (*partitionCache) makeKey(
78
nsid, tqname string, tqtype enumspb.TaskQueueType,
80
>
// note we don't need delimiters to make unambiguous keys: nsid is always the same length,
81
>
// the last byte is tqtype, and everything in between is the name.
82
>
nsidBytes, err := uuid.Parse(nsid)
83
>
if err != nil {
84
// this shouldn't fail, but use the string form as a backup, append a 0xff to differentiate
85
return nsid + string([]byte{0xff}) + tqname + string([]byte{byte(tqtype), 0xff})
86
}
87
>
return string(nsidBytes[:]) + tqname + string([]byte{byte(tqtype)})
partition_cache.go
88
}
89
91
>
// mix a few bits to pick a shard
92
>
l := len(key)
93
>
shard := int(key[min(14, l-3)] ^ key[l-2] ^ key[l-1])
94
>
return shard % partitionCacheNumShards
95
>
}
96
98
>
return c.shards[c.shardFromKey(key)].lookup(key)
99
>
}
100
101
func (c *partitionCache) put(key string, pc PartitionCounts) {