feat: wire context store scaffolding and dht test skeleton

This commit is contained in:
anthonyrawlins
2025-09-28 14:21:38 +10:00
parent d074520c30
commit ae021b47b9
7 changed files with 266 additions and 12 deletions

View File

@@ -0,0 +1,39 @@
package storage
import "context"
// noopBackupManager provides a BackupManager that performs no operations.
type noopBackupManager struct{}
// NewNoopBackupManager returns a no-op backup manager.
func NewNoopBackupManager() BackupManager {
return &noopBackupManager{}
}
func (n *noopBackupManager) CreateBackup(ctx context.Context, config *BackupConfig) (*BackupInfo, error) {
return &BackupInfo{Status: BackupStatusCompleted}, nil
}
func (n *noopBackupManager) RestoreBackup(ctx context.Context, backupID string, config *RestoreConfig) error {
return nil
}
func (n *noopBackupManager) ListBackups(ctx context.Context) ([]*BackupInfo, error) {
return []*BackupInfo{}, nil
}
func (n *noopBackupManager) DeleteBackup(ctx context.Context, backupID string) error {
return nil
}
func (n *noopBackupManager) ValidateBackup(ctx context.Context, backupID string) (*BackupValidation, error) {
return &BackupValidation{BackupID: backupID, Valid: true}, nil
}
func (n *noopBackupManager) ScheduleBackup(ctx context.Context, schedule *BackupSchedule) error {
return nil
}
func (n *noopBackupManager) GetBackupStats(ctx context.Context) (*BackupStatistics, error) {
return &BackupStatistics{}, nil
}

View File

@@ -0,0 +1,46 @@
package storage
import (
"context"
"time"
)
// noopCacheManager satisfies CacheManager when external cache infrastructure is unavailable.
type noopCacheManager struct{}
// NewNoopCacheManager returns a cache manager that always misses and performs no persistence.
func NewNoopCacheManager() CacheManager {
return &noopCacheManager{}
}
func (n *noopCacheManager) Get(ctx context.Context, key string) (interface{}, bool, error) {
return nil, false, nil
}
func (n *noopCacheManager) Set(ctx context.Context, key string, data interface{}, ttl time.Duration) error {
return nil
}
func (n *noopCacheManager) Delete(ctx context.Context, key string) error {
return nil
}
func (n *noopCacheManager) DeletePattern(ctx context.Context, pattern string) error {
return nil
}
func (n *noopCacheManager) Clear(ctx context.Context) error {
return nil
}
func (n *noopCacheManager) Warm(ctx context.Context, keys []string) error {
return nil
}
func (n *noopCacheManager) GetCacheStats() (*CacheStatistics, error) {
return &CacheStatistics{}, nil
}
func (n *noopCacheManager) SetCachePolicy(policy *CachePolicy) error {
return nil
}

View File

@@ -0,0 +1,24 @@
package storage
import "context"
// noopEventNotifier implements EventNotifier with no side effects.
type noopEventNotifier struct{}
// NewNoopEventNotifier returns a no-op event notifier implementation.
func NewNoopEventNotifier() EventNotifier {
return &noopEventNotifier{}
}
func (n *noopEventNotifier) NotifyStored(ctx context.Context, event *StorageEvent) error { return nil }
func (n *noopEventNotifier) NotifyRetrieved(ctx context.Context, event *StorageEvent) error {
return nil
}
func (n *noopEventNotifier) NotifyUpdated(ctx context.Context, event *StorageEvent) error { return nil }
func (n *noopEventNotifier) NotifyDeleted(ctx context.Context, event *StorageEvent) error { return nil }
func (n *noopEventNotifier) Subscribe(ctx context.Context, eventType EventType, handler EventHandler) error {
return nil
}
func (n *noopEventNotifier) Unsubscribe(ctx context.Context, eventType EventType, handler EventHandler) error {
return nil
}

View File

@@ -0,0 +1,43 @@
package storage
import "context"
// noopIndexManager satisfies the IndexManager interface without maintaining indexes.
type noopIndexManager struct{}
// NewNoopIndexManager returns a no-op index manager implementation.
func NewNoopIndexManager() IndexManager {
return &noopIndexManager{}
}
func (n *noopIndexManager) CreateIndex(ctx context.Context, indexName string, config *IndexConfig) error {
return nil
}
func (n *noopIndexManager) UpdateIndex(ctx context.Context, indexName string, key string, data interface{}) error {
return nil
}
func (n *noopIndexManager) DeleteFromIndex(ctx context.Context, indexName string, key string) error {
return nil
}
func (n *noopIndexManager) Search(ctx context.Context, indexName string, query *SearchQuery) (*SearchResults, error) {
return &SearchResults{Query: query, Results: []*SearchResult{}}, nil
}
func (n *noopIndexManager) RebuildIndex(ctx context.Context, indexName string) error {
return nil
}
func (n *noopIndexManager) OptimizeIndex(ctx context.Context, indexName string) error {
return nil
}
func (n *noopIndexManager) GetIndexStats(ctx context.Context, indexName string) (*IndexStatistics, error) {
return &IndexStatistics{Name: indexName}, nil
}
func (n *noopIndexManager) ListIndexes(ctx context.Context) ([]string, error) {
return []string{}, nil
}