/** * @nahisaho/yata-scale - Rebalancer * * Handles shard rebalancing operations */ import { type Result } from 'neverthrow'; import type { RebalanceOptions, RebalanceJob, PartitionStrategy } from '../types.js'; import { RebalanceError } from '../errors.js'; import type { ShardStorage } from './ShardManager.js'; /** * Rebalance plan */ export interface RebalancePlan { readonly moves: EntityMove[]; readonly estimatedDuration: number; readonly affectedShards: string[]; } /** * Entity move operation */ export interface EntityMove { readonly entityId: string; readonly fromShard: string; readonly toShard: string; } /** * Rebalance progress */ export interface RebalanceProgress { readonly jobId: string; readonly totalMoves: number; readonly completedMoves: number; readonly failedMoves: number; readonly currentMove?: EntityMove; } /** * Rebalancer for moving entities between shards */ export declare class Rebalancer { private readonly strategy; private readonly getStorage; private activeJobs; private cancelled; constructor(strategy: PartitionStrategy, getStorage: (shardId: string) => ShardStorage | undefined); /** * Plan a rebalance operation */ planRebalance(currentDistribution: Map, options?: RebalanceOptions): Promise>; /** * Execute a rebalance plan */ executeRebalance(plan: RebalancePlan, options?: RebalanceOptions): Promise>; /** * Execute a single move */ private executeMove; /** * Cancel an active rebalance */ cancel(jobId: string): boolean; /** * Get progress of an active rebalance */ getProgress(jobId: string): RebalanceProgress | undefined; /** * Check if a rebalance is active */ isActive(jobId: string): boolean; } //# sourceMappingURL=Rebalancer.d.ts.map