@pwngh/economy-lab
    Preparing search index...

    Function openClusterNode

    • Opens this process's node of a multi-node deployment — one construction for what every multi-node host was hand-wiring: the scope router bound to this node's identity, the store-backed shared reservation registry, ownership-gated session opening, crash recovery, and the orphan sweep. Every node constructs from the same nodes list over the same shared database, and the store must offer the reservation counter (the SQL engines and the memory adapter all do).

      Parameters

      Returns ClusterNode

      const node = openClusterNode(ports, {
      nodeId: 'economy-a',
      nodes: ['economy-a', 'economy-b', 'economy-c'],
      sweep: { settleOlderThanMs: 120_000 },
      });
      const lanes = openInstanceEconomies(ports, { ...node.laneOptions() });

      // Per request from a game server:
      node.assertOwns(worldInstanceId);
      await lanes.laneFor(worldInstanceId).purchase(order);

      // On the worker's schedule:
      await node.sweepOrphans();