pyramid

package
v1.45.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFileTracker added in v0.82.0

func NewFileTracker(delete deleteCallback) *fileTracker

Types

type FS

type FS interface {
	// Create creates a new file in the FS.
	// It will only be persistent after the returned file is stored.
	Create(ctx context.Context, namespace string) (StoredFile, error)

	// Open finds the referenced file and returns its read-only File.
	// If file isn't in the local disk, it is fetched from the block storage.
	Open(ctx context.Context, namespace, filename string) (File, error)

	// Exists returns true if filename currently exists on block storage.
	Exists(ctx context.Context, namespace, filename string) (bool, error)

	// GetRemoteURI returns the URI for filename on block storage.  That URI might not
	// resolve if filename does not exist.
	GetRemoteURI(ctx context.Context, namespace, filename string) (string, error)
}

FS is pyramid abstraction of filesystem where the persistent storage-layer is the block storage. Files on the local disk are transient and might be cleaned up by the eviction policy. File structure under a namespace and namespace itself are flat (no directories).

func NewFS

func NewFS(c *params.InstanceParams) (FS, error)

NewFS creates a new TierFS. It will traverse the existing local folders and will update the local disk cache to reflect existing files.

type File

type File interface {
	io.Reader
	io.Writer
	io.Closer
	io.ReaderAt
	Sync() error
	Stat() (os.FileInfo, error)
}

File is pyramid abstraction for an os.File

type ROFile

type ROFile struct {
	*os.File
	// contains filtered or unexported fields
}

ROFile is pyramid wrapper for os.File that implements io.ReadCloser with hooks for updating evictions.

func (*ROFile) Read

func (f *ROFile) Read(p []byte) (n int, err error)

func (*ROFile) ReadAt

func (f *ROFile) ReadAt(p []byte, off int64) (n int, err error)

func (*ROFile) Stat

func (f *ROFile) Stat() (os.FileInfo, error)

func (*ROFile) Sync

func (f *ROFile) Sync() error

func (*ROFile) Write

func (f *ROFile) Write(p []byte) (n int, err error)

type StoredFile

type StoredFile interface {
	File

	// Store - Successful operation guarantees that the file is persistent.
	// If the file wasn't closed, Store closes it.
	Store(ctx context.Context, filename string) error

	// Abort removes all traces of the file from the filesystem.
	// It's allowed to call Abort on the file at any stage, unless the file was already stored.
	Abort(ctx context.Context) error
}

StoredFile is pyramid abstraction for an os.File with a Store operation that makes the file persistent

type TierFS

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

TierFS is a filesystem where written files are never edited. All files are stored in the block storage. Local paths are treated as a cache layer that will be evicted according to the eviction control.

func (*TierFS) Create

func (tfs *TierFS) Create(_ context.Context, namespace string) (StoredFile, error)

Create creates a new file in TierFS. File isn't stored in TierFS until a successful close operation. Open(namespace, filename) calls will return an error before the close was called. Create only performs local operations so it ignores the context.

func (*TierFS) Exists

func (tfs *TierFS) Exists(ctx context.Context, namespace, filename string) (bool, error)

func (*TierFS) GetRemoteURI

func (tfs *TierFS) GetRemoteURI(_ context.Context, _, filename string) (string, error)

func (*TierFS) Open

func (tfs *TierFS) Open(ctx context.Context, namespace, filename string) (File, error)

Open returns a file descriptor to the local file. If the file is missing from the local disk, it will try to fetch it from the block storage.

type WRFile

type WRFile struct {
	*os.File
	// contains filtered or unexported fields
}

WRFile pyramid wrapper for os.file that triggers pyramid hooks for file actions.

func (*WRFile) Abort

func (f *WRFile) Abort(ctx context.Context) error

Abort deletes the file and cleans all traces of it. If file was already stored, returns an error.

func (*WRFile) Store

func (f *WRFile) Store(ctx context.Context, filename string) error

Store copies the closed file to all tiers of the pyramid.

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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