store

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package store implements MountRepository on top of an embedded BadgerDB database, encrypted at rest, so mount intent and credentials survive a daemon restart.

Index

Constants

View Source
const CurrentSchemaVersion uint64 = 1

CurrentSchemaVersion is the schema version this build of irodsfsd writes. Bump it and add a corresponding entry to migrations whenever the on-disk record format changes.

Variables

View Source
var (
	ErrMountNotFound     = errors.New("mount not found")
	ErrMountIDConflict   = errors.New("mount ID is already in use")
	ErrMountPathConflict = errors.New("mount path is already in use")
)

Functions

This section is empty.

Types

type MountRecord

type MountRecord struct {
	Info *api.MountInfo

	// Tombstone marks a record whose Unmount has been accepted. A
	// tombstoned record is never restored as a fresh mount after a daemon
	// restart; only its unmount cleanup is resumed.
	Tombstone bool
}

MountRecord is the persisted, unredacted representation of one mount. Info.Config retains original iRODS/DAVFS credentials; callers must redact a copy before returning it through any API. Info.Config.MountPath is treated as immutable for the lifetime of a record.

type MountRepository

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

MountRepository persists MountRecords in a Store, keeping a canonical mount-path index alongside each record so mount-ID and mount-path uniqueness can be enforced within a single transaction. This is the only implementation of mount persistence, so it is exposed as a concrete type rather than behind an interface.

func NewMountRepository

func NewMountRepository(store *Store) *MountRepository

NewMountRepository returns a MountRepository backed by store.

func (*MountRepository) Close

func (repository *MountRepository) Close() error

Close releases the underlying Store.

func (*MountRepository) Create

func (repository *MountRepository) Create(ctx context.Context, record *MountRecord) error

Create stores a new mount record and reserves its canonical mount path atomically. It returns ErrMountIDConflict or ErrMountPathConflict if the mount ID or mount path is already in use by another record.

func (*MountRepository) Delete

func (repository *MountRepository) Delete(ctx context.Context, mountID string) error

Delete removes the mount record and its path index atomically. Deleting an unknown mount ID is not an error.

func (*MountRepository) Get

func (repository *MountRepository) Get(ctx context.Context, mountID string) (*MountRecord, error)

Get returns the stored record for mountID, or ErrMountNotFound.

func (*MountRepository) List

func (repository *MountRepository) List(ctx context.Context) ([]*MountRecord, error)

List returns every stored mount record in unspecified order.

func (*MountRepository) Update

func (repository *MountRepository) Update(ctx context.Context, record *MountRecord) error

Update replaces the stored record for record.Info.MountId. It returns ErrMountNotFound if no record exists for that ID.

type Store

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

Store owns one embedded, encrypted BadgerDB instance.

func Open

func Open(dataDir string, encryptionKey []byte) (*Store, error)

Open opens (creating if necessary) an encrypted BadgerDB database at dataDir and ensures its schema is current. Production startup must never fall back to plaintext, so an empty encryptionKey is rejected outright.

func (*Store) Close

func (store *Store) Close() error

Close closes the underlying database.

Jump to

Keyboard shortcuts

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