arklocal

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package arklocal implements ark.Backend on the local filesystem.

Objects live under <dir>/<namespace>/<name>, where the namespace is ark.HandleType.String(). Chunks are sharded two levels deep by the first four characters of their name: chunks/aa/bb/<name>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

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

Backend implements ark.Backend backed by a directory tree.

func New

func New(dir string) (*Backend, error)

New creates or opens a local backend rooted at dir. The directory (and its parents) is created if it does not already exist.

func (*Backend) BasePath

func (b *Backend) BasePath() string

BasePath returns the root directory of the local backend.

func (*Backend) Close

func (b *Backend) Close() error

Close releases the root directory. The backend cannot Sync afterwards.

func (*Backend) Delete

func (b *Backend) Delete(ctx context.Context, h ark.Handle) error

Delete removes the object identified by h. A missing object is not an error. The removal becomes durable with the next Sync.

func (*Backend) Exists

func (b *Backend) Exists(ctx context.Context, h ark.Handle) (bool, error)

Exists reports whether the object identified by h is present.

func (*Backend) Get

func (b *Backend) Get(ctx context.Context, h ark.Handle) (io.ReadCloser, error)

Get opens the object stored under h.

func (*Backend) List

func (b *Backend) List(ctx context.Context, t ark.HandleType, fn func(ark.BlobInfo) error) error

List walks the namespace of t and calls fn for every object it holds. An absent namespace is empty, not an error.

func (*Backend) Put

func (b *Backend) Put(ctx context.Context, h ark.Handle, r io.Reader) error

Put writes r to a temporary file in the target directory and renames it into place, so a reader never sees a partial object. Nothing is flushed to disk: the object becomes durable with the next Sync.

func (*Backend) Stat

func (b *Backend) Stat(ctx context.Context, h ark.Handle) (ark.BlobInfo, error)

Stat returns metadata for the object stored under h.

func (*Backend) Sync added in v0.2.0

func (b *Backend) Sync(ctx context.Context) error

Sync flushes the filesystem holding the backend root, which makes every Put and Delete that returned before the call durable. On Linux that is syncfs on the root directory; when it fails for any reason, the global sync takes over, so Sync never skips the flush silently. On macOS it is the global sync from the start.

Jump to

Keyboard shortcuts

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