storage

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2018 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Base64EncodingName = "base64"
	Base32EncodingName = "base32"
	HexEncodingName    = "hex"
)
View Source
const NotFoundCode = "NotFound"

Variables

This section is empty.

Functions

func ErrorAddressNotFound

func ErrorAddressNotFound(address []byte) error

func MakeAddresser added in v1.1.0

func MakeAddresser(hashProvider func() hash.Hash) func(data []byte) []byte

Close in hasher

func NewAddressEncoding

func NewAddressEncoding(encodeToString func([]byte) string,
	decodeString func(string) ([]byte, error)) *addressEncoding

func NewFileSystemStore

func NewFileSystemStore(rootDirectory string, addressEncoding AddressEncoding) (*fileSystemStore, error)

func NewLoggingStore

func NewLoggingStore(store NamedStore, logger log.Logger) *loggingStore

Decorates a Store with some simple logging of method/address pairs

func NewMemoryStore

func NewMemoryStore() *memoryStore

func NewS3Store

func NewS3Store(s3Bucket, s3Prefix string, addressEncoding AddressEncoding,
	awsConfig *aws.Config, logger log.Logger) (*s3Store, error)

func NewSyncStore

func NewSyncStore(store NamedStore) *syncStore

Wrap a Store to synchronise it with respect to address access. For each address exactly one writer can enter the Put method of the underlying store or multiple readers can enter the Get and Stat methods, but no simultaneous readers (Getters, Statters) and writers (Putters) are allowed. Concurrent reads and writes to different addresses are permitted so the underlying store must be goroutine-safe across addresses.

func Session

func Session(awsConfig *aws.Config) (*session.Session, error)

Types

type AddressEncoding

type AddressEncoding interface {
	EncodeToString(address []byte) (addressString string)
	DecodeString(addressString string) (address []byte, err error)
}

func GetAddressEncoding

func GetAddressEncoding(name string) (AddressEncoding, error)

type ContentAddressedStore

type ContentAddressedStore interface {
	ReadStore
	Locator
	// Put the data at its address
	Put(data []byte) (address []byte, err error)
	// Get the address of some data without putting it at that address
	Address(data []byte) (address []byte)
}

func NewContentAddressedStore

func NewContentAddressedStore(addresser func([]byte) []byte, store Store) ContentAddressedStore

type Locator

type Locator interface {
	// Provides a canonical external location for some data, typically a URI
	Location(address []byte) string
}

type NamedStore added in v1.1.0

type NamedStore interface {
	// Human readable name describing the Store
	Name() string
	Store
}

type ReadStore

type ReadStore interface {
	// Get data stored at address
	Get(address []byte) (data []byte, err error)
	// Get stats on file including existence
	Stat(address []byte) (*StatInfo, error)
}

type StatInfo

type StatInfo struct {
	Exists bool
	Size   uint64
}

type Store

type Store interface {
	ReadStore
	WriteStore
	Locator
}

type WriteStore

type WriteStore interface {
	// Put data at address
	Put(address, data []byte) error
}

Jump to

Keyboard shortcuts

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