MCPcopy Create free account
hub / github.com/Effect-TS/effect / addNodesToRing

Function addNodesToRing

packages/effect/src/HashRing.ts:169–180  ·  view source on GitHub ↗
(self: HashRing<A>, keys: Array<string>, weight: number)

Source from the content-addressed store, hash-verified

167)
168
169function addNodesToRing<A extends PrimaryKey.PrimaryKey>(self: HashRing<A>, keys: Array<string>, weight: number) {
170 for (let i = weight; i > 0; i--) {
171 for (let j = 0; j < keys.length; j++) {
172 const key = keys[j]
173 self.ring.push([
174 Hash.string(`${key}:${i}`),
175 key
176 ])
177 }
178 }
179 self.ring.sort((a, b) => a[0] - b[0])
180}
181
182/**
183 * Adds a new node to the ring. If the node already exists in the ring, it

Callers 1

HashRing.tsFile · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected