bucket

package
v0.0.16-dev Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

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

NOTE: all write operations should use the lock for the bucket to keep consistency TODO: Maybe read operations dont need a lock, needs testing struct for implementing bucket interface

func New

func New(
	root *bucketsproto.Root,
	getBucketContext GetBucketContextFn,
	bucketsClient BucketsClient,
) *Bucket

func (*Bucket) CreateDirectory

func (b *Bucket) CreateDirectory(ctx context.Context, path string) (result path.Resolved, root path.Path, err error)

CreateDirectory creates an empty directory Because textile doesn't support empty directory an empty .keep file is created in the directory

func (*Bucket) DeleteDirOrFile

func (b *Bucket) DeleteDirOrFile(ctx context.Context, path string) (path.Resolved, error)

DeleteDirOrFile will delete file or directory at path

func (*Bucket) DirExists

func (b *Bucket) DirExists(ctx context.Context, path string) (bool, error)

func (*Bucket) FileExists

func (b *Bucket) FileExists(ctx context.Context, path string) (bool, error)

func (*Bucket) GetData

func (b *Bucket) GetData() BucketData

func (*Bucket) GetFile

func (b *Bucket) GetFile(ctx context.Context, path string, w io.Writer) error

GetFile pulls path from bucket writing it to writer if it's a file.

func (*Bucket) GetThreadID added in v0.0.13

func (b *Bucket) GetThreadID(ctx context.Context) (*thread.ID, error)

func (*Bucket) Key

func (b *Bucket) Key() string

func (*Bucket) ListDirectory

func (b *Bucket) ListDirectory(ctx context.Context, path string) (*DirEntries, error)

ListDirectory returns a list of items in a particular directory

func (*Bucket) Slug

func (b *Bucket) Slug() string

func (*Bucket) UploadFile

func (b *Bucket) UploadFile(ctx context.Context, path string, reader io.Reader) (result path.Resolved, root path.Path, err error)

type BucketData

type BucketData struct {
	Key       string `json:"_id"`
	Name      string `json:"name"`
	Path      string `json:"path"`
	DNSRecord string `json:"dns_record,omitempty"`
	//Archives  Archives `json:"archives"`
	CreatedAt int64 `json:"created_at"`
	UpdatedAt int64 `json:"updated_at"`
}

type BucketsClient

type BucketsClient interface {
	PushPath(ctx context.Context, key, pth string, reader io.Reader, opts ...bucketsClient.Option) (result path.Resolved, root path.Resolved, err error)
	PullPath(ctx context.Context, key, pth string, writer io.Writer, opts ...bucketsClient.Option) error
	ListPath(ctx context.Context, key, pth string) (*bucketsproto.ListPathResponse, error)
	RemovePath(ctx context.Context, key, pth string, opts ...bucketsClient.Option) (path.Resolved, error)
}

type GetBucketContextFn added in v0.0.14

type GetBucketContextFn func(context.Context, string) (context.Context, *thread.ID, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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