object

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotExist is an error value which may be tested against to determine
	// whether a method invocation from a Store instance failed due to being
	// called on an object which did not exist.
	ErrNotExist = fs.ErrNotExist

	// ErrReadOnly is an error returned when attempting to create an object in
	// a read-only store.
	ErrReadOnly = errors.New("read only object store")
)

Functions

func AppendTags

func AppendTags(buf []byte, tags ...Tag) []byte

Types

type Filter

type Filter = query.Filter[*Info]

Filter represents a predicate applicated to objects to determine whether they are part of the result of a ListObject operation.

func AFTER

func AFTER(t time.Time) Filter

func AND

func AND(f1, f2 Filter) Filter

func BEFORE

func BEFORE(t time.Time) Filter

func MATCH

func MATCH(name, value string) Filter

func NOT

func NOT(f Filter) Filter

func OR

func OR(f1, f2 Filter) Filter

type Info

type Info struct {
	Name      string
	Size      int64
	CreatedAt time.Time
	Tags      []Tag
}

The Info type represents the set of meta data associated with an object within a store.

func (*Info) After

func (info *Info) After(t time.Time) bool

func (*Info) Before

func (info *Info) Before(t time.Time) bool

func (*Info) Lookup

func (info *Info) Lookup(name string) (string, bool)

func (*Info) Match

func (info *Info) Match(name, value string) bool

type Store

type Store interface {
	// Creates an object with the given name, initializing its content to the
	// data read from the given io.Reader.
	//
	// The creation of objects is atomic, the store must be left unchanged if
	// an error occurs that would cause the object to be only partially created.
	CreateObject(ctx context.Context, name string, data io.Reader, tags ...Tag) error

	// Reads an existing object from the store, returning a reader exposing its
	// content.
	ReadObject(ctx context.Context, name string) (io.ReadSeekCloser, error)

	// Retrieves information about an object in the store.
	StatObject(ctx context.Context, name string) (Info, error)

	// Lists existing objects.
	//
	// Objects that are being created by a call to CreateObject are not visible
	// until the creation completed.
	ListObjects(ctx context.Context, prefix string, filters ...Filter) stream.ReadCloser[Info]

	// Deletes and object from the store.
	//
	// The deletion is idempotent, deleting an object which does not exist does
	// not cause the method to return an error.
	DeleteObject(ctx context.Context, name string) error
}

Store is an interface abstracting an object storage layer.

Once created, objects are immutable, the store does not need to offer a mechanism for updating the object content or metadata.

Store instances must be safe to use concurrently from multiple goroutines.

func DirStore

func DirStore(path string) (Store, error)

DirStore constructs an object store from a directory entry at the given path.

The function converts the directory location to an absolute path to decouple the store from a change of the current working directory.

The directory is not created if it does not exist.

func EmptyStore

func EmptyStore() Store

EmptyStore returns a Store instance representing an empty, read-only object store.

type Tag

type Tag struct {
	Name  string
	Value string
}

Tag represents a name/value pair attached to an object.

func (Tag) String

func (t Tag) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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