storage

package
v0.0.0-...-54565ea Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2018 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KeySuffix is the suffix appended to key names on disk.
	KeySuffix = ".gob"
)
View Source
const (
	// NoEntryForKey storage error msg
	NoEntryForKey string = "no entry for key"
)

---------- Error Types ---------

Variables

View Source
var KeyFormat = fmt.Sprintf("%%s%s", KeySuffix)

KeyFormat is used for creating the filename of the keys on disk

Functions

func PruneByPrefix

func PruneByPrefix(bucket string, prefix string, maxObjects int)

PruneByPrefix will remove objects over maxObjects from an S3 bucket with the given prefix

Types

type Bucket

type Bucket struct {

	// ACL Amazon S3 access control lists value
	ACL string
	// contains filtered or unexported fields
}

Bucket wraps the S3 downloader with an in memory cache

func NewS3

func NewS3(bucket, key string) *Bucket

NewS3 returns a Bucket with an S3 downloader

func (*Bucket) List

func (b *Bucket) List(prefix string, startAfter string) (*s3.ListObjectsV2Output, errors.TracerError)

List the contents of a bucket with the given prefix

func (*Bucket) ReadObject

func (b *Bucket) ReadObject() ([]byte, errors.TracerError)

ReadObject downloads a file from s3 into a byte array

func (*Bucket) WriteObject

func (b *Bucket) WriteObject(p []byte) errors.TracerError

WriteObject writes an object to a file in s3

type Provider

type Provider interface {
	Shard(name string) (Provider, error)
	Read(key string, target interface{}) error
	Write(key string, target interface{}) error
	Exists(key string) bool
	Delete(key string) error
}

Provider is a struct that implements the functions necessary to work with the persist package.

func NewDisk

func NewDisk(rootPath string, mode os.FileMode) (Provider, error)

NewDisk storage provider using the passed root path and creating files with the specified mode.

func NewMemoryStorage

func NewMemoryStorage() Provider

NewMemoryStorage for storing and retrieving key values.

Jump to

Keyboard shortcuts

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