driver

package
v0.0.0-...-5fe3b72 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CommitOnAbortedObjectWriter = errors.New("commit on aborted ObjectWriter")

Functions

func Drivers

func Drivers() []string

Drivers returns a sorted list of the URL schemes of the registered drivers.

func Register

func Register(scheme string, driver Driver)

Register makes a storage driver available by the provided URL scheme. If Register is called twice with the same scheme or if driver is nil, it panics.

func Visit

func Visit(ctx context.Context, drvr Readdirer, root string, visitor Visitor) error

Types

type AnonymousObject

type AnonymousObject interface {
	io.Closer
	io.Reader
	io.ReaderAt
	io.Seeker
	Size() int64
}

AnonymousObject represents a read-only, fixed size, random access object.

type CommitInfo

type CommitInfo interface {
	// ObjectURL returns the final URL of the committed object
	ObjectURL() string
}

func NewCommitInfo

func NewCommitInfo(url string) CommitInfo

NewCommitInfo is a helper function for storage drivers

type ComprehensiveDriver

type ComprehensiveDriver interface {
	Driver
	Creator
	Remover
	Readdirer
	Locker
}

Useful for mocking

type Creator

type Creator interface {
	// Create an ObjectWriter handle
	Create(ctx context.Context, url string) (ObjectWriter, error)
}

type Driver

type Driver interface {
	// Name returns the display name of this driver
	Name() string

	// Open opens the Object for reading.
	Open(ctx context.Context, url string, size int64) (Object, error)

	// Stat returns a FileInfo describing the Object.
	Stat(ctx context.Context, url string) (os.FileInfo, error)
}

Driver is the interface that must be implemented by a storage driver.

func Find

func Find(url string) (Driver, error)

type Locker

type Locker interface {
	// Lock acquires an advisory exclusive lock on the object
	// specified, potentially creating it if it does not already
	// exist.
	Lock(ctx context.Context, url string) (io.Closer, error)

	// RLock acquires an advisory shared lock on the object specified,
	// potentially creating it if it does not already exist.
	RLock(ctx context.Context, url string) (io.Closer, error)
}

type Object

type Object interface {
	AnonymousObject
	URL() string
}

Object represents a AnonymousObject with a URL

type ObjectWriter

type ObjectWriter interface {
	io.Writer
	Abort()
	Commit() (CommitInfo, error)
}

ObjectWriter is a handle for creating an Object

type Readdirer

type Readdirer interface {
	// Readdir reads the contents of the directory and returns a slice
	// of FileInfo values, as would be returned by Stat, in directory
	// order.
	Readdir(ctx context.Context, url string) ([]os.FileInfo, error)
}

type Remover

type Remover interface {
	// Remove an object
	Remove(ctx context.Context, url string) error
}

type Undo

type Undo func()

func ClearRegistry

func ClearRegistry() Undo

Temporarily unregister all the default drivers until Undo is called.

type Visitor

type Visitor interface {
	VisitDir(baseURL string, files []os.FileInfo) error
}

type VisitorConcurrency

type VisitorConcurrency interface {
	Concurrency() int
}

type VisitorPredicate

type VisitorPredicate interface {
	ShouldVisitDir(url string) (bool, error)
}

type VisitorTraversal

type VisitorTraversal interface {
	DepthFirst() bool
}

type XattrObject

type XattrObject interface {
	Object
	GetXattr(name string) ([]byte, error)
}

type XattrObjectWriter

type XattrObjectWriter interface {
	ObjectWriter
	SetXattr(name string, value []byte) error
}

Jump to

Keyboard shortcuts

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