stores

package
v8.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Contains core types and logic pertaining to Hoard's backend storage services - but not the implementations of those stores to avoid a large number of possibly unwanted dependencies

Index

Constants

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

Variables

This section is empty.

Functions

func ErrorAddressNotFound

func ErrorAddressNotFound(address []byte) error

func MakeAddresser

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, encoding 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 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 RunTests

func RunTests(t *testing.T, store Store)

Generic test suite for all Stores

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)
	// Delete data from address
	Delete(address []byte) 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

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 {
	// The address will be the same as the one passed in but is repeated to
	// make result self-describing
	Address []byte `protobuf:"bytes,1,opt,name=Address,proto3" json:"Address,omitempty"`
	// If the blob does not exist this will be false instead of returning an
	// error
	Exists bool `protobuf:"varint,2,opt,name=Exists,proto3" json:"Exists,omitempty"`
	// Will be 0 if the blob does not existing (or omitted under protobuf3)
	Size_ uint64 `protobuf:"varint,3,opt,name=Size,proto3" json:"Size,omitempty"`
	// The externally resolvable location of the encrypted blob. The location
	// will be hypothetical if the blob does not exist
	Location             string   `protobuf:"bytes,4,opt,name=Location,proto3" json:"Location,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*StatInfo) Descriptor

func (*StatInfo) Descriptor() ([]byte, []int)

func (*StatInfo) GetAddress

func (m *StatInfo) GetAddress() []byte

func (*StatInfo) GetExists

func (m *StatInfo) GetExists() bool

func (*StatInfo) GetLocation

func (m *StatInfo) GetLocation() string

func (*StatInfo) GetSize_

func (m *StatInfo) GetSize_() uint64

func (*StatInfo) ProtoMessage

func (*StatInfo) ProtoMessage()

func (*StatInfo) Reset

func (m *StatInfo) Reset()

func (*StatInfo) String

func (m *StatInfo) String() string

func (*StatInfo) XXX_DiscardUnknown

func (m *StatInfo) XXX_DiscardUnknown()

func (*StatInfo) XXX_Marshal

func (m *StatInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*StatInfo) XXX_Merge

func (m *StatInfo) XXX_Merge(src proto.Message)

func (*StatInfo) XXX_Size

func (m *StatInfo) XXX_Size() int

func (*StatInfo) XXX_Unmarshal

func (m *StatInfo) XXX_Unmarshal(b []byte) error

type Store

type Store interface {
	ReadStore
	WriteStore
	Locator
}

type WriteStore

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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