Documentation ¶
Overview ¶
Package gcs provides interfaces and wraps calls for interacting with Google Cloud Storage. This package is mainly necessary because of the lack of interfaces provided by Google with their client library.
The package aims to be unit-testable without calling any external services, making storage gateways easier to test.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
Bucket is used by our Client interface for interacting with buckets in GCS.
func NewGoogleBucket ¶
func NewGoogleBucket(bucket StorageBucket) Bucket
NewGoogleBucket produces a new Bucket instance, using GoogleBucket.
type Client ¶
Client is the client interface we'll be using in our code that intends to use GCS.
func NewGoogleClient ¶
func NewGoogleClient(storageClient StorageClient) Client
NewGoogleClient produces a new Client instance, using GoogleClient.
type GoogleBucket ¶
type GoogleBucket struct {
// contains filtered or unexported fields
}
GoogleBucket is an implementation of Bucket that can use the real Google Cloud Storage client library (but doesn't have to).
func (*GoogleBucket) Object ¶
func (b *GoogleBucket) Object(name string) Object
Object wraps a call to the underlying StorageBucket, creating an Object, which is like a *storage.ObjectHandle. This should be idempotent.
type GoogleClient ¶
type GoogleClient struct {
// contains filtered or unexported fields
}
GoogleClient is an implementation of Client that can use the real Google Cloud Storage client library (but doesn't have to).
func (*GoogleClient) Bucket ¶
func (c *GoogleClient) Bucket(name string) Bucket
Bucket wraps a call to the underlying StorageClient, creating a Bucket, which is like a *storage.BucketHandle. This should be idempotent.
type GoogleObject ¶
type GoogleObject struct {
// contains filtered or unexported fields
}
GoogleObject is an implementation of Object that can use the real Google Cloud Storage client library (but doesn't have to).
func (*GoogleObject) NewWriteCloser ¶
func (o *GoogleObject) NewWriteCloser(ctx context.Context) io.WriteCloser
NewWriteCloser wraps a call to the underlying StorageObject, creating an io.WriteCloser, which is like a *storage.Writer. This should be idempotent (but the returned writer may write to GCS).
type Object ¶
type Object interface {
NewWriteCloser(ctx context.Context) io.WriteCloser
}
Object is used by our Bucket interface for interacting with objects in GCS.
func NewGoogleObject ¶
func NewGoogleObject(object StorageObject) Object
NewGoogleObject produces a new Object instance, using GoogleObject.
type StorageBucket ¶
type StorageBucket interface {
Object(name string) *storage.ObjectHandle
}
StorageBucket is the interface that lets us mock a *storage.BucketHandle instance. We can construct a Bucket with a StorageBucket.
type StorageClient ¶
type StorageClient interface {
Bucket(name string) *storage.BucketHandle
}
StorageClient is the interface that lets us mock a *storage.Client instance. We can construct a Client with a StorageClient.