Documentation
¶
Overview ¶
Package bucket defines an interface for cloud storage buckets (AWS S3, Google Cloud Storage, etc.).
It also provides a mock implementation backed by local FSDB for testing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket interface { // Read downloads an entry from the bucket. // // It's the caller's responsibility to close the ReadCloser returned. Read(ctx context.Context, name string) (io.ReadCloser, error) // Write uploads an entry to the bucket. Write(ctx context.Context, name string, data io.Reader) error // Delete deletes an entry from the bucket. Delete(ctx context.Context, name string) error // IsNotExist checks whether an error returned by Read or Delete means the // entry does not exist on the bucket. IsNotExist(err error) bool }
Bucket defines the interface for a remote storage bucket (e.g. s3 or gcs).
type Mock ¶
type Mock struct { ReadDelay MockOperationDelay WriteDelay MockOperationDelay DeleteDelay MockOperationDelay // contains filtered or unexported fields }
Mock is a mock implementation of Bucket, backed by local FSDB.
func MockBucket ¶
MockBucket creates a new mock Bucket using fsdb.
func (*Mock) IsNotExist ¶
IsNotExist calls fsdb.IsNoSuchKeyError.
type MockOperationDelay ¶
type MockOperationDelay struct { // Before is the delay between the function call and the actual operation. Before time.Duration // After is the delay between the actual operation completes and the function // returns. After time.Duration // Total is the minimal time the function call should take before returning. // Here are some examples assuming the operation itself takes 1ms and we have // a Total set to 50ms: // - If both Before and After are set to zero, the function call will take // 1ms to do the actual operation, then wait for ~49ms for the 50ms Total to // pass, so it returns after approximately 50ms; // - If both Before and After are set to 30ms, the function call will first // sleep 30ms, then take 1ms to do the actual operation, then sleep 30ms // again. At this time the Total 50ms is already passed so the function // returns at approximately 61ms. Total time.Duration }
MockOperationDelay defines the delays of an operation (function call). It's useful to mimic network latency in local tests.
Click to show internal directories.
Click to hide internal directories.