storage

package
v0.0.0-...-460841a Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GITType = Type("git")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Name     string
	Children []Entry
}

type Manager

type Manager interface {
	// Init creates storage locally
	Init(
		ctx context.Context,
		path string,
		remote maybe.Maybe[string],
		t Type,
	) (Storage, error)
	// Clone copies Storage from remote to path
	Clone(ctx context.Context, path string, remote string, t Type) (Storage, error)

	// Use local copy of store by path
	Use(ctx context.Context, path string) (Storage, error)

	// Remove local storage copy
	Remove(ctx context.Context, path string) error
}

Manager manages stores: create, delete, mount

type Storage

type Storage interface {
	// Store data to storage
	Store(ctx context.Context, path string, data []byte) error
	// Remove path from storage
	Remove(ctx context.Context, path string) error

	// Copy path in storage
	Copy(ctx context.Context, src, dst string) error
	// Move path in storage
	Move(ctx context.Context, src, dst string) error

	// Get data from storage
	Get(ctx context.Context, path string) (maybe.Maybe[[]byte], error)
	// GetLatest reruns latest version of object
	GetLatest(ctx context.Context, p string) (maybe.Maybe[[]byte], error)
	// List storage entries
	List(ctx context.Context, path string) ([]Entry, error)

	// AddRemote to storage. remoteAddr depends on storage implementation
	AddRemote(ctx context.Context, remoteName string, remoteAddr string) error
	// HasRemote reports that Storage has remote
	HasRemote(ctx context.Context) (bool, error)
	// Push storage to remote if there is one
	Push(ctx context.Context) error
	// Pull changes from remote
	Pull(ctx context.Context) error

	// Commit changes to storage. Semantics depends on storage implementation
	Commit(ctx context.Context, msg string) error
	// Rollback all uncommitted changes
	Rollback(ctx context.Context) error
}

type Type

type Type string

Jump to

Keyboard shortcuts

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