Documentation
¶
Index ¶
- type Bucket
- type Iterator
- type Sink
- func (r *Sink) DeleteObjects(ctx context.Context, prefix string, objectNames []string) map[string]error
- func (r *Sink) Download(ctx context.Context, objectKey string, fullFilePath string) (returnErr error)
- func (r *Sink) List(ctx context.Context, prefix string) (res []string, err error)
- func (r *Sink) Upload(ctx context.Context, fullFilePath string, prefix string, ...) (returnErr error)
- type SinkOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket interface {
Download(ctx context.Context, key string, w io.Writer, opts *blob.ReaderOptions) error
Upload(ctx context.Context, key string, r io.Reader, opts *blob.WriterOptions) error
List(opts *blob.ListOptions) *blob.ListIterator
Delete(ctx context.Context, key string) (err error)
Attributes(ctx context.Context, key string) (*blob.Attributes, error)
Close() error
}
Bucket is an interface to abstract the behavior of the gocloud.dev/blob Bucket type. This abstraction is especially useful when adding a customized bucket to intercept traffic or to modify the functionality for specific use cases.
type Iterator ¶
type Iterator interface {
Next(ctx context.Context) (*blob.ListObject, error)
}
Iterator is an interface to abstract the behavior of the gocloud.dev/blob ListIterator type. This abstraction is especially useful when adding a customized bucket to intercept traffic or to modify the functionality for specific use cases.
type Sink ¶
type Sink struct {
// contains filtered or unexported fields
}
Sink is a wrapper around the storage bucket, providing an interface for operations on offloaded objects.
func NewSink ¶
func NewSink(bucket Bucket, options ...SinkOption) (*Sink, error)
NewSink creates a Sink from the given options. If some options are not specified, the function will use the default values for them.
func (*Sink) DeleteObjects ¶
func (r *Sink) DeleteObjects(ctx context.Context, prefix string, objectNames []string) map[string]error
DeleteObjects attempts to delete the specified objects within the given prefix. The result is a map of objectKey to error. Successfully deleted objects will not appear in the map.
func (*Sink) Download ¶
func (r *Sink) Download(ctx context.Context, objectKey string, fullFilePath string) (returnErr error)
Download retrieves a file from the bucket and saves it to the specified location on the local file system. The objectKey is the key of the object in the bucket, which includes the prefix and object name (e.g., "prefix/my_object.idx"); fullFilePath is full path on the local file system where the object will be saved including the file name (e.g., "/tmp/foo.txt").
type SinkOption ¶
type SinkOption func(*sinkCfg)
SinkOption modifies a sink configuration.
func WithBackoffStrategy ¶
func WithBackoffStrategy(strategy backoff.Strategy) SinkOption
WithBackoffStrategy sets the backoff strategy for retrying failed operations.
func WithMaxRetry ¶
func WithMaxRetry(max uint) SinkOption
WithMaxRetry sets the max backoffStrategy attempt. Use WithNoRetry if you do not want any retry. If the operation supports retries, it will attempt the operation up to maxRetry times with retryTimeout intervals between each attempt. Once the overallTimeout is exceeded, the operation will be terminated even if maxRetry attempts not been exhausted.
func WithNoRetry ¶
func WithNoRetry() SinkOption
WithNoRetry disables the backoffStrategy for the sink.
func WithOverallTimeout ¶
func WithOverallTimeout(timeout time.Duration) SinkOption
WithOverallTimeout sets the overallTimeout. The overallTimeout specifies the maximum allowed duration for the entire operation, including all retries. This ensures the operation completes or fails within a bounded time.
func WithRetryTimeout ¶
func WithRetryTimeout(duration time.Duration) SinkOption
WithRetryTimeout sets the retryTimeout. The retryTimeout specifies the maximum time to wait for each individual backoffStrategy attempt. This is useful for handling transient failures in a single operation while respecting the overall timeout.