bucket

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2020 License: Apache-2.0 Imports: 14 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) AttachNotifier added in v0.0.22

func (b *Bucket) AttachNotifier(n Notifier)

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, pth string) (bool, error)

func (*Bucket) GetClient added in v0.0.22

func (b *Bucket) GetClient() BucketsClient

func (*Bucket) GetContext added in v0.0.22

func (b *Bucket) GetContext(ctx context.Context) (context.Context, *thread.ID, 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) ItemsCount added in v0.0.23

func (b *Bucket) ItemsCount(ctx context.Context, path string, withRecursive bool) (int32, error)

return the recursive items count for a path

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 BucketInterface added in v0.0.22

type BucketInterface interface {
	Slug() string
	Key() string
	GetData() BucketData
	GetContext(ctx context.Context) (context.Context, *thread.ID, error)
	GetClient() BucketsClient
	GetThreadID(ctx context.Context) (*thread.ID, error)
	DirExists(ctx context.Context, path string) (bool, error)
	FileExists(ctx context.Context, path string) (bool, error)
	UploadFile(
		ctx context.Context,
		path string,
		reader io.Reader,
	) (result path.Resolved, root path.Path, err error)
	GetFile(
		ctx context.Context,
		path string,
		w io.Writer,
	) error
	CreateDirectory(
		ctx context.Context,
		path string,
	) (result path.Resolved, root path.Path, err error)
	ListDirectory(
		ctx context.Context,
		path string,
	) (*DirEntries, error)
	DeleteDirOrFile(
		ctx context.Context,
		path string,
	) (path.Resolved, error)
	ItemsCount(
		ctx context.Context,
		path string,
		withRecursive bool,
	) (int32, error)
}

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)
	ListIpfsPath(ctx context.Context, ipfsPath path.Path) (*bucketsproto.ListIpfsPathResponse, error)
	PushPathAccessRoles(ctx context.Context, key, path string, roles map[string]buckets.Role) error
}

type GetBucketContextFn added in v0.0.14

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

type Notifier added in v0.0.22

type Notifier interface {
	OnUploadFile(bucketSlug string, bucketPath string, result path.Resolved, root path.Path)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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