/** * @nahisaho/yata-scale - Shard Router * * Routes operations to appropriate shards based on partition strategy */ import { type Result } from 'neverthrow'; import type { PartitionStrategy, PartitionStrategyType, ShardInfo, Entity, Relationship, GraphQuery } from '../types.js'; import { ShardNotFoundError, ShardUnavailableError } from '../errors.js'; import { type RangeConfig } from './RangePartitionStrategy.js'; /** * Shard connection interface */ export interface ShardConnection { readonly shardId: string; readonly info: ShardInfo; isHealthy(): boolean; } /** * Routing result */ export interface RoutingResult { readonly shardId: string; readonly connection: ShardConnection; } /** * Multi-shard routing result */ export interface MultiRoutingResult { readonly routings: Map; readonly unroutable: string[]; } /** * Shard router for directing operations to appropriate shards */ export declare class ShardRouter { private strategy; private connections; constructor(strategyType: PartitionStrategyType, shardIds: string[], options?: { rangeConfigs?: RangeConfig[]; }); /** * Create partition strategy */ private createStrategy; /** * Register a shard connection */ registerConnection(connection: ShardConnection): void; /** * Unregister a shard connection */ unregisterConnection(shardId: string): void; /** * Route a single entity to its shard */ routeEntity(entity: Entity): Result; /** * Route an entity ID to its shard */ routeEntityId(entityId: string): Result; /** * Route multiple entities to their shards */ routeEntities(entities: Entity[]): MultiRoutingResult; /** * Route a relationship to its shard (based on source entity) */ routeRelationship(relationship: Relationship): Result; /** * Get shards for a query */ getShardsForQuery(query: GraphQuery): string[]; /** * Get routing for a shard ID */ private getRouting; /** * Check if a shard is available */ private isShardAvailable; /** * Get all available shards */ private getAllAvailableShards; /** * Get the partition strategy */ getStrategy(): PartitionStrategy; /** * Get all registered connections */ getConnections(): Map; /** * Get healthy shard count */ getHealthyShardCount(): number; /** * Get total shard count */ getTotalShardCount(): number; } //# sourceMappingURL=ShardRouter.d.ts.map