HashRing
Combinators
Add a new node to the ring. If the node already exists in the ring, it will be updated. For example, you can use this to update the node's weight.
Signature
declare const add: { <A extends PrimaryKey>(node: A, options?: { readonly weight?: number; }): (self: HashRing<A>) => HashRing<A>; <A extends PrimaryKey>(self: HashRing<A>, node: A, options?: { readonly weight?: number; }): HashRing<A>;}Add new nodes to the ring. If a node already exists in the ring, it will be updated. For example, you can use this to update the node's weight.
Signature
declare const addMany: { <A extends PrimaryKey>(nodes: Iterable<A>, options?: { readonly weight?: number; }): (self: HashRing<A>) => HashRing<A>; <A extends PrimaryKey>(self: HashRing<A>, nodes: Iterable<A>, options?: { readonly weight?: number; }): HashRing<A>;}Gets the node which should handle the given input. Returns undefined if the hashring has no elements with weight.
Signature
declare function get<A extends PrimaryKey>(self: HashRing<A>, input: string): A | undefinedDistributes count shards across the nodes in the ring, attempting to
balance the number of shards allocated to each node. Returns undefined if
the hashring has no elements with weight.
Signature
declare function getShards<A extends PrimaryKey>(self: HashRing<A>, count: number): Array<A> | undefinedSignature
declare const has: { <A extends PrimaryKey>(node: A): (self: HashRing<A>) => boolean; <A extends PrimaryKey>(self: HashRing<A>, node: A): boolean;}Removes the node from the ring. No-op's if the node does not exist.
Signature
declare const remove: { <A extends PrimaryKey>(node: A): (self: HashRing<A>) => HashRing<A>; <A extends PrimaryKey>(self: HashRing<A>, node: A): HashRing<A>;}Constructors
Guards
isHashRing
Added in v3.19.0
Source
Signature
declare function isHashRing(u: unknown): u is HashRing<any>Models
Signature
interface HashRing<A extends PrimaryKey.PrimaryKey> extends Pipeable, "/home/runner/work/website/website/.effect-source-v3/packages/effect/src/Iterable"<A> { readonly "~effect/cluster/HashRing": "~effect/cluster/HashRing"; readonly baseWeight: number; readonly nodes: Map<string, [node: A, weight: number]>; ring: Array<[hash: number, node: string]>; totalWeightCache: number;}