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 ConsistencyConfig
- type ConsistencyMode
- type HistoryConfig
- type HomeWriter
- type MetadataBackupConfig
- type MetadataCacheConfig
- type Option
- func WithCache(encoded *cache.Cache) Option
- func WithChunkAdmission(admit func(context.Context) (func(), error)) 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 WithRemote(remote RemoteConfig) Option
- func WithRemoteConsistency(consistency ConsistencyConfig) Option
- func WithStaging(raw *writer.Store) Option
- func WithStatFSMode(mode string) Option
- func WithSyncBackend(enabled bool) Option
- func WithWorkers(workers int) Option
- func WithWriteQueue(size int) Option
- func WithoutHistory() Option
- func WithoutMetadataBackup() Option
- type ReadConfig
- type RemoteConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Remote *RemoteConfig
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
// ChunkAdmission optionally shares a process-wide background chunk budget.
// Each accepted task must release its permit, including on failure.
ChunkAdmission func(context.Context) (func(), error)
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
// StatFSMode selects capacity accounting: logical (the default) reports
// namespace usage, while physical reports the backend's filesystem pools.
// This only changes reporting; it does not change quota admission.
StatFSMode string
// 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 ConsistencyConfig ¶ added in v1.0.3
type ConsistencyConfig struct {
Mode ConsistencyMode `json:"mode,omitempty" toml:"mode,omitempty"`
HomeEpoch string `json:"home_epoch,omitempty" toml:"home_epoch,omitempty"`
MinSeq uint64 `json:"min_seq,omitempty" toml:"min_seq,omitempty"`
}
ConsistencyConfig is shared by FUSE, Afero and blk remote opens. Empty Mode normalizes to strict. HomeEpoch and MinSeq are optional fences and do not create a local journal or change fsync acknowledgement boundaries.
func (ConsistencyConfig) HomeWriter ¶ added in v1.0.3
func (c ConsistencyConfig) HomeWriter() HomeWriter
HomeWriter returns the requested authority fence in a stable value type.
func (ConsistencyConfig) Normalize ¶ added in v1.0.3
func (c ConsistencyConfig) Normalize() (ConsistencyConfig, error)
Normalize validates and canonicalizes the policy before a client starts.
type ConsistencyMode ¶ added in v1.0.3
type ConsistencyMode string
ConsistencyMode selects the metadata admission policy used by a remote client. Strict is the zero/default policy; eventual is an explicit opt-in for callers that are prepared to observe a boundedly stale replica.
const ( ConsistencyStrict ConsistencyMode = "strict" ConsistencyEventual ConsistencyMode = "eventual" )
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 HomeWriter ¶ added in v1.0.3
type HomeWriter struct {
Epoch string `json:"epoch,omitempty" toml:"epoch,omitempty"`
MinSeq uint64 `json:"min_seq,omitempty" toml:"min_seq,omitempty"`
}
HomeWriter identifies the authority generation and sequence a client is willing to use. The fields are a fence: a server from an older HomeEpoch or below MinSeq must not be installed during initial connect or reconnect. Durable sequencing and outbox replay remain server responsibilities.
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 MetadataCacheConfig ¶ added in v1.0.3
MetadataCacheConfig enables a bounded remote-client metadata replica. Reads may observe another client's prior state until invalidation arrives or TTL expires. It does not change mutation or fsync acknowledgement boundaries. A nil RemoteConfig.MetadataCache preserves strict remote reads.
func (MetadataCacheConfig) Normalize ¶ added in v1.0.3
func (c MetadataCacheConfig) Normalize() (MetadataCacheConfig, error)
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 WithChunkAdmission ¶ added in v1.0.3
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 WithRemote ¶ added in v1.0.3
func WithRemote(remote RemoteConfig) Option
WithRemote selects a remote core.Access through clusterfs.Open.
func WithRemoteConsistency ¶ added in v1.0.3
func WithRemoteConsistency(consistency ConsistencyConfig) Option
WithRemoteConsistency updates only the remote consistency policy. It keeps the option useful for callers that construct a Config in stages while retaining all other RemoteConfig fields.
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 WithStatFSMode ¶ added in v1.0.3
WithStatFSMode selects logical (the default) or physical capacity reporting. Core validates the mode; this setting does not change write admission.
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.
type RemoteConfig ¶ added in v1.0.3
type RemoteConfig struct {
// NamespaceID asserts the authenticated namespace; it cannot select another one.
NamespaceID string
Server, CredentialsFile string
DataRoute string
ClusterID, NodeID, AccessKeyID, SecretAccessKey string
HTTPClient *http.Client
// Consistency is normalized by files.Dial. Empty mode is strict.
Consistency ConsistencyConfig
// MetadataCache is an explicit bounded-staleness client cache. Nil keeps
// each metadata read on the authoritative server's normal admission path.
MetadataCache *MetadataCacheConfig
}
RemoteConfig selects the authoritative server when opening storage through clusterfs.Open. It is shared by FUSE, Afero and blk; no client namespace or local storage workers are started. CredentialsFile is a role-scoped JSON identity; explicit fields take precedence. Server may override its URL.