storage

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 30 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Local commands share the Profile and runtime constructors in this package.

Package storage binds shared CLI storage configuration and constructs owned runtimes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPaths

func DefaultPaths() (backendPath, metadataPath, cacheRoot string, err error)

DefaultPaths returns local backend, metadata and cache defaults for the current user.

func MetadataDiskSize

func MetadataDiskSize(path string) (int64, error)

MetadataDiskSize counts native database files before and after offline compaction.

func OpenCodec

func OpenCodec(opts *Profile) (codec.Codec, func() error, error)

OpenCodec creates the selected codec and returns its sole owner closer.

func PrintMetadataResult

func PrintMetadataResult(asJSON bool, result map[string]any) error

PrintMetadataResult renders the common offline metadata result fields.

func RedactS3Credentials

func RedactS3Credentials(settings map[string]any, prefix string)

Viper exposes nested settings maps. Redact both credential locations before config show prints either its text or JSON representation. RedactS3Credentials removes secrets recursively even from malformed or array configurations.

Types

type BackendConfig

type BackendConfig struct {
	Kind  string
	Root  string
	S3    backend.S3Config
	Array backend.ArrayConfig
	// contains filtered or unexported fields
}

BackendConfig is shared by exports and offline maintenance. Explicit remote object backends never fall back to an unrelated local directory.

func (*BackendConfig) Description

func (o *BackendConfig) Description() string

func (*BackendConfig) Flags

func (o *BackendConfig) Flags(flags *lfhflag.FlagSet, storageGroup, defaultRoot string)

func (*BackendConfig) Open

Open opens only the object backend. Use storage.Open for a complete core runtime with codec, metadata, cache and ownership locks. The caller owns any returned io.Closer and must close it after all backend users have stopped.

func (*BackendConfig) Validate

func (o *BackendConfig) Validate() error

type Budget

type Budget struct {
	Disk, Raw, Read, Quota, ChunkBytes int64
	Workers                            int
	Cache, Writeback                   bool
}

Budget is the parsed process resource envelope used to allocate namespace reservations. Profile retains the CLI spelling and all unrelated options.

type CodecConfig

type CodecConfig struct {
	Name, WorkerMode, WorkerSocket, WorkerBinary string
	WorkerProcs, Concurrency                     int
	Timeout                                      time.Duration
	MaxChunk                                     string
	GzipLevel, ZstdLevel                         int
	FPGAUser, FPGAH2C, FPGAC2H                   string
	FPGACores                                    int
	OpenGuard                                    func() error
}

CodecConfig is the execution configuration used by standalone compute nodes. It does not expose mount, cache, backend or daemon command options.

type Export

type Export struct {
	FileSystem  core.Access
	Description string
	// contains filtered or unexported fields
}

Export owns a local runtime or a remote file client and its optional local diagnostics service. Close drains diagnostics before releasing storage.

func OpenExport

func OpenExport(opts *Profile) (*Export, error)

func (*Export) Close

func (r *Export) Close() error

func (*Export) StartDiagnostics

func (r *Export) StartDiagnostics(path string) error

StartDiagnostics opens the local control endpoint after storage is ready. Remote clients do not expose local engine snapshots or start a control socket.

type FUSEConfig

type FUSEConfig struct {
	AllowOther, DefaultPermissions bool
	AllowDev                       bool
	// Kernel selects the FUSE kernel transport. "fuse" uses the standard
	// /dev/fuse module; "cpfs" uses the optional coexisting cpfs module.
	Kernel          string
	DirectIO        bool
	ReadDirPlusAuto bool
	// KernelMetadataCache requests coherent caching when mount owns the local
	// writer. The mount command checks the live core before enabling it.
	KernelMetadataCache bool
	UID, GID            int64

	MaxWrite int
	// contains filtered or unexported fields
}

FUSEConfig is shared by mount and the new-volume config writer. It does not change core's storage options or the credentials of the daemon process.

func (*FUSEConfig) Flags

