MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / pickShard

Function pickShard

packages/queue/src/queues.ts:22–27  ·  view source on GitHub ↗
(projectId: string)

Source from the content-addressed store, hash-verified

20 process.env.QUEUE_CLUSTER ? `{${name}}` : name;
21
22function pickShard(projectId: string) {
23 const h = createHash('sha1').update(projectId).digest(); // 20 bytes
24 // take first 4 bytes as unsigned int
25 const x = h.readUInt32BE(0);
26 return x % EVENTS_GROUP_QUEUES_SHARDS; // 0..n-1
27}
28
29export const queueLogger = createLogger({ name: 'queue' });
30

Callers 1

getEventsGroupQueueShardFunction · 0.85

Calls 1

createHashFunction · 0.85

Tested by

no test coverage detected