storage

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Connect(ctx context.Context) error
	VisitObjects(ctx context.Context, bucketName, prefix string, visit func(objectInfo ObjectInfo) error) error
	ReadObject(ctx context.Context, bucketName, objectName string) (io.ReadCloser, error)
	Close() error
}

Client defines an interface used to interact with Google Cloud Storage

type GoogleClient

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

GoogleClient provides the ability to interact with Google Cloud Storage

func NewGoogleClient

func NewGoogleClient() *GoogleClient

NewGoogleClient creates a new instance of GoogleClient

func (*GoogleClient) Close

func (c *GoogleClient) Close() error

Close closes the client

func (*GoogleClient) Connect

func (c *GoogleClient) Connect(ctx context.Context) error

Connect establishes a connection to Google Cloud Storage

func (*GoogleClient) ReadObject

func (c *GoogleClient) ReadObject(ctx context.Context, bucketName, objectName string) (io.ReadCloser, error)

ReadObject reads the content of an object from Google Cloud Storage

func (*GoogleClient) VisitObjects

func (c *GoogleClient) VisitObjects(ctx context.Context, bucketName, prefix string, visit func(objectInfo ObjectInfo) error) error

VisitObjects calls a function for each object found in a bucket where the object starts with a specified prefix

type MockClient

type MockClient struct {
	ObjectInfoProviderFunc    func(bucketName, prefix string) []ObjectInfo
	ObjectContentProviderFunc func(bucketName, objectName string) []byte
	// contains filtered or unexported fields
}

MockClient provides a mock implementation of the Client interface

func (*MockClient) Close

func (c *MockClient) Close() error

Close simulates the connection being closed

func (*MockClient) Connect

func (c *MockClient) Connect(_ context.Context) error

Connect simulates a connection being established

func (*MockClient) ReadObject

func (c *MockClient) ReadObject(_ context.Context, bucketName, objectName string) (io.ReadCloser, error)

ReadObject returns the data provided by MockClient.ObjectContentProviderFunc

func (*MockClient) VisitObjects

func (c *MockClient) VisitObjects(_ context.Context, bucketName, prefix string, visit func(objectInfo ObjectInfo) error) error

VisitObjects calls a function for each object returned by MockClient.ObjectInfoProviderFunc

type ObjectInfo

type ObjectInfo struct {
	Name string
	Size int64
}

ObjectInfo contains information about an object

Jump to

Keyboard shortcuts

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