func (o *FUSEConfig) Flags(f *lfhflag.FlagSet)

Flags binds export-specific FUSE mount, identity and permission options.

func (*FUSEConfig) Options

func (o *FUSEConfig) Options() (fuse.Options, error)

Options validates and constructs the FUSE adapter policy.

func (*FUSEConfig) Settings

func (o *FUSEConfig) Settings() map[string]any

Settings returns the FUSE configuration for new-volume configuration output.

type LocalSettings

type LocalSettings struct{ CachePath, SyncMode, HistoryMode string }

LocalSettings contains the storage paths and sync policy needed by offline commands.

type MaintenanceConfig

type MaintenanceConfig struct {
	BackendConfig
	MetadataSelection
	Path     string
	Prefix   string
	VolumeID string
	Snapshot string
	Block    bool
	JSON     bool
	Timeout  time.Duration
}

MaintenanceConfig binds the common offline metadata and backend input schema. Each maintenance command owns its own operation and lifecycle.

func (*MaintenanceConfig) Flags

func (opts *MaintenanceConfig) Flags(flags *lfhflag.FlagSet) error

Flags binds the shared offline metadata input without selecting or executing a command.

type MaintenancePolicy

type MaintenancePolicy struct{ RequireExisting, History bool }

MaintenancePolicy selects the existing offline normalization and history behavior.

type MetadataSelection

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

MetadataSelection keeps every command on the same engine/cache configuration.

func (*MetadataSelection) Flags

func (o *MetadataSelection) Flags(flags *lfhflag.FlagSet, group string)

Flags binds metadata engine and cache CLI/TOML options.

func (MetadataSelection) Options

func (o MetadataSelection) Options(path string) (meta.Options, error)

Options validates a native metadata engine configuration for the selected path.

type MountConfig

type MountConfig struct {
	Profile                       *Profile
	Mountpoint                    string
	Daemon, Foreground, AutoMount bool
	DaemonLog                     string
	StartupTimeout                time.Duration
}

MountConfig binds the shared export configuration used by mount, setup and boot registration.

func MountFlags

func MountFlags(name string, args []string) (*MountConfig, *lfhflag.FlagSet, error)

MountFlags binds the complete export schema without reading files or opening storage.

func ParseMount

func ParseMount(name string, args []string, gateway conf.GatewayOptions) (*MountConfig, *lfhflag.FlagSet, error)

ParseMount parses and validates configuration without opening storage or starting a process.

type NamespaceConfig

type NamespaceConfig struct {
	ID                string
	Backend           backend.Backend
	Metadata          meta.Engine
	Budget            *Budget
	Admission         func(context.Context) (func(), error)
	CoordinatedBackup bool
}

NamespaceConfig supplies borrowed resources owned by the enclosing Meta process. The namespace runtime owns neither the shared native engine nor its external writer lock; its Close still drains its own core and codec.

type PredictionOptions

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

PredictionOptions binds the compression predictor schema shared with standalone workers.

func (PredictionOptions) Build

func (o PredictionOptions) Build() (*codec.Predictor, error)

Build validates the predictor configuration and creates its runtime.

func (*PredictionOptions) Flags

func (o *PredictionOptions) Flags(flags *lfhflag.FlagSet, prefix string)

Flags binds CLI and TOML predictor options.

type Profile

type Profile struct {
	BackendConfig
	MetadataSelection
	FUSEConfig
	// contains filtered or unexported fields
}

Profile is one parsed invocation. CLI fields remain private; namespace runtimes derive isolated borrowed views through ForNamespace.

func Flags

func Flags(command string, blockMode bool) (*Profile, *lfhflag.FlagSet, error)

Flags keeps mount and blk on one config/codec/writeback implementation.

func NewCodecProfile

func NewCodecProfile(c CodecConfig) *Profile

NewCodecProfile binds standalone codec execution without mount or backend settings.

func (*Profile) ApplyGateway

func (opts *Profile) ApplyGateway(gateway conf.GatewayOptions, explicitServer bool)

