dataaccess

package
v0.0.0-...-a821fee Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvGCSCredentials = "GCS_CREDENTIALS"
)

Variables

View Source
var StorageLatency = promauto.NewHistogramVec(
	prometheus.HistogramOpts{
		Name: "storage_latency",
		Help: "Duration of storage queries",
	},
	[]string{"query"},
)

StorageLatency is the duration of GCS queries.

Functions

func GenerateConnectionStr

func GenerateConnectionStr(v *viper.Viper, vs vault.Secrets) string

Types

type MockStorage

type MockStorage struct {
	mock.Mock
}

MockStorage is an autogenerated mock type for the Storage type

func NewMockStorage

func NewMockStorage(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockStorage

NewMockStorage creates a new instance of MockStorage. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockStorage) DeleteFile

func (_m *MockStorage) DeleteFile(ctx context.Context, filePath string) error

DeleteFile provides a mock function with given fields: ctx, filePath

func (*MockStorage) DownloadFile

func (_m *MockStorage) DownloadFile(ctx context.Context, filePath string) ([]byte, error)

DownloadFile provides a mock function with given fields: ctx, filePath

func (*MockStorage) Purge

func (_m *MockStorage) Purge(ctx context.Context, from time.Time) (int, error)

Purge provides a mock function with given fields: ctx, from

func (*MockStorage) SaveFile

func (_m *MockStorage) SaveFile(ctx context.Context, filePath string, file []byte) error

SaveFile provides a mock function with given fields: ctx, filePath, file

type Storage

type Storage interface {
	// SaveFile uploads a file to the storage bucket. This will replace any existing file with the same name.
	SaveFile(ctx context.Context, filePath string, file []byte) error

	// DownloadFile downloads a file from the storage bucket.
	DownloadFile(ctx context.Context, filePath string) ([]byte, error)

	// DeleteFile deletes a file from the storage bucket.
	DeleteFile(ctx context.Context, filePath string) error

	// Purge purges the data from the storage bucket out of the given range.
	Purge(ctx context.Context, from time.Time) (int, error)
}

func NewGCS

func NewGCS(gcs *storage.Client, bucket string) Storage

func NewLocal

func NewLocal() Storage

Jump to

Keyboard shortcuts

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