storage

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: BSD-3-Clause Imports: 18 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSupported = errors.New("method call on storage engine not supported")

Functions

func Get

func Get(ctx context.Context, engine Engine, u *URI) ([]byte, error)

func NewBytesReader

func NewBytesReader(b []byte) *bytesReader

func Put

func Put(ctx context.Context, engine Engine, u *URI, r io.Reader) error

func Size

func Size(r Reader) (int64, error)

Types

type Engine

type Engine interface {
	Get(context.Context, *URI) (Reader, error)
	Put(context.Context, *URI) (io.WriteCloser, error)
	PutIfNotExists(context.Context, *URI, []byte) error
	Delete(context.Context, *URI) error
	DeleteByPrefix(context.Context, *URI) error
	Exists(context.Context, *URI) (bool, error)
	Size(context.Context, *URI) (int64, error)
	List(context.Context, *URI) ([]Info, error)
}

type FileSystem

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

func NewFileSystem

func NewFileSystem() *FileSystem

func (*FileSystem) Delete

func (f *FileSystem) Delete(_ context.Context, u *URI) error

func (*FileSystem) DeleteByPrefix

func (f *FileSystem) DeleteByPrefix(_ context.Context, u *URI) error

func (*FileSystem) Exists

func (f *FileSystem) Exists(_ context.Context, u *URI) (bool, error)

func (*FileSystem) Get

func (f *FileSystem) Get(ctx context.Context, u *URI) (Reader, error)

func (*FileSystem) List

func (f *FileSystem) List(ctx context.Context, u *URI) ([]Info, error)

func (*FileSystem) Put

func (f *FileSystem) Put(_ context.Context, u *URI) (io.WriteCloser, error)

func (*FileSystem) PutIfNotExists

func (f *FileSystem) PutIfNotExists(_ context.Context, u *URI, b []byte) error

func (*FileSystem) Size

func (f *FileSystem) Size(_ context.Context, u *URI) (int64, error)

type HTTPEngine

type HTTPEngine struct{}

func NewHTTP

func NewHTTP() *HTTPEngine

func (*HTTPEngine) Delete

func (*HTTPEngine) Delete(_ context.Context, u *URI) error

func (*HTTPEngine) DeleteByPrefix

func (*HTTPEngine) DeleteByPrefix(_ context.Context, u *URI) error

func (*HTTPEngine) Exists

func (*HTTPEngine) Exists(_ context.Context, u *URI) (bool, error)

func (*HTTPEngine) Get

func (*HTTPEngine) Get(ctx context.Context, u *URI) (Reader, error)

func (*HTTPEngine) List

func (*HTTPEngine) List(ctx context.Context, u *URI) ([]Info, error)

func (*HTTPEngine) Put

func (*HTTPEngine) Put(_ context.Context, u *URI) (io.WriteCloser, error)

func (*HTTPEngine) PutIfNotExists

func (*HTTPEngine) PutIfNotExists(context.Context, *URI, []byte) error

func (*HTTPEngine) Size

func (*HTTPEngine) Size(_ context.Context, u *URI) (int64, error)

type Info

type Info struct {
	Name string
	Size int64
}

type Reader

type Reader interface {
	io.Reader
	io.ReaderAt
	io.Closer
}

type Router

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

Router is an Engine that routes each function call to the correct sub-Engine based off the provided URI's scheme and its enablement.

func NewLocalEngine

func NewLocalEngine() *Router

func NewRemoteEngine

func NewRemoteEngine() *Router

func NewRouter

func NewRouter() *Router

func (*Router) Delete

func (r *Router) Delete(ctx context.Context, u *URI) error

func (*Router) DeleteByPrefix

func (r *Router) DeleteByPrefix(ctx context.Context, u *URI) error

func (*Router) Enable

func (r *Router) Enable(scheme Scheme)

func (*Router) Exists

func (r *Router) Exists(ctx context.Context, u *URI) (bool, error)

func (*Router) Get

func (r *Router) Get(ctx context.Context, u *URI) (Reader, error)

func (*Router) List

func (r *Router) List(ctx context.Context, u *URI) ([]Info, error)

func (*Router) Put

func (r *Router) Put(ctx context.Context, u *URI) (io.WriteCloser, error)

func (*Router) PutIfNotExists

func (r *Router) PutIfNotExists(ctx context.Context, u *URI, b []byte) error

func (*Router) Size

func (r *Router) Size(ctx context.Context, u *URI) (int64, error)

type S3Engine

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

func NewS3

func NewS3() *S3Engine

func (*S3Engine) Delete

func (s *S3Engine) Delete(ctx context.Context, u *URI) error

func (*S3Engine) DeleteByPrefix

func (s *S3Engine) DeleteByPrefix(ctx context.Context, u *URI) error

func (*S3Engine) Exists

func (s *S3Engine) Exists(ctx context.Context, u *URI) (bool, error)

func (*S3Engine) Get

func (s *S3Engine) Get(ctx context.Context, u *URI) (Reader, error)

func (*S3Engine) List

func (s *S3Engine) List(ctx context.Context, uri *URI) ([]Info, error)

func (*S3Engine) Put

func (s *S3Engine) Put(ctx context.Context, u *URI) (io.WriteCloser, error)

func (*S3Engine) PutIfNotExists

func (s *S3Engine) PutIfNotExists(context.Context, *URI, []byte) error

func (*S3Engine) Size

func (s *S3Engine) Size(ctx context.Context, u *URI) (int64, error)

type Scheme

type Scheme string
const (
	FileScheme  Scheme = "file"
	StdioScheme Scheme = "stdio"
	HTTPScheme  Scheme = "http"
	HTTPSScheme Scheme = "https"
	S3Scheme    Scheme = "s3"
)

type Sizer

type Sizer interface {
	Size() (int64, error)
}

type StdioEngine

type StdioEngine struct{}

func NewStdioEngine

func NewStdioEngine() *StdioEngine

func (*StdioEngine) Delete

func (*StdioEngine) Delete(ctx context.Context, u *URI) error

func (*StdioEngine) DeleteByPrefix

func (*StdioEngine) DeleteByPrefix(ctx context.Context, u *URI) error

func (*StdioEngine) Exists

func (*StdioEngine) Exists(_ context.Context, u *URI) (bool, error)

func (*StdioEngine) Get

func (*StdioEngine) Get(_ context.Context, u *URI) (Reader, error)

func (*StdioEngine) List

func (*StdioEngine) List(_ context.Context, _ *URI) ([]Info, error)

func (*StdioEngine) Put

func (*StdioEngine) Put(ctx context.Context, u *URI) (io.WriteCloser, error)

func (*StdioEngine) PutIfNotExists

func (*StdioEngine) PutIfNotExists(context.Context, *URI, []byte) error

func (*StdioEngine) Size

func (*StdioEngine) Size(_ context.Context, u *URI) (int64, error)

type URI

type URI url.URL

func MustParseURI

func MustParseURI(path string) *URI

func ParseURI

func ParseURI(path string) (*URI, error)

ParseURI parses the path using `url.Parse`. If the provided uri does not contain a scheme, the scheme is set to file. Relative paths are treated as files and resolved as absolute paths using filepath.Abs. If path is an empty, a pointer to zero-valued URI is returned.

func (*URI) Filepath

func (p *URI) Filepath() string

func (*URI) HasScheme

func (u *URI) HasScheme(s Scheme) bool

func (*URI) IsZero

func (u *URI) IsZero() bool

func (*URI) JoinPath added in v1.6.0

func (p *URI) JoinPath(elem ...string) *URI

func (*URI) MarshalText

func (u *URI) MarshalText() ([]byte, error)

func (*URI) MarshalZNG

func (u *URI) MarshalZNG(mc *zson.MarshalZNGContext) (zed.Type, error)

func (*URI) RelPath

func (u *URI) RelPath(target URI) string

func (URI) String

func (u URI) String() string

func (*URI) UnmarshalText

func (u *URI) UnmarshalText(b []byte) error

Directories

Path Synopsis
Package cache contains facilities for caching immutable files, typically for a cloud object store.
Package cache contains facilities for caching immutable files, typically for a cloud object store.
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