fs

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package fs provides the filesystem abstraction layer for pulse storage backends.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

Config holds filesystem configuration for Pulse storage operations. The FS field uses afero.Fs as the interface contract, enabling transparent swapping between real OS filesystems and in-memory implementations for testing.

Extension hook: callers can inject any afero.Fs implementation via WithFs to support custom storage backends (e.g., encrypted FS, remote mounts).

func Default

func Default() (*Config, error)

Default returns an OsFs rooted at the directory specified by the PULSE_DATA_DIR environment variable. Returns an error if the variable is empty or unset.

func New

func New(opts ...Option) (*Config, error)

New creates a configured filesystem with the given options. If no FS is injected, an OsFs rooted at the data directory is created. If no DataDir is set, it is not resolved from the environment (use Default for that).

func NewMemMap

func NewMemMap() *Config

NewMemMap returns a Config backed by an in-memory MemMapFs. Intended for testing; the DataDir is empty.

func (*Config) DataDir

func (c *Config) DataDir() string

DataDir returns the resolved data directory path.

func (*Config) Fs

func (c *Config) Fs() afero.Fs

Fs returns the configured filesystem.

type Option

type Option func(*Config)

Option configures a Config during construction.

func WithDataDir

func WithDataDir(dir string) Option

WithDataDir sets an explicit data directory path. This takes precedence over the PULSE_DATA_DIR environment variable.

func WithFs

func WithFs(fs afero.Fs) Option

WithFs injects a custom afero.Fs implementation. When set, the filesystem is used as-is without wrapping in BasePathFs.

Jump to

Keyboard shortcuts

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