UNPKG

@gati-framework/runtime

Version:

Gati runtime execution engine for running handler-based applications

133 lines 3.88 kB
import type { TimescapeArtifact, TSV, VersionRegistryState, VersionInfo, VersionTag, VersionStatus } from './types.js'; export interface VersionClassificationConfig { hotThresholdRequests: number; warmThresholdRequests: number; coldThresholdMs: number; classificationWindowMs: number; } export declare class VersionRegistry { private state; private history; private versionCache; private readonly maxCacheSize; private classificationConfig; constructor(initialState?: Partial<VersionRegistryState>, config?: Partial<VersionClassificationConfig>); register(artifact: TimescapeArtifact): void; get(type: 'module' | 'schema' | 'route' | 'event_handler' | 'effect', id: string): TSV | undefined; getConfigVersion(): TSV | null; getAll(): VersionRegistryState; private addToHistory; getHistory(type: string, id: string): TSV[]; /** * Register a handler version in the timeline */ registerVersion(handlerPath: string, tsv: TSV, metadata: Partial<VersionInfo>): void; /** * Get version at a specific timestamp using binary search */ getVersionAt(handlerPath: string, timestamp: number): TSV | undefined; /** * Get latest version for a handler */ getLatestVersion(handlerPath: string): TSV | undefined; /** * Tag a version with a semantic label */ tagVersion(tsv: TSV, label: string, createdBy?: string): void; /** * Get version by semantic tag */ getVersionByTag(handlerPath: string, tag: string): TSV | undefined; /** * Remove a tag */ untagVersion(label: string): boolean; /** * Get all versions for a handler */ getVersions(handlerPath: string): VersionInfo[]; /** * Get all active versions */ getActiveVersions(handlerPath?: string): TSV[]; /** * Mark a version as cold */ markCold(tsv: TSV): void; /** * Update version status */ updateVersionStatus(tsv: TSV, status: VersionStatus): void; /** * Increment request count for a version */ recordRequest(tsv: TSV): void; /** * Classify version as hot/warm/cold based on usage patterns */ private classifyVersion; /** * Estimate recent requests based on total count and last access time * This is a heuristic since we don't track individual request timestamps */ private estimateRecentRequests; /** * Reclassify all versions (useful for periodic background jobs) */ reclassifyAllVersions(): void; /** * Get versions by status */ getVersionsByStatus(status: VersionStatus, handlerPath?: string): VersionInfo[]; /** * Get usage statistics */ getUsageStats(handlerPath?: string): { hot: number; warm: number; cold: number; totalRequests: number; totalVersions: number; }; /** * Update classification configuration */ updateClassificationConfig(config: Partial<VersionClassificationConfig>): void; /** * Get classification configuration */ getClassificationConfig(): VersionClassificationConfig; /** * Get version info */ getVersionInfo(tsv: TSV): VersionInfo | undefined; /** * Get all tags */ getAllTags(): VersionTag[]; /** * Get tags for a specific version */ getTagsForVersion(tsv: TSV): string[]; /** * Extract timestamp from TSV */ private extractTimestamp; /** * Cache a version lookup */ private cacheVersion; /** * Clear version cache */ private clearCache; /** * Serialize state for persistence */ serialize(): string; /** * Deserialize state from persistence */ static deserialize(data: string): VersionRegistry; } //# sourceMappingURL=registry.d.ts.map