exposure-notifications-server: github.com/google/exposure-notifications-server/internal/storage Index | Files

package storage

import "github.com/google/exposure-notifications-server/internal/storage"

Package storage is an interface over Google Cloud Storage.

Package storage is an interface over file/blob storage.

Index

Package Files

aws_s3.go azure_blobstore.go config.go filesystem_storage.go google_cloud_storage.go memory.go noop.go storage.go

Constants

const (
    ContentTypeTextPlain = "text/plain"
    ContentTypeZip       = "application/zip"
)

Variables

var ErrNotFound = fmt.Errorf("storage object not found")

type AWSS3 Uses

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 Uses

func (s *AWSS3) CreateObject(ctx context.Context, bucket, key string, contents []byte, cacheable bool, contentType string) error

CreateObject creates a new S3 object or overwrites an existing one.

func (*AWSS3) DeleteObject Uses

func (s *AWSS3) DeleteObject(ctx context.Context, bucket, key string) error

DeleteObject deletes a S3 object, returns nil if the object was successfully deleted, or of the object doesn't exist.

func (*AWSS3) GetObject Uses

func (s *AWSS3) GetObject(ctx context.Context, bucket, key string) ([]byte, error)

GetObject returns the contents for the given object. If the object does not exist, it returns ErrNotFound.

type AzureBlobstore Uses

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 Uses

func (s *AzureBlobstore) CreateObject(ctx context.Context, container, name string, contents []byte, cacheable bool, contentType string) error

CreateObject creates a new blobstore object or overwrites an existing one.

func (*AzureBlobstore) DeleteObject Uses

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.

func (*AzureBlobstore) GetObject Uses

func (s *AzureBlobstore) GetObject(ctx context.Context, container, name string) ([]byte, error)

GetObject returns the contents for the given object. If the object does not exist, it returns ErrNotFound.

type Blobstore Uses

type Blobstore interface {
    // CreateObject creates or overwrites an object in the storage system.
    // If contentType is blank, the default for the chosen storage implementation is used.
    CreateObject(ctx context.Context, parent, name string, contents []byte, cacheable bool, contentType string) 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 Uses

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 NewAWSS3 Uses

func NewAWSS3(ctx context.Context) (Blobstore, error)

NewAWSS3 creates a AWS S3 Service, suitable for use with serverenv.ServerEnv.

func NewAzureBlobstore Uses

func NewAzureBlobstore(ctx context.Context) (Blobstore, error)

NewAzureBlobstore creates a storage client, suitable for use with serverenv.ServerEnv.

func NewFilesystemStorage Uses

func NewFilesystemStorage(ctx context.Context) (Blobstore, error)

NewFilesystemStorage creates a Blobsstore compatible storage for the filesystem.

func NewGoogleCloudStorage Uses

func NewGoogleCloudStorage(ctx context.Context) (Blobstore, error)

NewGoogleCloudStorage creates a Google Cloud Storage Client, suitable for use with serverenv.ServerEnv.

func NewMemory Uses

func NewMemory(_ context.Context) (Blobstore, error)

NewMemory creates a Blobstore that writes data in memory.

func NewNoop Uses

func NewNoop(ctx context.Context) (Blobstore, error)

type BlobstoreType Uses

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 Uses

type Config struct {
    BlobstoreType BlobstoreType `env:"BLOBSTORE,default=GOOGLE_CLOUD_STORAGE"`
}

Config defines the configuration for a blobstore.

type FilesystemStorage Uses

type FilesystemStorage struct{}

FilesystemStorage implements Blobstore and provides the ability write files to the filesystem.

func (*FilesystemStorage) CreateObject Uses

func (s *FilesystemStorage) CreateObject(ctx context.Context, folder, filename string, contents []byte, cacheable bool, contentType string) error

CreateObject creates a new object on the filesystem or overwrites an existing one. contentType is ignored for this storage implementation.

func (*FilesystemStorage) DeleteObject Uses

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.

func (*FilesystemStorage) GetObject Uses

func (s *FilesystemStorage) GetObject(ctx context.Context, folder, filename string) ([]byte, error)

GetObject returns the contents for the given object. If the object does not exist, it returns ErrNotFound.

type GoogleCloudStorage Uses

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 Uses

func (s *GoogleCloudStorage) CreateObject(ctx context.Context, bucket, objectName string, contents []byte, cacheable bool, contentType string) error

CreateObject creates a new cloud storage object or overwrites an existing one.

func (*GoogleCloudStorage) DeleteObject Uses

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.

func (*GoogleCloudStorage) GetObject Uses

func (s *GoogleCloudStorage) GetObject(ctx context.Context, bucket, object string) ([]byte, error)

GetObject returns the contents for the given object. If the object does not exist, it returns ErrNotFound.

type Memory Uses

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

Memory implements Blobstore and provides the ability write files to memory.

func (*Memory) CreateObject Uses

func (s *Memory) CreateObject(_ context.Context, folder, filename string, contents []byte, cacheable bool, contentType string) error

CreateObject creates a new object. contentType is ignored in this implementation.

func (*Memory) DeleteObject Uses

func (s *Memory) DeleteObject(_ context.Context, folder, filename string) error

DeleteObject deletes an object. It returns nil if the object was deleted or if the object no longer exists.

func (*Memory) GetObject Uses

func (s *Memory) GetObject(_ context.Context, folder, filename string) ([]byte, error)

GetObject returns the contents for the given object. If the object does not exist, it returns ErrNotFound.

type Noop Uses

type Noop struct{}

Noop is a blobstore that does nothing.

func (*Noop) CreateObject Uses

func (s *Noop) CreateObject(_ context.Context, _, _ string, _ []byte, _ bool, _ string) error

func (*Noop) DeleteObject Uses

func (s *Noop) DeleteObject(_ context.Context, _, _ string) error

func (*Noop) GetObject Uses

func (s *Noop) GetObject(_ context.Context, _, _ string) ([]byte, error)

Package storage imports 20 packages (graph) and is imported by 7 packages. Updated 2020-09-27. Refresh now. Tools for package owners.