bucket

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2021 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBucket

func NewBucket(name string) (*bucket, error)

NewBucket creates a new Bucket

Types

type Bucket

type Bucket interface {
	// Name returns the name of the bucket
	Name() string

	// Close closes gcs client associated with this bucket
	Close() error

	// WaitForLock waits for a lock, timing out after maxTime. It returns a lock id / object generation number
	// that must be passed in to ReleaseLock
	WaitForLock(objectPath string, maxWait time.Duration) (int64, error)

	// DeleteStaleLock deletes a stale lock file if it exists and is older than staleAge
	DeleteStaleLock(objectPath string, staleAge time.Duration) error

	// ReleaseLock removes a lockfile
	ReleaseLock(objectPath string, generation int64) error

	// Exists returns true if the object exists, false otherwise
	Exists(objectPath string) (bool, error)

	// Upload uploads a local file to the bucket
	Upload(localPath string, objectPath string, cacheControl string) error

	// Download downloads an object in the bucket to a local file
	Download(objectPath string, localPath string) error
}

Bucket offers higher-level operations on GCS buckets

type MockBucket

type MockBucket struct {
	mock.Mock
	// contains filtered or unexported fields
}

func NewMockBucket

func NewMockBucket(name string) *MockBucket

NewMockBucket creates a new MockBucket

func (*MockBucket) Close

func (bucket *MockBucket) Close() error

Close closes gcs client associated with this bucket

func (*MockBucket) Delete

func (bucket *MockBucket) Delete(objectPath string) error

Delete deletes an object in the bucket

func (*MockBucket) DeleteStaleLock

func (bucket *MockBucket) DeleteStaleLock(objectPath string, staleAge time.Duration) error

DeleteStaleLock deletes a stale lock file if it exists and is older than staleAge

func (*MockBucket) Download

func (bucket *MockBucket) Download(objectPath string, localPath string) error

Download downloads an object in the bucket to a local file

func (*MockBucket) Exists

func (bucket *MockBucket) Exists(objectPath string) (bool, error)

Exists returns true if the object exists, false otherwise

func (*MockBucket) Name

func (bucket *MockBucket) Name() string

Name returns the name of this bucket

func (*MockBucket) ReleaseLock

func (bucket *MockBucket) ReleaseLock(objectPath string, generation int64) error

ReleaseLock removes a lockfile

func (*MockBucket) Upload

func (bucket *MockBucket) Upload(localPath string, objectPath string, cacheControl string) error

Upload uploads a local file to the bucket

func (*MockBucket) WaitForLock

func (bucket *MockBucket) WaitForLock(objectPath string, maxWait time.Duration) (int64, error)

WaitForLock waits for a lock, timing out after maxTime. It returns a lock id / object generation number that must be passed in to ReleaseLock

Jump to

Keyboard shortcuts

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