atomicfs

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadMarker

func ReadMarker(fs vfs.FS, dir, markerName string) (string, error)

ReadMarker looks up the current state of a marker returning just the current value of the marker. Callers that may need to move the marker should use LocateMarker.

Types

type Marker

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

A Marker provides an interface for marking a single file on the filesystem. The marker may be atomically moved from name to name. Marker is not safe for concurrent use. Multiple processes may not read or move the same marker simultaneously. An Marker may only be constructed through LocateMarker.

Marker names must be unique within the directory.

func LocateMarker

func LocateMarker(fs vfs.FS, dir, markerName string) (*Marker, string, error)

LocateMarker loads the current state of a marker. It returns a handle to the Marker that may be used to move the marker and the current value of the marker.

func (*Marker) Close

func (a *Marker) Close() error

Close releases all resources in use by the marker.

func (*Marker) Move

func (a *Marker) Move(filename string) error

Move atomically moves the marker to mark the provided filename. If Move returns a nil error, the new marker value is guaranteed to be persisted to stable storage. If Move returns an error, the current value of the marker may be the old value or the new value. Callers may retry a Move error.

If an error occurs while syncing the directory, Move panics.

The provided filename does not need to exist on the filesystem.

func (*Marker) NextIter

func (a *Marker) NextIter() uint64

NextIter returns the next iteration number that the marker will use. Clients may use this number for formulating filenames that are unused.

func (*Marker) RemoveObsolete

func (a *Marker) RemoveObsolete() error

RemoveObsolete removes any obsolete files discovered while locating the marker or files unable to be removed during Move.

Jump to

Keyboard shortcuts

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