/** * @nahisaho/yata-scale - Shard Manager * * Manages shard lifecycle, health, and operations */ import { type Result } from 'neverthrow'; import type { ShardConfig, ShardInfo, ShardHealth, RebalanceOptions, RebalanceJob, PartitionStrategyType, Entity, Relationship } from '../types.js'; import { ShardError, ShardNotFoundError, ShardUnavailableError, RebalanceError } from '../errors.js'; import { ShardRouter } from './ShardRouter.js'; /** * Shard storage interface */ export interface ShardStorage { readonly shardId: string; getEntity(id: string): Promise; putEntity(entity: Entity): Promise; deleteEntity(id: string): Promise; getRelationship(id: string): Promise; putRelationship(relationship: Relationship): Promise; deleteRelationship(id: string): Promise; getEntities(ids: string[]): Promise>; putEntities(entities: Entity[]): Promise; getEntityCount(): Promise; getRelationshipCount(): Promise; getSizeBytes(): Promise; open(): Promise; close(): Promise; clear(): Promise; } /** * Shard manager for lifecycle and operations */ export declare class ShardManager { private readonly strategyType; private readonly storageFactory; private shards; private storage; private router; private rebalanceJobs; private healthCheckInterval?; constructor(strategyType: PartitionStrategyType, storageFactory: (config: ShardConfig) => ShardStorage); /** * Initialize with shard configurations */ initialize(configs: ShardConfig[]): Promise; /** * Create a new shard */ createShard(config: ShardConfig): Promise>; /** * Remove a shard */ removeShard(shardId: string, graceful?: boolean): Promise>; /** * Get shard info */ getShardInfo(shardId: string): Result; /** * List all shards */ listShards(): ShardInfo[]; /** * Get shard for an entity */ getShardForEntity(entityId: string): Result; /** * Get storage for an entity */ getStorageForEntity(entityId: string): Result; /** * Start rebalancing */ startRebalance(options?: RebalanceOptions): Promise>; /** * Execute rebalance operation */ private executeRebalance; /** * Get rebalance status */ getRebalanceStatus(jobId: string): Result; /** * Cancel rebalance */ cancelRebalance(jobId: string): Promise>; /** * Check health of all shards */ checkHealth(): Promise>; /** * Repair a shard */ repairShard(shardId: string): Promise>; /** * Get the router */ getRouter(): ShardRouter; /** * Get storage for a shard */ getStorage(shardId: string): ShardStorage | undefined; /** * Close all shards */ close(): Promise; /** * Update shard status */ private updateShardStatus; /** * Create a connection object for router */ private createConnection; /** * Start health check interval */ private startHealthCheck; /** * Stop health check interval */ private stopHealthCheck; } //# sourceMappingURL=ShardManager.d.ts.map