/** * @pwngh/economy-lab * * Copyright (c) Preston Neal * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */ /** * Builds the assignment function over a fixed node list, by rendezvous (highest-random-weight) * hashing: each node's weight for a scope is a deterministic hash of (node, scope) and the * scope belongs to the highest, so every node computes the same owner with no ring state to * coordinate, and a membership change reassigns only the departed or arrived node's scopes. * Every process in the deployment must construct it from the same list (order does not matter; * the hash does not depend on position) for the assignments to agree. Throws CONFIG_INVALID on * an empty or duplicate-bearing node list. * * The router only decides where new epochs open: live sessions on a moved scope finish via * epoch rotation and the orphan sweep (src/worker/orphans.ts). * * @example * const route = scopeRouter(['economy-a', 'economy-b', 'economy-c']); * const node = route(worldInstanceId); // send this scope's traffic to `node` */ export declare function scopeRouter(nodes: ReadonlyArray): (scope: string) => string;