filerepo

package
v0.0.0-...-579b097 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repo

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

Repo manages filesystem operations for saving files marked by the fileSuffix in order to support crash fault tolerance for components that need it by maintaining a file repo structure storing intermediate state.

func New

func New(repoParentDir, fileSuffix string) (*Repo, error)

New initializes a new file repo at repoParentDir/fileSuffix. All file system operations on the returned file repo are thread safe.

func (*Repo) FileToBaseName

func (r *Repo) FileToBaseName(fileName string) string

FileToBaseName strips the suffix from the file name to get the associated channel name.

func (*Repo) List

func (r *Repo) List() ([]string, error)

List parses the directory and produce a list of file names, filtered by suffix.

func (*Repo) Read

func (r *Repo) Read(baseName string) ([]byte, error)

Read reads the file in the fileRepo associated with baseName's contents.

func (*Repo) Remove

func (r *Repo) Remove(baseName string) error

Remove removes the file associated with baseName from the file system.

func (*Repo) Save

func (r *Repo) Save(baseName string, content []byte) error

Save atomically persists the content to suffix/baseName+suffix file by first writing it to a tmp file marked by the transientFileMarker and then moves the file to the final destination indicated by the FileSuffix.

Jump to

Keyboard shortcuts

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