Documentation ¶
Overview ¶
Package storage is an interface over Google Cloud Storage.
Package storage is an interface over file/blob storage.
Index ¶
- Variables
- type AWSS3
- type AzureBlobstore
- func (s *AzureBlobstore) CreateObject(ctx context.Context, container, name string, contents []byte, cacheable bool) error
- func (s *AzureBlobstore) DeleteObject(ctx context.Context, container, name string) error
- func (s *AzureBlobstore) GetObject(ctx context.Context, container, name string) ([]byte, error)
- type Blobstore
- func BlobstoreFor(ctx context.Context, typ BlobstoreType) (Blobstore, error)
- func NewAWSS3(ctx context.Context) (Blobstore, error)
- func NewAzureBlobstore(ctx context.Context) (Blobstore, error)
- func NewFilesystemStorage(ctx context.Context) (Blobstore, error)
- func NewGoogleCloudStorage(ctx context.Context) (Blobstore, error)
- func NewMemory(_ context.Context) (Blobstore, error)
- func NewNoop(ctx context.Context) (Blobstore, error)
- type BlobstoreType
- type Config
- type FilesystemStorage
- func (s *FilesystemStorage) CreateObject(ctx context.Context, folder, filename string, contents []byte, cacheable bool) error
- func (s *FilesystemStorage) DeleteObject(ctx context.Context, folder, filename string) error
- func (s *FilesystemStorage) GetObject(ctx context.Context, folder, filename string) ([]byte, error)
- type GoogleCloudStorage
- func (s *GoogleCloudStorage) CreateObject(ctx context.Context, bucket, objectName string, contents []byte, ...) error
- func (s *GoogleCloudStorage) DeleteObject(ctx context.Context, bucket, objectName string) error
- func (s *GoogleCloudStorage) GetObject(ctx context.Context, bucket, object string) ([]byte, error)
- type Memory
- type Noop
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = fmt.Errorf("storage object not found")
Functions ¶
This section is empty.
Types ¶
type AWSS3 ¶
type AWSS3 struct {
// contains filtered or unexported fields
}
AWSS3 implements the Blob interface and provides the ability write files to AWS S3.
func (*AWSS3) CreateObject ¶
func (s *AWSS3) CreateObject(ctx context.Context, bucket, key string, contents []byte, cacheable bool) error
CreateObject creates a new S3 object or overwrites an existing one.
func (*AWSS3) DeleteObject ¶
DeleteObject deletes a S3 object, returns nil if the object was successfully deleted, or of the object doesn't exist.
type AzureBlobstore ¶
type AzureBlobstore struct {
// contains filtered or unexported fields
}
AzureBlobstore implements the Blob interface and provides the ability write files to Azure Blob Storage.
func (*AzureBlobstore) CreateObject ¶
func (s *AzureBlobstore) CreateObject(ctx context.Context, container, name string, contents []byte, cacheable bool) error
CreateObject creates a new blobstore object or overwrites an existing one.
func (*AzureBlobstore) DeleteObject ¶
func (s *AzureBlobstore) DeleteObject(ctx context.Context, container, name string) error
DeleteObject deletes a blobstore object, returns nil if the object was successfully deleted, or if the object doesn't exist.
type Blobstore ¶
type Blobstore interface { // CreateObject creates or overwrites an object in the storage system. CreateObject(ctx context.Context, parent, name string, contents []byte, cacheable bool) error // DeleteObject deletes an object or does nothing if the object doesn't exist. DeleteObject(ctx context.Context, parent, bame string) error // GetObject fetches the object's contents. GetObject(ctx context.Context, parent, name string) ([]byte, error) }
Blobstore defines the minimum interface for a blob storage system.
func BlobstoreFor ¶
func BlobstoreFor(ctx context.Context, typ BlobstoreType) (Blobstore, error)
BlobstoreFor returns the blob store for the given type, or an error if one does not exist.
func NewAzureBlobstore ¶
NewAzureBlobstore creates a storage client, suitable for use with serverenv.ServerEnv.
func NewFilesystemStorage ¶
NewFilesystemStorage creates a Blobsstore compatible storage for the filesystem.
func NewGoogleCloudStorage ¶
NewGoogleCloudStorage creates a Google Cloud Storage Client, suitable for use with serverenv.ServerEnv.
type BlobstoreType ¶
type BlobstoreType string
BlobstoreType defines a specific blobstore.
const ( BlobstoreTypeAWSS3 BlobstoreType = "AWS_S3" BlobstoreTypeAzureBlobStorage BlobstoreType = "AZURE_BLOB_STORAGE" BlobstoreTypeFilesystem BlobstoreType = "FILESYSTEM" BlobstoreTypeGoogleCloudStorage BlobstoreType = "GOOGLE_CLOUD_STORAGE" BlobstoreTypeMemory BlobstoreType = "MEMORY" BlobstoreTypeNoop BlobstoreType = "NOOP" )
type Config ¶
type Config struct {
BlobstoreType BlobstoreType `env:"BLOBSTORE,default=GOOGLE_CLOUD_STORAGE"`
}
Config defines the configuration for a blobstore.
type FilesystemStorage ¶
type FilesystemStorage struct{}
FilesystemStorage implements Blobstore and provides the ability write files to the filesystem.
func (*FilesystemStorage) CreateObject ¶
func (s *FilesystemStorage) CreateObject(ctx context.Context, folder, filename string, contents []byte, cacheable bool) error
CreateObject creates a new object on the filesystem or overwrites an existing one.
func (*FilesystemStorage) DeleteObject ¶
func (s *FilesystemStorage) DeleteObject(ctx context.Context, folder, filename string) error
DeleteObject deletes an object from the filesystem. It returns nil if the object was deleted or if the object no longer exists.
type GoogleCloudStorage ¶
type GoogleCloudStorage struct {
// contains filtered or unexported fields
}
GoogleCloudStorage implements the Blob interface and provides the ability write files to Google Cloud Storage.
func (*GoogleCloudStorage) CreateObject ¶
func (s *GoogleCloudStorage) CreateObject(ctx context.Context, bucket, objectName string, contents []byte, cacheable bool) error
CreateObject creates a new cloud storage object or overwrites an existing one.
func (*GoogleCloudStorage) DeleteObject ¶
func (s *GoogleCloudStorage) DeleteObject(ctx context.Context, bucket, objectName string) error
DeleteObject deletes a cloud storage object, returns nil if the object was successfully deleted, or of the object doesn't exist.
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory implements Blobstore and provides the ability write files to memory.
func (*Memory) CreateObject ¶
func (s *Memory) CreateObject(_ context.Context, folder, filename string, contents []byte, cacheable bool) error
CreateObject creates a new object.
func (*Memory) DeleteObject ¶
DeleteObject deletes an object. It returns nil if the object was deleted or if the object no longer exists.