Documentation
¶
Overview ¶
Package option defines storage settings shared by all compactfs exports. Apply them when constructing core.FileSystem, then pass that engine to FUSE, Afero or blk. Options never reconfigure an engine that is already running.
Index ¶
- type Config
- type HistoryConfig
- type MetadataBackupConfig
- type Option
- func WithCache(encoded *cache.Cache) Option
- func WithChunkRetry(attempts int, backoff time.Duration) Option
- func WithChunkSize(size int) Option
- func WithChunking(chunking chunk.ChunkingOptions) Option
- func WithChunks(store *chunk.Store) Option
- func WithDirectoryPageSize(size int) Option
- func WithHistory(history HistoryConfig) Option
- func WithMetadata(metadata meta.Options) Option
- func WithMetadataBackup(backup MetadataBackupConfig) Option
- func WithNamespace(namespace *meta.Namespace) Option
- func WithQuotaBytes(size int64) Option
- func WithRead(read ReadConfig) Option
- func WithStaging(raw *writer.Store) Option
- func WithSyncBackend(enabled bool) Option
- func WithWorkers(workers int) Option
- func WithWriteQueue(size int) Option
- func WithoutHistory() Option
- func WithoutMetadataBackup() Option
- type ReadConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Namespace *meta.Namespace
// Metadata selects a native database opened and owned by core. Use either
// Metadata or an injected Namespace, never both. Nil does not open a DB.
Metadata *meta.Options
Chunks *chunk.Store
Cache *cache.Cache
Staging *writer.Store
// SyncBackend sets the minimum file-sync durability for every export.
// With Staging and false, sync may stop at recoverable local storage.
// An individual sync request may strengthen this boundary, never weaken it.
SyncBackend bool
ChunkSize int
// Chunking controls backend subdivision; raw cache windows stay ChunkSize.
// The zero value keeps fixed chunks; FastCDC is explicitly enabled.
Chunking chunk.ChunkingOptions
// DirectoryPageSize bounds attributes retained per directory handle. Zero
// selects meta.DefaultDirectoryPageSize; the maximum is meta.MaxDirectoryPageSize.
DirectoryPageSize int
Workers int
WriteQueue int
ChunkAttempts int
ChunkRetryBackoff time.Duration
// Read controls decoded backend caching and sequential read ahead. Nil
// selects bounded defaults, independently of the optional SSD cache.
Read *ReadConfig
// QuotaBytes limits the sum of logical file sizes in the namespace. Zero is
// unlimited; compressed backend bytes are reported separately by quota.
QuotaBytes int64
// MetadataBackup enables periodic standalone metadata snapshots in Backend.
// Nil leaves scheduling to the embedding application.
MetadataBackup *MetadataBackupConfig
History *HistoryConfig
}
Config is the shared storage configuration, independent of export protocol. The caller owns injected resources and must close the engine before them. Core supplies defaults and validates the final configuration before use.
type HistoryConfig ¶ added in v1.0.2
type HistoryConfig struct {
MaxVersions int
MaxAge time.Duration
MaxBytes int64
Mode string
JournalBytes int64
// JournalCodec is minlz (default) or raw. This only encodes local log
// records; the selected backend chunk algorithm remains independent.
JournalCodec string
}
HistoryConfig bounds optional PRE-operation versions. Mode="backend" (the default) synchronizes every write to backend. Mode="journal" appends local byte deltas, follows the ordinary fsync boundary, and requires Staging. JournalBytes bounds its local log separately from the raw cache (64 MiB by default). Nil Config.History leaves the original asynchronous path unchanged.
func (HistoryConfig) Normalize ¶ added in v1.0.2
func (h HistoryConfig) Normalize() (meta.HistoryRetention, error)
type MetadataBackupConfig ¶
type MetadataBackupConfig struct {
Interval time.Duration
Timeout time.Duration
Retention int
Prefix string
TempDir string
}
MetadataBackupConfig enables standalone binary metadata backups in Backend. Zero values select a five-minute interval, ten-minute timeout, seven retained images, the metadata/backups prefix and the system temporary directory.
type Option ¶
type Option func(*Config)
Option updates a storage configuration before core.New starts its workers. Options apply from left to right after Config; the last setting wins. A list can be reused with any export, but injected resources keep their own ownership rules and a chunk.Store belongs to one live engine.
func WithCache ¶
WithCache sets the engine's encoded-object disk cache. Nil supplies no cache; it does not clear a separate cache already configured directly on Chunks.
func WithChunkRetry ¶
WithChunkRetry sets retry defaults for a Store whose own retry fields are zero.
func WithChunkSize ¶
WithChunkSize selects the raw addressing window in bytes; zero uses the core default. Existing volumes require their original window size.
func WithChunking ¶
func WithChunking(chunking chunk.ChunkingOptions) Option
WithChunking selects fixed or content-defined backend chunks for a new volume. Core normalizes the bounds and verifies them when reopening.
func WithChunks ¶
WithChunks injects the object store, codec, fallback and optional decoders. The option does not modify or copy the store; core initializes it once.
func WithDirectoryPageSize ¶
WithDirectoryPageSize bounds per-handle metadata pages for FUSE and Afero. Zero selects 256; the largest permitted page is 4096 entries.
func WithHistory ¶ added in v1.0.2
func WithHistory(history HistoryConfig) Option
WithHistory enables per-operation versions shared by all exports. Backend mode confirms every write remotely; journal mode follows the fsync boundary.
func WithMetadata ¶
WithMetadata selects a bbolt or Pebble database which core.New opens and core.Close closes. Auto detects an existing database; a new path defaults to bbolt. This replaces an injected namespace without opening any resources here. The application must exclude other writers for the lifetime of the core.
func WithMetadataBackup ¶
func WithMetadataBackup(backup MetadataBackupConfig) Option
WithMetadataBackup opts in to automatic backend snapshots. A zero config selects the backup defaults; the metadata engine must support snapshots.
func WithNamespace ¶
WithNamespace injects the authoritative metadata namespace.
func WithQuotaBytes ¶
WithQuotaBytes limits logical file sizes; zero is unlimited.
func WithRead ¶
func WithRead(read ReadConfig) Option
WithRead sets decoded caching and prefetch. ReadConfig{} disables both.
func WithStaging ¶
WithStaging sets the durable raw writeback cache. Nil selects direct backend writes; removing an existing raw cache requires draining its dirty data first.
func WithSyncBackend ¶
WithSyncBackend requires file syncs in every export to wait for backend persistence. False permits local durability when a raw cache is configured.
func WithWorkers ¶
WithWorkers selects local raw and background upload concurrency.
func WithWriteQueue ¶
WithWriteQueue selects the bounded raw/encoding queue capacity.
func WithoutHistory ¶ added in v1.0.2
func WithoutHistory() Option
WithoutHistory disables future recording; retained versions remain readable.
func WithoutMetadataBackup ¶
func WithoutMetadataBackup() Option
WithoutMetadataBackup disables a previously configured backup scheduler.
type ReadConfig ¶
type ReadConfig struct {
CacheBytes int64
Workers int
Ahead int
// RawRefill asynchronously retains decoded backend data in the optional
// raw SSD cache. Nil Config.Read enables it; explicit ReadConfig opts in.
RawRefill bool
}
ReadConfig controls decoded caching and raw SSD refill. Nil in Config selects 128 MiB, four concurrent loads and four chunks of sequential read ahead. CacheBytes=0 disables this cache and read ahead. Ahead=0 disables only read ahead. The byte limit includes cached data and reserved raw load bytes; callers can retain returned slices until their read replies complete.