ApplyGateway applies explicit global discovery while preserving an explicit --server override.

func (*Profile) BackupOptions

func (p *Profile) BackupOptions() option.MetadataBackupConfig

BackupOptions returns the backup policy for an already validated profile.

func (*Profile) Budget

func (p *Profile) Budget() (Budget, error)

Budget parses resource settings only when namespace resource allocation needs them.

func (*Profile) ChunkSize

func (p *Profile) ChunkSize() (int64, error)

func (*Profile) CodecName

func (p *Profile) CodecName() string

func (*Profile) ForMaintenance

func (p *Profile) ForMaintenance(policy MaintenancePolicy) *Profile

ForMaintenance clones a profile for offline CPU/raw access without a backup scheduler. Callers retain their original validation order before or after this policy change.

func (*Profile) ForNamespace

func (p *Profile) ForNamespace(n NamespaceConfig) *Profile

ForNamespace derives a view that borrows the enclosing process resources.

func (*Profile) ForNewVolume

func (p *Profile) ForNewVolume() *Profile

ForNewVolume requires creation under the writer lock without changing the input profile.

func (*Profile) HistoryConfig

func (o *Profile) HistoryConfig() (option.HistoryConfig, error)

HistoryConfig validates the configured history retention and journal policy.

func (*Profile) LocalCodec

func (p *Profile) LocalCodec(name string) (codec.Codec, func() error, error)

func (*Profile) MetadataClientCache

func (p *Profile) MetadataClientCache() (*option.MetadataCacheConfig, error)

MetadataClientCache parses the shared remote-client cache policy. Zero TTL selects strict reads and starts no cache or subscription worker.

func (*Profile) MetadataOptions

func (p *Profile) MetadataOptions() (meta.Options, error)

func (*Profile) MetadataPath

func (p *Profile) MetadataPath() string

func (*Profile) NamespaceID

func (p *Profile) NamespaceID() string

func (*Profile) Remote

func (p *Profile) Remote() RemoteConfig

func (*Profile) RemoteConsistency

func (p *Profile) RemoteConsistency() (option.ConsistencyConfig, error)

RemoteConsistency validates the authority policy before a remote open.

func (*Profile) Settings

func (p *Profile) Settings() LocalSettings

Settings returns parsed local paths and sync policy without additional validation.

func (*Profile) Validate

func (opts *Profile) Validate() error

Validate checks the parsed configuration and normalizes paths without starting a storage runtime. Remote profiles are accepted only by mount/blk.

func (*Profile) WithoutMetadataBackup

func (p *Profile) WithoutMetadataBackup() *Profile

WithoutMetadataBackup reserves snapshots for the enclosing coordinated capture, while preserving every other parsed setting.

func (*Profile) Workers

func (p *Profile) Workers() int

Workers returns the configured process worker count; zero selects the runtime default.

type RemoteConfig

type RemoteConfig struct {
	Server, Credentials, DataRoute string
	Consistency                    option.ConsistencyConfig
}

type Runtime

type Runtime struct {
	FileSystem *core.FileSystem
	Codec      codec.Codec
	Backend    backend.Backend
	// contains filtered or unexported fields
}

Runtime owns a local core, codec and resources it opened. Close drains the core before releasing codec, native DB and writer locks in reverse order.

func Open

func Open(opts *Profile) (_ *Runtime, err error)

Open creates a complete local runtime. BackendConfig.Open opens only the object backend and does not perform this ownership or core construction.

func OpenWithCodec

func OpenWithCodec(opts *Profile, primary codec.Codec, closeCodec func() error) (_ *Runtime, err error)

OpenWithCodec lets a server replace its new-write codec while keeping cache, staging, metadata and backend setup identical. Ownership of primary and closeCodec transfers to the returned runtime, including on setup errors. OpenWithCodec takes ownership of closeCodec immediately, including every early validation failure. Injected namespace resources remain borrowed.

func (*Runtime) Close

func (r *Runtime) Close() error

Jump to

Keyboard shortcuts

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