s3store

package module
v0.0.0-...-40151bf Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 16 Imported by: 1

README

s3store

GoDoc

Package s3store implements the blob.Store interface using Amazon S3.

Documentation

Overview

Package s3store implements the blob.Store interface on Amazon S3.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Opener

func Opener(_ context.Context, addr string) (blob.Store, error)

Opener constructs a store from an address comprising a bucket name and storage region, and an optional prefix, in the format:

[prefix@]bucket:region[?query]

Query parameters:

read_qps   : rate limit for read (GET) queries
write_qps  : rate limit for write (PUT/DELETE) queries

Types

type Options

type Options struct {
	// If set, this prefix is prepended to all keys sent to S3.
	// A trailing slash ("/") is appended if one is not already present.
	KeyPrefix string

	// If set, us these rate limits apply to requests to the store.
	ReadQPS  int
	WriteQPS int

	// An optional AWS configuration to use when constructing the session.
	AWSConfig *aws.Config
}

Options are optional settings for a Store. A nil *Options is ready for use and provides zero values for all fields.

type Store

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

A Store implements the blob.Store interface on an S3 bucket. Since S3 does not support empty keys, access to an empty key will report blob.ErrKeyNotFound as required by the interface.

func New

func New(bucket, region string, opts *Options) (*Store, error)

New creates a new Store that references the given bucket and region. If opts == nil, default options are provided as described on Options.

By default, New constructs an AWS session using ambient credentials from the environment or from a configuration file profile. To specify credentials from another source, set the AWSConfig field of the options.

func (*Store) Close

func (*Store) Close(_ context.Context) error

Close implements part of the blob.Store interface. It is a no-op here.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, key string) error

Delete atomically removes a blob from the store.

func (*Store) Get

func (s *Store) Get(ctx context.Context, key string) ([]byte, error)

Get fetches the contents of a blob from the store.

func (*Store) Len

func (s *Store) Len(ctx context.Context) (int64, error)

Len reports the number of keys currently in the store.

func (*Store) List

func (s *Store) List(ctx context.Context, start string, f func(string) error) error

List calls f with each key in the store in lexicographic order, beginning with the first key greater than or equal to start.

func (*Store) Put

func (s *Store) Put(ctx context.Context, opts blob.PutOptions) error

Put writes a blob to the store.

Jump to

Keyboard shortcuts

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