diff --git a/pkg/slurp/storage/backup_manager.go b/pkg/slurp/storage/backup_manager.go index 4ecede9..bc37e9d 100644 --- a/pkg/slurp/storage/backup_manager.go +++ b/pkg/slurp/storage/backup_manager.go @@ -12,35 +12,35 @@ import ( "sync" "time" - "github.com/robfig/cron/v3" "chorus/pkg/crypto" + "github.com/robfig/cron/v3" ) // BackupManagerImpl implements the BackupManager interface type BackupManagerImpl struct { - mu sync.RWMutex - contextStore *ContextStoreImpl - crypto crypto.RoleCrypto - basePath string - nodeID string - schedules map[string]*cron.Cron - backups map[string]*BackupInfo - runningBackups map[string]*BackupJob - options *BackupManagerOptions - notifications chan *BackupEvent - stopCh chan struct{} + mu sync.RWMutex + contextStore *ContextStoreImpl + crypto crypto.RoleCrypto + basePath string + nodeID string + schedules map[string]*cron.Cron + backups map[string]*BackupInfo + runningBackups map[string]*BackupJob + options *BackupManagerOptions + notifications chan *BackupEvent + stopCh chan struct{} } // BackupManagerOptions configures backup manager behavior type BackupManagerOptions struct { - MaxConcurrentBackups int `json:"max_concurrent_backups"` - CompressionEnabled bool `json:"compression_enabled"` - EncryptionEnabled bool `json:"encryption_enabled"` - RetentionDays int `json:"retention_days"` - ValidationEnabled bool `json:"validation_enabled"` - NotificationsEnabled bool `json:"notifications_enabled"` - BackupTimeout time.Duration `json:"backup_timeout"` - CleanupInterval time.Duration `json:"cleanup_interval"` + MaxConcurrentBackups int `json:"max_concurrent_backups"` + CompressionEnabled bool `json:"compression_enabled"` + EncryptionEnabled bool `json:"encryption_enabled"` + RetentionDays int `json:"retention_days"` + ValidationEnabled bool `json:"validation_enabled"` + NotificationsEnabled bool `json:"notifications_enabled"` + BackupTimeout time.Duration `json:"backup_timeout"` + CleanupInterval time.Duration `json:"cleanup_interval"` } // BackupJob represents a running backup operation @@ -69,14 +69,14 @@ type BackupEvent struct { type BackupEventType string const ( - BackupStarted BackupEventType = "backup_started" - BackupProgress BackupEventType = "backup_progress" - BackupCompleted BackupEventType = "backup_completed" - BackupFailed BackupEventType = "backup_failed" - BackupValidated BackupEventType = "backup_validated" - BackupRestored BackupEventType = "backup_restored" - BackupDeleted BackupEventType = "backup_deleted" - BackupScheduled BackupEventType = "backup_scheduled" + BackupEventStarted BackupEventType = "backup_started" + BackupEventProgress BackupEventType = "backup_progress" + BackupEventCompleted BackupEventType = "backup_completed" + BackupEventFailed BackupEventType = "backup_failed" + BackupEventValidated BackupEventType = "backup_validated" + BackupEventRestored BackupEventType = "backup_restored" + BackupEventDeleted BackupEventType = "backup_deleted" + BackupEventScheduled BackupEventType = "backup_scheduled" ) // DefaultBackupManagerOptions returns sensible defaults @@ -112,15 +112,15 @@ func NewBackupManager( bm := &BackupManagerImpl{ contextStore: contextStore, - crypto: crypto, - basePath: basePath, - nodeID: nodeID, - schedules: make(map[string]*cron.Cron), - backups: make(map[string]*BackupInfo), + crypto: crypto, + basePath: basePath, + nodeID: nodeID, + schedules: make(map[string]*cron.Cron), + backups: make(map[string]*BackupInfo), runningBackups: make(map[string]*BackupJob), - options: options, - notifications: make(chan *BackupEvent, 100), - stopCh: make(chan struct{}), + options: options, + notifications: make(chan *BackupEvent, 100), + stopCh: make(chan struct{}), } // Load existing backup metadata @@ -154,16 +154,16 @@ func (bm *BackupManagerImpl) CreateBackup( // Create backup info backupInfo := &BackupInfo{ - ID: backupID, - BackupID: backupID, - Name: config.Name, - Destination: config.Destination, + ID: backupID, + BackupID: backupID, + Name: config.Name, + Destination: config.Destination, IncludesIndexes: config.IncludeIndexes, IncludesCache: config.IncludeCache, Encrypted: config.Encryption, Incremental: config.Incremental, ParentBackupID: config.ParentBackupID, - Status: BackupInProgress, + Status: BackupStatusInProgress, CreatedAt: time.Now(), RetentionUntil: time.Now().Add(config.Retention), } @@ -174,7 +174,7 @@ func (bm *BackupManagerImpl) CreateBackup( ID: backupID, Config: config, StartTime: time.Now(), - Status: BackupInProgress, + Status: BackupStatusInProgress, cancel: cancel, } @@ -186,7 +186,7 @@ func (bm *BackupManagerImpl) CreateBackup( // Notify backup started bm.notify(&BackupEvent{ - Type: BackupStarted, + Type: BackupEventStarted, BackupID: backupID, Message: fmt.Sprintf("Backup '%s' started", config.Name), Timestamp: time.Now(), @@ -213,7 +213,7 @@ func (bm *BackupManagerImpl) RestoreBackup( return fmt.Errorf("backup %s not found", backupID) } - if backupInfo.Status != BackupCompleted { + if backupInfo.Status != BackupStatusCompleted { return fmt.Errorf("backup %s is not completed (status: %s)", backupID, backupInfo.Status) } @@ -276,7 +276,7 @@ func (bm *BackupManagerImpl) DeleteBackup(ctx context.Context, backupID string) // Notify deletion bm.notify(&BackupEvent{ - Type: BackupDeleted, + Type: BackupEventDeleted, BackupID: backupID, Message: fmt.Sprintf("Backup '%s' deleted", backupInfo.Name), Timestamp: time.Now(), @@ -348,7 +348,7 @@ func (bm *BackupManagerImpl) ValidateBackup( // Notify validation completed bm.notify(&BackupEvent{ - Type: BackupValidated, + Type: BackupEventValidated, BackupID: backupID, Message: fmt.Sprintf("Backup validation completed (valid: %v)", validation.Valid), Timestamp: time.Now(), @@ -396,7 +396,7 @@ func (bm *BackupManagerImpl) ScheduleBackup( // Notify scheduling bm.notify(&BackupEvent{ - Type: BackupScheduled, + Type: BackupEventScheduled, BackupID: schedule.ID, Message: fmt.Sprintf("Backup schedule '%s' created", schedule.Name), Timestamp: time.Now(), @@ -429,13 +429,13 @@ func (bm *BackupManagerImpl) GetBackupStats(ctx context.Context) (*BackupStatist for _, backup := range bm.backups { switch backup.Status { - case BackupCompleted: + case BackupStatusCompleted: stats.SuccessfulBackups++ if backup.CompletedAt != nil { backupTime := backup.CompletedAt.Sub(backup.CreatedAt) totalTime += backupTime } - case BackupFailed: + case BackupStatusFailed: stats.FailedBackups++ } @@ -544,7 +544,7 @@ func (bm *BackupManagerImpl) performBackup( // Update backup info completedAt := time.Now() bm.mu.Lock() - backupInfo.Status = BackupCompleted + backupInfo.Status = BackupStatusCompleted backupInfo.DataSize = finalSize backupInfo.CompressedSize = finalSize // Would be different if compression is applied backupInfo.Checksum = checksum @@ -560,7 +560,7 @@ func (bm *BackupManagerImpl) performBackup( // Notify completion bm.notify(&BackupEvent{ - Type: BackupCompleted, + Type: BackupEventCompleted, BackupID: job.ID, Message: fmt.Sprintf("Backup '%s' completed successfully", job.Config.Name), Timestamp: time.Now(), @@ -607,7 +607,7 @@ func (bm *BackupManagerImpl) performRestore( // Notify restore completion bm.notify(&BackupEvent{ - Type: BackupRestored, + Type: BackupEventRestored, BackupID: backupInfo.BackupID, Message: fmt.Sprintf("Backup '%s' restored successfully", backupInfo.Name), Timestamp: time.Now(), @@ -706,13 +706,13 @@ func (bm *BackupManagerImpl) validateFile(filePath string) error { func (bm *BackupManagerImpl) failBackup(job *BackupJob, backupInfo *BackupInfo, err error) { bm.mu.Lock() - backupInfo.Status = BackupFailed + backupInfo.Status = BackupStatusFailed backupInfo.ErrorMessage = err.Error() job.Error = err bm.mu.Unlock() bm.notify(&BackupEvent{ - Type: BackupFailed, + Type: BackupEventFailed, BackupID: job.ID, Message: fmt.Sprintf("Backup '%s' failed: %v", job.Config.Name, err), Timestamp: time.Now(), diff --git a/pkg/slurp/storage/types.go b/pkg/slurp/storage/types.go index 12e65a8..2e83971 100644 --- a/pkg/slurp/storage/types.go +++ b/pkg/slurp/storage/types.go @@ -3,83 +3,83 @@ package storage import ( "time" - "chorus/pkg/ucxl" "chorus/pkg/crypto" slurpContext "chorus/pkg/slurp/context" + "chorus/pkg/ucxl" ) // ListCriteria represents criteria for listing contexts type ListCriteria struct { // Filter criteria - Tags []string `json:"tags"` // Required tags - Technologies []string `json:"technologies"` // Required technologies - Roles []string `json:"roles"` // Accessible roles - PathPattern string `json:"path_pattern"` // Path pattern to match - + Tags []string `json:"tags"` // Required tags + Technologies []string `json:"technologies"` // Required technologies + Roles []string `json:"roles"` // Accessible roles + PathPattern string `json:"path_pattern"` // Path pattern to match + // Date filters - CreatedAfter *time.Time `json:"created_after,omitempty"` // Created after date - CreatedBefore *time.Time `json:"created_before,omitempty"` // Created before date - UpdatedAfter *time.Time `json:"updated_after,omitempty"` // Updated after date - UpdatedBefore *time.Time `json:"updated_before,omitempty"` // Updated before date - + CreatedAfter *time.Time `json:"created_after,omitempty"` // Created after date + CreatedBefore *time.Time `json:"created_before,omitempty"` // Created before date + UpdatedAfter *time.Time `json:"updated_after,omitempty"` // Updated after date + UpdatedBefore *time.Time `json:"updated_before,omitempty"` // Updated before date + // Quality filters - MinConfidence float64 `json:"min_confidence"` // Minimum confidence score - MaxAge *time.Duration `json:"max_age,omitempty"` // Maximum age - + MinConfidence float64 `json:"min_confidence"` // Minimum confidence score + MaxAge *time.Duration `json:"max_age,omitempty"` // Maximum age + // Pagination - Offset int `json:"offset"` // Result offset - Limit int `json:"limit"` // Maximum results - + Offset int `json:"offset"` // Result offset + Limit int `json:"limit"` // Maximum results + // Sorting - SortBy string `json:"sort_by"` // Sort field - SortOrder string `json:"sort_order"` // Sort order (asc, desc) - + SortBy string `json:"sort_by"` // Sort field + SortOrder string `json:"sort_order"` // Sort order (asc, desc) + // Options - IncludeStale bool `json:"include_stale"` // Include stale contexts + IncludeStale bool `json:"include_stale"` // Include stale contexts } // SearchQuery represents a search query for contexts type SearchQuery struct { // Query terms - Query string `json:"query"` // Main search query - Tags []string `json:"tags"` // Required tags - Technologies []string `json:"technologies"` // Required technologies - FileTypes []string `json:"file_types"` // File types to include - + Query string `json:"query"` // Main search query + Tags []string `json:"tags"` // Required tags + Technologies []string `json:"technologies"` // Required technologies + FileTypes []string `json:"file_types"` // File types to include + // Filters - MinConfidence float64 `json:"min_confidence"` // Minimum confidence - MaxAge *time.Duration `json:"max_age"` // Maximum age - Roles []string `json:"roles"` // Required access roles - + MinConfidence float64 `json:"min_confidence"` // Minimum confidence + MaxAge *time.Duration `json:"max_age"` // Maximum age + Roles []string `json:"roles"` // Required access roles + // Scope - Scope []string `json:"scope"` // Paths to search within - ExcludeScope []string `json:"exclude_scope"` // Paths to exclude - + Scope []string `json:"scope"` // Paths to search within + ExcludeScope []string `json:"exclude_scope"` // Paths to exclude + // Result options - Limit int `json:"limit"` // Maximum results - Offset int `json:"offset"` // Result offset - SortBy string `json:"sort_by"` // Sort field - SortOrder string `json:"sort_order"` // asc, desc - + Limit int `json:"limit"` // Maximum results + Offset int `json:"offset"` // Result offset + SortBy string `json:"sort_by"` // Sort field + SortOrder string `json:"sort_order"` // asc, desc + // Advanced options - FuzzyMatch bool `json:"fuzzy_match"` // Enable fuzzy matching - IncludeStale bool `json:"include_stale"` // Include stale contexts - HighlightTerms bool `json:"highlight_terms"` // Highlight search terms - + FuzzyMatch bool `json:"fuzzy_match"` // Enable fuzzy matching + IncludeStale bool `json:"include_stale"` // Include stale contexts + HighlightTerms bool `json:"highlight_terms"` // Highlight search terms + // Faceted search - Facets []string `json:"facets"` // Facets to include - FacetFilters map[string][]string `json:"facet_filters"` // Facet filters + Facets []string `json:"facets"` // Facets to include + FacetFilters map[string][]string `json:"facet_filters"` // Facet filters } // SearchResults represents search query results type SearchResults struct { - Query *SearchQuery `json:"query"` // Original query - Results []*SearchResult `json:"results"` // Search results - TotalResults int64 `json:"total_results"` // Total matching results - ProcessingTime time.Duration `json:"processing_time"` // Query processing time - Facets map[string]map[string]int `json:"facets"` // Faceted results - Suggestions []string `json:"suggestions"` // Query suggestions - ProcessedAt time.Time `json:"processed_at"` // When query was processed + Query *SearchQuery `json:"query"` // Original query + Results []*SearchResult `json:"results"` // Search results + TotalResults int64 `json:"total_results"` // Total matching results + ProcessingTime time.Duration `json:"processing_time"` // Query processing time + Facets map[string]map[string]int `json:"facets"` // Faceted results + Suggestions []string `json:"suggestions"` // Query suggestions + ProcessedAt time.Time `json:"processed_at"` // When query was processed } // SearchResult represents a single search result @@ -94,76 +94,76 @@ type SearchResult struct { // BatchStoreRequest represents a batch store operation type BatchStoreRequest struct { - Contexts []*ContextStoreItem `json:"contexts"` // Contexts to store - Roles []string `json:"roles"` // Default roles for all contexts - Options *StoreOptions `json:"options"` // Store options - Transaction bool `json:"transaction"` // Use transaction - FailOnError bool `json:"fail_on_error"` // Fail entire batch on error + Contexts []*ContextStoreItem `json:"contexts"` // Contexts to store + Roles []string `json:"roles"` // Default roles for all contexts + Options *StoreOptions `json:"options"` // Store options + Transaction bool `json:"transaction"` // Use transaction + FailOnError bool `json:"fail_on_error"` // Fail entire batch on error } // ContextStoreItem represents a single item in batch store type ContextStoreItem struct { - Context *slurpContext.ContextNode `json:"context"` // Context to store - Roles []string `json:"roles"` // Specific roles (overrides default) - Options *StoreOptions `json:"options"` // Item-specific options + Context *slurpContext.ContextNode `json:"context"` // Context to store + Roles []string `json:"roles"` // Specific roles (overrides default) + Options *StoreOptions `json:"options"` // Item-specific options } // BatchStoreResult represents the result of batch store operation type BatchStoreResult struct { - SuccessCount int `json:"success_count"` // Number of successful stores - ErrorCount int `json:"error_count"` // Number of failed stores - Errors map[string]error `json:"errors"` // Errors by context path - ProcessingTime time.Duration `json:"processing_time"` // Total processing time - ProcessedAt time.Time `json:"processed_at"` // When batch was processed + SuccessCount int `json:"success_count"` // Number of successful stores + ErrorCount int `json:"error_count"` // Number of failed stores + Errors map[string]error `json:"errors"` // Errors by context path + ProcessingTime time.Duration `json:"processing_time"` // Total processing time + ProcessedAt time.Time `json:"processed_at"` // When batch was processed } // BatchRetrieveRequest represents a batch retrieve operation type BatchRetrieveRequest struct { - Addresses []ucxl.Address `json:"addresses"` // Addresses to retrieve - Role string `json:"role"` // Role for access control - Options *RetrieveOptions `json:"options"` // Retrieve options - FailOnError bool `json:"fail_on_error"` // Fail entire batch on error + Addresses []ucxl.Address `json:"addresses"` // Addresses to retrieve + Role string `json:"role"` // Role for access control + Options *RetrieveOptions `json:"options"` // Retrieve options + FailOnError bool `json:"fail_on_error"` // Fail entire batch on error } // BatchRetrieveResult represents the result of batch retrieve operation type BatchRetrieveResult struct { - Contexts map[string]*slurpContext.ContextNode `json:"contexts"` // Retrieved contexts by address - SuccessCount int `json:"success_count"` // Number of successful retrieves - ErrorCount int `json:"error_count"` // Number of failed retrieves - Errors map[string]error `json:"errors"` // Errors by address - ProcessingTime time.Duration `json:"processing_time"` // Total processing time - ProcessedAt time.Time `json:"processed_at"` // When batch was processed + Contexts map[string]*slurpContext.ContextNode `json:"contexts"` // Retrieved contexts by address + SuccessCount int `json:"success_count"` // Number of successful retrieves + ErrorCount int `json:"error_count"` // Number of failed retrieves + Errors map[string]error `json:"errors"` // Errors by address + ProcessingTime time.Duration `json:"processing_time"` // Total processing time + ProcessedAt time.Time `json:"processed_at"` // When batch was processed } // StoreOptions represents options for storing contexts type StoreOptions struct { - Encrypt bool `json:"encrypt"` // Whether to encrypt data - Replicate bool `json:"replicate"` // Whether to replicate across nodes - Index bool `json:"index"` // Whether to add to search index - Cache bool `json:"cache"` // Whether to cache locally - Compress bool `json:"compress"` // Whether to compress data - TTL *time.Duration `json:"ttl,omitempty"` // Time to live - AccessLevel crypto.AccessLevel `json:"access_level"` // Required access level - Metadata map[string]interface{} `json:"metadata"` // Additional metadata + Encrypt bool `json:"encrypt"` // Whether to encrypt data + Replicate bool `json:"replicate"` // Whether to replicate across nodes + Index bool `json:"index"` // Whether to add to search index + Cache bool `json:"cache"` // Whether to cache locally + Compress bool `json:"compress"` // Whether to compress data + TTL *time.Duration `json:"ttl,omitempty"` // Time to live + AccessLevel crypto.AccessLevel `json:"access_level"` // Required access level + Metadata map[string]interface{} `json:"metadata"` // Additional metadata } // RetrieveOptions represents options for retrieving contexts type RetrieveOptions struct { - UseCache bool `json:"use_cache"` // Whether to use cache - RefreshCache bool `json:"refresh_cache"` // Whether to refresh cache - IncludeStale bool `json:"include_stale"` // Include stale contexts - MaxAge *time.Duration `json:"max_age,omitempty"` // Maximum acceptable age - Decompress bool `json:"decompress"` // Whether to decompress data - ValidateIntegrity bool `json:"validate_integrity"` // Validate data integrity + UseCache bool `json:"use_cache"` // Whether to use cache + RefreshCache bool `json:"refresh_cache"` // Whether to refresh cache + IncludeStale bool `json:"include_stale"` // Include stale contexts + MaxAge *time.Duration `json:"max_age,omitempty"` // Maximum acceptable age + Decompress bool `json:"decompress"` // Whether to decompress data + ValidateIntegrity bool `json:"validate_integrity"` // Validate data integrity } // DistributedStoreOptions represents options for distributed storage type DistributedStoreOptions struct { - ReplicationFactor int `json:"replication_factor"` // Number of replicas - ConsistencyLevel ConsistencyLevel `json:"consistency_level"` // Consistency requirements - Timeout time.Duration `json:"timeout"` // Operation timeout - PreferLocal bool `json:"prefer_local"` // Prefer local storage - SyncMode SyncMode `json:"sync_mode"` // Synchronization mode + ReplicationFactor int `json:"replication_factor"` // Number of replicas + ConsistencyLevel ConsistencyLevel `json:"consistency_level"` // Consistency requirements + Timeout time.Duration `json:"timeout"` // Operation timeout + PreferLocal bool `json:"prefer_local"` // Prefer local storage + SyncMode SyncMode `json:"sync_mode"` // Synchronization mode } // ConsistencyLevel represents consistency requirements @@ -179,184 +179,187 @@ const ( type SyncMode string const ( - SyncAsync SyncMode = "async" // Asynchronous synchronization - SyncSync SyncMode = "sync" // Synchronous synchronization - SyncLazy SyncMode = "lazy" // Lazy synchronization + SyncAsync SyncMode = "async" // Asynchronous synchronization + SyncSync SyncMode = "sync" // Synchronous synchronization + SyncLazy SyncMode = "lazy" // Lazy synchronization ) // StorageStatistics represents overall storage statistics type StorageStatistics struct { - TotalContexts int64 `json:"total_contexts"` // Total stored contexts - LocalContexts int64 `json:"local_contexts"` // Locally stored contexts - DistributedContexts int64 `json:"distributed_contexts"` // Distributed contexts - TotalSize int64 `json:"total_size"` // Total storage size - CompressedSize int64 `json:"compressed_size"` // Compressed storage size - IndexSize int64 `json:"index_size"` // Search index size - CacheSize int64 `json:"cache_size"` // Cache size - ReplicationFactor float64 `json:"replication_factor"` // Average replication factor - AvailableSpace int64 `json:"available_space"` // Available storage space - LastSyncTime time.Time `json:"last_sync_time"` // Last synchronization - SyncErrors int64 `json:"sync_errors"` // Synchronization errors - OperationsPerSecond float64 `json:"operations_per_second"` // Operations per second - AverageLatency time.Duration `json:"average_latency"` // Average operation latency + TotalContexts int64 `json:"total_contexts"` // Total stored contexts + LocalContexts int64 `json:"local_contexts"` // Locally stored contexts + DistributedContexts int64 `json:"distributed_contexts"` // Distributed contexts + TotalSize int64 `json:"total_size"` // Total storage size + CompressedSize int64 `json:"compressed_size"` // Compressed storage size + IndexSize int64 `json:"index_size"` // Search index size + CacheSize int64 `json:"cache_size"` // Cache size + ReplicationFactor float64 `json:"replication_factor"` // Average replication factor + AvailableSpace int64 `json:"available_space"` // Available storage space + LastSyncTime time.Time `json:"last_sync_time"` // Last synchronization + SyncErrors int64 `json:"sync_errors"` // Synchronization errors + OperationsPerSecond float64 `json:"operations_per_second"` // Operations per second + AverageLatency time.Duration `json:"average_latency"` // Average operation latency } // LocalStorageStats represents local storage statistics type LocalStorageStats struct { - TotalFiles int64 `json:"total_files"` // Total stored files - TotalSize int64 `json:"total_size"` // Total storage size - CompressedSize int64 `json:"compressed_size"` // Compressed size - AvailableSpace int64 `json:"available_space"` // Available disk space - FragmentationRatio float64 `json:"fragmentation_ratio"` // Storage fragmentation - LastCompaction time.Time `json:"last_compaction"` // Last compaction time - ReadOperations int64 `json:"read_operations"` // Read operations count - WriteOperations int64 `json:"write_operations"` // Write operations count - AverageReadTime time.Duration `json:"average_read_time"` // Average read time - AverageWriteTime time.Duration `json:"average_write_time"` // Average write time + TotalFiles int64 `json:"total_files"` // Total stored files + TotalSize int64 `json:"total_size"` // Total storage size + CompressedSize int64 `json:"compressed_size"` // Compressed size + AvailableSpace int64 `json:"available_space"` // Available disk space + FragmentationRatio float64 `json:"fragmentation_ratio"` // Storage fragmentation + LastCompaction time.Time `json:"last_compaction"` // Last compaction time + ReadOperations int64 `json:"read_operations"` // Read operations count + WriteOperations int64 `json:"write_operations"` // Write operations count + AverageReadTime time.Duration `json:"average_read_time"` // Average read time + AverageWriteTime time.Duration `json:"average_write_time"` // Average write time } // DistributedStorageStats represents distributed storage statistics type DistributedStorageStats struct { - TotalNodes int `json:"total_nodes"` // Total nodes in cluster - ActiveNodes int `json:"active_nodes"` // Active nodes - FailedNodes int `json:"failed_nodes"` // Failed nodes - TotalReplicas int64 `json:"total_replicas"` // Total replicas - HealthyReplicas int64 `json:"healthy_replicas"` // Healthy replicas - UnderReplicated int64 `json:"under_replicated"` // Under-replicated data - NetworkLatency time.Duration `json:"network_latency"` // Average network latency + TotalNodes int `json:"total_nodes"` // Total nodes in cluster + ActiveNodes int `json:"active_nodes"` // Active nodes + FailedNodes int `json:"failed_nodes"` // Failed nodes + TotalReplicas int64 `json:"total_replicas"` // Total replicas + HealthyReplicas int64 `json:"healthy_replicas"` // Healthy replicas + UnderReplicated int64 `json:"under_replicated"` // Under-replicated data + NetworkLatency time.Duration `json:"network_latency"` // Average network latency ReplicationLatency time.Duration `json:"replication_latency"` // Average replication latency - ConsensusTime time.Duration `json:"consensus_time"` // Average consensus time - LastRebalance time.Time `json:"last_rebalance"` // Last rebalance operation + ConsensusTime time.Duration `json:"consensus_time"` // Average consensus time + LastRebalance time.Time `json:"last_rebalance"` // Last rebalance operation } // CacheStatistics represents cache performance statistics type CacheStatistics struct { - HitRate float64 `json:"hit_rate"` // Cache hit rate - MissRate float64 `json:"miss_rate"` // Cache miss rate - TotalHits int64 `json:"total_hits"` // Total cache hits - TotalMisses int64 `json:"total_misses"` // Total cache misses - CurrentSize int64 `json:"current_size"` // Current cache size - MaxSize int64 `json:"max_size"` // Maximum cache size - EvictionCount int64 `json:"eviction_count"` // Number of evictions - AverageLoadTime time.Duration `json:"average_load_time"` // Average cache load time - LastEviction time.Time `json:"last_eviction"` // Last eviction time - MemoryUsage int64 `json:"memory_usage"` // Memory usage in bytes + HitRate float64 `json:"hit_rate"` // Cache hit rate + MissRate float64 `json:"miss_rate"` // Cache miss rate + TotalHits int64 `json:"total_hits"` // Total cache hits + TotalMisses int64 `json:"total_misses"` // Total cache misses + CurrentSize int64 `json:"current_size"` // Current cache size + MaxSize int64 `json:"max_size"` // Maximum cache size + EvictionCount int64 `json:"eviction_count"` // Number of evictions + AverageLoadTime time.Duration `json:"average_load_time"` // Average cache load time + LastEviction time.Time `json:"last_eviction"` // Last eviction time + MemoryUsage int64 `json:"memory_usage"` // Memory usage in bytes } // CachePolicy represents caching policy configuration type CachePolicy struct { - TTL time.Duration `json:"ttl"` // Default TTL - MaxSize int64 `json:"max_size"` // Maximum cache size - EvictionPolicy string `json:"eviction_policy"` // Eviction policy (LRU, LFU, etc.) - RefreshThreshold float64 `json:"refresh_threshold"` // Refresh threshold - WarmupEnabled bool `json:"warmup_enabled"` // Enable cache warmup - CompressEntries bool `json:"compress_entries"` // Compress cache entries - MaxEntrySize int64 `json:"max_entry_size"` // Maximum entry size + TTL time.Duration `json:"ttl"` // Default TTL + MaxSize int64 `json:"max_size"` // Maximum cache size + EvictionPolicy string `json:"eviction_policy"` // Eviction policy (LRU, LFU, etc.) + RefreshThreshold float64 `json:"refresh_threshold"` // Refresh threshold + WarmupEnabled bool `json:"warmup_enabled"` // Enable cache warmup + CompressEntries bool `json:"compress_entries"` // Compress cache entries + MaxEntrySize int64 `json:"max_entry_size"` // Maximum entry size } // IndexConfig represents search index configuration type IndexConfig struct { - Name string `json:"name"` // Index name - Fields []string `json:"fields"` // Indexed fields - Analyzer string `json:"analyzer"` // Text analyzer - Language string `json:"language"` // Index language - CaseSensitive bool `json:"case_sensitive"` // Case sensitivity - Stemming bool `json:"stemming"` // Enable stemming - StopWords []string `json:"stop_words"` // Stop words list - Synonyms map[string][]string `json:"synonyms"` // Synonym mappings - MaxDocumentSize int64 `json:"max_document_size"` // Max document size - RefreshInterval time.Duration `json:"refresh_interval"` // Index refresh interval + Name string `json:"name"` // Index name + Fields []string `json:"fields"` // Indexed fields + Analyzer string `json:"analyzer"` // Text analyzer + Language string `json:"language"` // Index language + CaseSensitive bool `json:"case_sensitive"` // Case sensitivity + Stemming bool `json:"stemming"` // Enable stemming + StopWords []string `json:"stop_words"` // Stop words list + Synonyms map[string][]string `json:"synonyms"` // Synonym mappings + MaxDocumentSize int64 `json:"max_document_size"` // Max document size + RefreshInterval time.Duration `json:"refresh_interval"` // Index refresh interval } // IndexStatistics represents search index statistics type IndexStatistics struct { - Name string `json:"name"` // Index name - DocumentCount int64 `json:"document_count"` // Total documents - IndexSize int64 `json:"index_size"` // Index size in bytes - LastUpdate time.Time `json:"last_update"` // Last update time - QueryCount int64 `json:"query_count"` // Total queries - AverageQueryTime time.Duration `json:"average_query_time"` // Average query time - SuccessRate float64 `json:"success_rate"` // Query success rate - FragmentationRatio float64 `json:"fragmentation_ratio"` // Index fragmentation - LastOptimization time.Time `json:"last_optimization"` // Last optimization time + Name string `json:"name"` // Index name + DocumentCount int64 `json:"document_count"` // Total documents + IndexSize int64 `json:"index_size"` // Index size in bytes + LastUpdate time.Time `json:"last_update"` // Last update time + QueryCount int64 `json:"query_count"` // Total queries + AverageQueryTime time.Duration `json:"average_query_time"` // Average query time + SuccessRate float64 `json:"success_rate"` // Query success rate + FragmentationRatio float64 `json:"fragmentation_ratio"` // Index fragmentation + LastOptimization time.Time `json:"last_optimization"` // Last optimization time } // BackupConfig represents backup configuration type BackupConfig struct { - Name string `json:"name"` // Backup name - Destination string `json:"destination"` // Backup destination - IncludeIndexes bool `json:"include_indexes"` // Include search indexes - IncludeCache bool `json:"include_cache"` // Include cache data - Compression bool `json:"compression"` // Enable compression - Encryption bool `json:"encryption"` // Enable encryption - EncryptionKey string `json:"encryption_key"` // Encryption key - Incremental bool `json:"incremental"` // Incremental backup - Retention time.Duration `json:"retention"` // Backup retention period - Metadata map[string]interface{} `json:"metadata"` // Additional metadata + Name string `json:"name"` // Backup name + Destination string `json:"destination"` // Backup destination + IncludeIndexes bool `json:"include_indexes"` // Include search indexes + IncludeCache bool `json:"include_cache"` // Include cache data + Compression bool `json:"compression"` // Enable compression + Encryption bool `json:"encryption"` // Enable encryption + EncryptionKey string `json:"encryption_key"` // Encryption key + Incremental bool `json:"incremental"` // Incremental backup + Retention time.Duration `json:"retention"` // Backup retention period + Metadata map[string]interface{} `json:"metadata"` // Additional metadata } // BackupInfo represents information about a backup type BackupInfo struct { - ID string `json:"id"` // Backup ID - Name string `json:"name"` // Backup name - CreatedAt time.Time `json:"created_at"` // Creation time - Size int64 `json:"size"` // Backup size - CompressedSize int64 `json:"compressed_size"` // Compressed size - ContextCount int64 `json:"context_count"` // Number of contexts - Encrypted bool `json:"encrypted"` // Whether encrypted - Incremental bool `json:"incremental"` // Whether incremental - ParentBackupID string `json:"parent_backup_id"` // Parent backup for incremental - Checksum string `json:"checksum"` // Backup checksum - Status BackupStatus `json:"status"` // Backup status - Metadata map[string]interface{} `json:"metadata"` // Additional metadata + ID string `json:"id"` // Backup ID + Name string `json:"name"` // Backup name + CreatedAt time.Time `json:"created_at"` // Creation time + Size int64 `json:"size"` // Backup size + CompressedSize int64 `json:"compressed_size"` // Compressed size + ContextCount int64 `json:"context_count"` // Number of contexts + Encrypted bool `json:"encrypted"` // Whether encrypted + Incremental bool `json:"incremental"` // Whether incremental + ParentBackupID string `json:"parent_backup_id"` // Parent backup for incremental + Checksum string `json:"checksum"` // Backup checksum + Status BackupStatus `json:"status"` // Backup status + Metadata map[string]interface{} `json:"metadata"` // Additional metadata } // BackupStatus represents backup status type BackupStatus string const ( - BackupInProgress BackupStatus = "in_progress" - BackupCompleted BackupStatus = "completed" - BackupFailed BackupStatus = "failed" - BackupCorrupted BackupStatus = "corrupted" + BackupStatusInProgress BackupStatus = "in_progress" + BackupStatusCompleted BackupStatus = "completed" + BackupStatusFailed BackupStatus = "failed" + BackupStatusCorrupted BackupStatus = "corrupted" ) +// DistributedStorageOptions aliases DistributedStoreOptions for backwards compatibility. +type DistributedStorageOptions = DistributedStoreOptions + // RestoreConfig represents restore configuration type RestoreConfig struct { - BackupID string `json:"backup_id"` // Backup to restore from - Destination string `json:"destination"` // Restore destination - OverwriteExisting bool `json:"overwrite_existing"` // Overwrite existing data - RestoreIndexes bool `json:"restore_indexes"` // Restore search indexes - RestoreCache bool `json:"restore_cache"` // Restore cache data - ValidateIntegrity bool `json:"validate_integrity"` // Validate data integrity - DecryptionKey string `json:"decryption_key"` // Decryption key - Metadata map[string]interface{} `json:"metadata"` // Additional metadata + BackupID string `json:"backup_id"` // Backup to restore from + Destination string `json:"destination"` // Restore destination + OverwriteExisting bool `json:"overwrite_existing"` // Overwrite existing data + RestoreIndexes bool `json:"restore_indexes"` // Restore search indexes + RestoreCache bool `json:"restore_cache"` // Restore cache data + ValidateIntegrity bool `json:"validate_integrity"` // Validate data integrity + DecryptionKey string `json:"decryption_key"` // Decryption key + Metadata map[string]interface{} `json:"metadata"` // Additional metadata } // BackupValidation represents backup validation results type BackupValidation struct { - BackupID string `json:"backup_id"` // Backup ID - Valid bool `json:"valid"` // Whether backup is valid - ChecksumMatch bool `json:"checksum_match"` // Whether checksum matches - CorruptedFiles []string `json:"corrupted_files"` // List of corrupted files - MissingFiles []string `json:"missing_files"` // List of missing files - ValidationTime time.Duration `json:"validation_time"` // Validation duration - ValidatedAt time.Time `json:"validated_at"` // When validated - ErrorCount int `json:"error_count"` // Number of errors - WarningCount int `json:"warning_count"` // Number of warnings + BackupID string `json:"backup_id"` // Backup ID + Valid bool `json:"valid"` // Whether backup is valid + ChecksumMatch bool `json:"checksum_match"` // Whether checksum matches + CorruptedFiles []string `json:"corrupted_files"` // List of corrupted files + MissingFiles []string `json:"missing_files"` // List of missing files + ValidationTime time.Duration `json:"validation_time"` // Validation duration + ValidatedAt time.Time `json:"validated_at"` // When validated + ErrorCount int `json:"error_count"` // Number of errors + WarningCount int `json:"warning_count"` // Number of warnings } // BackupSchedule represents automatic backup scheduling type BackupSchedule struct { - ID string `json:"id"` // Schedule ID - Name string `json:"name"` // Schedule name - Cron string `json:"cron"` // Cron expression - BackupConfig *BackupConfig `json:"backup_config"` // Backup configuration - Enabled bool `json:"enabled"` // Whether schedule is enabled - LastRun *time.Time `json:"last_run,omitempty"` // Last execution time - NextRun *time.Time `json:"next_run,omitempty"` // Next scheduled execution - ConsecutiveFailures int `json:"consecutive_failures"` // Consecutive failure count - MaxFailures int `json:"max_failures"` // Max allowed failures + ID string `json:"id"` // Schedule ID + Name string `json:"name"` // Schedule name + Cron string `json:"cron"` // Cron expression + BackupConfig *BackupConfig `json:"backup_config"` // Backup configuration + Enabled bool `json:"enabled"` // Whether schedule is enabled + LastRun *time.Time `json:"last_run,omitempty"` // Last execution time + NextRun *time.Time `json:"next_run,omitempty"` // Next scheduled execution + ConsecutiveFailures int `json:"consecutive_failures"` // Consecutive failure count + MaxFailures int `json:"max_failures"` // Max allowed failures } // BackupStatistics represents backup statistics @@ -370,4 +373,4 @@ type BackupStatistics struct { OldestBackup time.Time `json:"oldest_backup"` // Oldest backup time CompressionRatio float64 `json:"compression_ratio"` // Average compression ratio EncryptionEnabled bool `json:"encryption_enabled"` // Whether encryption is enabled -} \ No newline at end of file +}