Hyperlinkv0.8.0-beta.28

HashRing

HashRing.makeconsteffect/HashRing.ts:92
<A extends PrimaryKey.PrimaryKey>(options?: {
  readonly baseWeight?: number | undefined
}): HashRing<A>

Creates an empty HashRing.

When to use

Use to create an empty weighted consistent-hashing ring with the default or custom virtual-point density.

Details

baseWeight controls how many virtual points are added for a node with weight 1; it defaults to 128 and is clamped to at least 1.

constructorsaddaddMany
Source effect/HashRing.ts:9210 lines
export const make = <A extends PrimaryKey.PrimaryKey>(options?: {
  readonly baseWeight?: number | undefined
}): HashRing<A> => {
  const self = Object.create(Proto)
  self.baseWeight = Math.max(options?.baseWeight ?? 128, 1)
  self.totalWeightCache = 0
  self.nodes = new Map()
  self.ring = []
  return self
}