connector

package
v0.18.2 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBucketNotFound is non retriable error that is thrown when the bucket doesn't exist
	ErrBucketNotFound = errors.New("bucket not found")
)

Functions

This section is empty.

Types

type BucketHandleWrapper

type BucketHandleWrapper interface {
	Object(name string) ObjectHandleWrapper
	Objects(ctx context.Context, q *storage.Query) ObjectIteratorWrapper
	Attrs(ctx context.Context) (*storage.BucketAttrs, error)
}

BucketHandleWrapper is an interface that expose some methods from gcloud storage bucket

type Client

type Client interface {
	Upload(ctx context.Context, URI archiver.URI, fileName string, file []byte) error
	Get(ctx context.Context, URI archiver.URI, file string) ([]byte, error)
	Query(ctx context.Context, URI archiver.URI, fileNamePrefix string) ([]string, error)
	QueryWithFilters(ctx context.Context, URI archiver.URI, fileNamePrefix string, pageSize, offset int, filters []Precondition) ([]string, bool, int, error)
	Exist(ctx context.Context, URI archiver.URI, fileName string) (bool, error)
}

Client is a wrapper around Google cloud storages client library.

func NewClient

func NewClient(ctx context.Context, config *config.GstorageArchiver) (Client, error)

NewClient return a Cadence gcloudstorage.Client based on default google service account creadentials (ScopeFullControl required). Bucket must be created by Iaas scripts, in other words, this library doesn't create the required Bucket. Optionaly you can set your credential path throught "GOOGLE_APPLICATION_CREDENTIALS" environment variable or through cadence config file. You can find more info about "Google Setting Up Authentication for Server to Server Production Applications" under the following link https://cloud.google.com/docs/authentication/production

func NewClientWithParams

func NewClientWithParams(clientD GcloudStorageClient) (Client, error)

NewClientWithParams return a gcloudstorage.Client based on input parameters

type GcloudStorageClient

type GcloudStorageClient interface {
	Bucket(URI string) BucketHandleWrapper
}

GcloudStorageClient is an interface that expose some methods from gcloud storage client

type ObjectHandleWrapper

type ObjectHandleWrapper interface {
	NewWriter(ctx context.Context) WriterWrapper
	NewReader(ctx context.Context) (ReaderWrapper, error)
	Attrs(ctx context.Context) (*storage.ObjectAttrs, error)
}

ObjectHandleWrapper is an interface that expose some methods from gcloud storage object

type ObjectIteratorWrapper

type ObjectIteratorWrapper interface {
	Next() (*storage.ObjectAttrs, error)
}

ObjectIteratorWrapper is an interface that expose some methods from gcloud storage objectIterator

type Precondition

type Precondition func(subject interface{}) bool

Precondition is a function that allow you to filter a query result. If subject match params conditions then return true, else return false.

type ReaderWrapper

type ReaderWrapper interface {
	Close() error
	Read(p []byte) (int, error)
}

ReaderWrapper is an interface that expose some methods from gcloud storage reader

type WriterWrapper

type WriterWrapper interface {
	Close() error
	Write(p []byte) (n int, err error)
	CloseWithError(err error) error
}

WriterWrapper is an interface that expose some methods from gcloud storage writer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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