storage

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MaxObjectSize = 100 * 1024 * 1024 // 100 MB

MaxObjectSize is the maximum size of a single object that can be stored. Objects larger than this are rejected to prevent memory exhaustion.

Variables

This section is empty.

Functions

This section is empty.

Types

type Orchestrator

type Orchestrator struct {
	// contains filtered or unexported fields
}

Orchestrator routes storage operations to registered providers based on capability negotiation and user-defined policies.

Per-operation timeouts wrap every provider call so a hung provider cannot block the caller indefinitely. Set via StorageTimeouts, defaulting to 30s reads, 5m writes, 30s deletes.

func NewOrchestrator

func NewOrchestrator(reg contracts.Registry) *Orchestrator

NewOrchestrator creates an Orchestrator that uses the given registry for provider discovery. Default timeouts: 30s read/delete, 5m write.

func (*Orchestrator) AddPolicy

func (o *Orchestrator) AddPolicy(p RoutingPolicy)

AddPolicy registers a routing policy.

func (*Orchestrator) CapabilityCheck

func (o *Orchestrator) CapabilityCheck(ctx context.Context, key string) ([]string, error)

func (*Orchestrator) Delete

func (o *Orchestrator) Delete(ctx context.Context, key string) error

func (*Orchestrator) DiscoverCache added in v0.2.0

func (o *Orchestrator) DiscoverCache()

DiscoverCache finds a cache module from the registry and sets it as the read-through cache. If no cache module is registered, the orchestrator operates without a cache.

func (*Orchestrator) DiscoverStorage added in v0.2.0

func (o *Orchestrator) DiscoverStorage() error

DiscoverStorage finds all registered storage modules and adds them to the pool.

func (*Orchestrator) Exists

func (o *Orchestrator) Exists(ctx context.Context, key string) (bool, error)

func (*Orchestrator) Get

func (o *Orchestrator) Get(ctx context.Context, key string) (io.ReadCloser, error)

func (*Orchestrator) List

func (o *Orchestrator) List(ctx context.Context, prefix string) ([]contracts.ObjectInfo, error)

func (*Orchestrator) Move

func (o *Orchestrator) Move(ctx context.Context, src, dst string) error

func (*Orchestrator) ProviderCount

func (o *Orchestrator) ProviderCount() int

func (*Orchestrator) ProviderInfo added in v0.4.0

func (o *Orchestrator) ProviderInfo() []StorageProviderInfo

ProviderInfo returns metadata for all registered storage providers.

func (*Orchestrator) Put

func (o *Orchestrator) Put(ctx context.Context, key string, data io.Reader, size int64) error

func (*Orchestrator) SetAuditLogger added in v0.4.0

func (o *Orchestrator) SetAuditLogger(a contracts.AuditLogger)

SetAuditLogger attaches an audit logger for recording storage operations.

func (*Orchestrator) SetCache

func (o *Orchestrator) SetCache(c contracts.CacheLayer)

SetCache directly sets the cache layer (for testing or forced override).

func (*Orchestrator) SetTimeouts added in v0.4.0

func (o *Orchestrator) SetTimeouts(t StorageTimeouts)

SetTimeouts configures per-operation deadlines. Zero values keep the current default. Call before any storage operations begin.

func (*Orchestrator) Stat

func (*Orchestrator) Stream added in v0.4.0

func (o *Orchestrator) Stream(ctx context.Context, key string, offset, length int64) (io.ReadCloser, error)

Stream reads a byte range from a storage object. If the routed provider implements Streamable, it uses that for efficient range requests. Otherwise falls back to Get() with a full read and slice. This enables progressive download and in-RAM streaming without requiring every provider to implement range requests.

func (*Orchestrator) WatchModules added in v0.4.0

func (o *Orchestrator) WatchModules(bus contracts.EventBus) (cancel func())

WatchModules subscribes to module.registered events and automatically re-discovers storage providers and cache layers when new modules appear. Call this after bootstrap to enable dynamic provider registration. The returned cancel function stops watching.

type RoutingPolicy

type RoutingPolicy struct {
	Name     string
	Prefix   string
	Provider string
}

RoutingPolicy decides which provider handles a given key.

type StorageProviderInfo added in v0.4.0

type StorageProviderInfo struct {
	ID           string   `json:"id"`
	Capabilities []string `json:"capabilities"`
	IsCache      bool     `json:"is_cache"`
}

StorageProviderInfo describes a registered storage provider for the admin API.

type StorageTimeouts added in v0.4.0

type StorageTimeouts struct {
	Read   time.Duration // Get, Exists, Stat, List, Stream
	Write  time.Duration // Put
	Delete time.Duration // Delete, Move
}

StorageTimeouts holds per-operation deadline durations for the orchestrator.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL