bucketly

package module
v0.0.0-...-bb5f746 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2020 License: MIT Imports: 9 Imported by: 0

README

Bucketly

Go Report Card Build Status Coverage Status

License

bucketly is licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSkipWalkDir  = errors.New("skip walk dir")
	ErrStopWalk     = errors.New("stop walk dir")
	ErrNotSupported = errors.New("not supported")
)

Functions

func Abs

func Abs(b PathSeparable, name string) (string, error)

func Base

func Base(b PathSeparable, name string) string

func Clean

func Clean(b PathSeparable, name string) string

func CopyAll

func CopyAll(ctx context.Context, from Item, to Item, opts ...CopyOption) error

func Dir

func Dir(b PathSeparable, name string) string

func Join

func Join(b PathSeparable, elems ...string) string

func Sanitize

func Sanitize(b PathSeparable, name string) (string, error)

Types

type Bucket

type Bucket interface {
	PathSeparable

	Name() string
	Read(ctx context.Context, name string) ([]byte, error)
	NewReader(ctx context.Context, name string) (io.ReadCloser, error)
	Write(ctx context.Context, name string, data []byte, opts ...WriteOption) (int, error)
	NewWriter(ctx context.Context, name string, opts ...WriteOption) (io.WriteCloser, error)
	Exists(ctx context.Context, name string) (bool, error)
	Remove(ctx context.Context, name string) error
	Stat(ctx context.Context, name string) (Item, error)
	Mkdir(ctx context.Context, name string, opts ...WriteOption) error
	MkdirAll(ctx context.Context, name string, opts ...WriteOption) error
	Chmod(ctx context.Context, name string, mode os.FileMode) error
	RemoveAll(ctx context.Context, name string) error
	Rename(ctx context.Context, from string, to string, opts ...CopyOption) error
	Copy(ctx context.Context, from Item, to string, opts ...CopyOption) error
	CopyAll(ctx context.Context, from Item, to string, opts ...CopyOption) error
	Copy2(ctx context.Context, from string, to string, opts ...CopyOption) error
	CopyAll2(ctx context.Context, from string, to string, opts ...CopyOption) error
}

type BucketItem

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

func NewItem

func NewItem(bucket Bucket, name string) *BucketItem

func (*BucketItem) AddMetadata

func (i *BucketItem) AddMetadata(k, v string)

func (*BucketItem) Bucket

func (i *BucketItem) Bucket() Bucket

func (*BucketItem) ETag

func (i *BucketItem) ETag() (string, error)

func (*BucketItem) IsDir

func (i *BucketItem) IsDir() bool

func (*BucketItem) Metadata

func (i *BucketItem) Metadata() (Metadata, error)

func (*BucketItem) ModTime

func (i *BucketItem) ModTime() time.Time

func (*BucketItem) Mode

func (i *BucketItem) Mode() os.FileMode

func (*BucketItem) Name

func (i *BucketItem) Name() string

func (*BucketItem) Open

func (i *BucketItem) Open(ctx context.Context) (io.ReadCloser, error)

func (*BucketItem) SetDir

func (i *BucketItem) SetDir(dir bool)

func (*BucketItem) SetETag

func (i *BucketItem) SetETag(etag string)

func (*BucketItem) SetMetadata

func (i *BucketItem) SetMetadata(metadata Metadata)

func (*BucketItem) SetMode

func (i *BucketItem) SetMode(mode os.FileMode)

func (*BucketItem) SetModeTime

func (i *BucketItem) SetModeTime(modTime time.Time)

func (*BucketItem) SetSize

func (i *BucketItem) SetSize(size int64)

func (*BucketItem) SetSys

func (i *BucketItem) SetSys(sys interface{})

func (*BucketItem) Size

func (i *BucketItem) Size() int64

func (*BucketItem) String

func (i *BucketItem) String() string

func (*BucketItem) Sys

func (i *BucketItem) Sys() interface{}

type BucketManager

type BucketManager interface {
	Create(context.Context) error
	Remove(context.Context) error
	Clean(context.Context) error
}

type CopyFn

type CopyFn func(ctx context.Context, from Item, to string) error

type CopyOption

type CopyOption func(o *CopyOptions)

func WithCopyMetadata

func WithCopyMetadata(metadata Metadata) CopyOption

type CopyOptions

type CopyOptions struct {
	Metadata Metadata
	Mode     os.FileMode
}

type Item

type Item interface {
	fmt.Stringer
	os.FileInfo

	Bucket() Bucket
	Open(context.Context) (io.ReadCloser, error)
	ETag() (string, error)
	Metadata() (Metadata, error)
}

type ListIterator

type ListIterator interface {
	io.Closer

	Next(ctx context.Context) (Item, error)
}

type Listable

type Listable interface {
	Items(name string) (ListIterator, error)
}

type Metadata

type Metadata map[string]string

type PathSeparable

type PathSeparable interface {
	PathSeparator() rune
}

type WalkFunc

type WalkFunc func(item Item, err error) error

type Walkable

type Walkable interface {
	Walk(ctx context.Context, dir string, walkFunc WalkFunc) error
}

type WriteOption

type WriteOption func(o *WriteOptions)

func WithWriteBufferSize

func WithWriteBufferSize(bufferSize int) WriteOption

func WithWriteMetadata

func WithWriteMetadata(metadata Metadata) WriteOption

func WithWriteMode

func WithWriteMode(mode os.FileMode) WriteOption

type WriteOptions

type WriteOptions struct {
	Metadata   Metadata
	BufferSize int
	Mode       os.FileMode
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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