store

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultNReplicas is the numeber of
	DefaultNReplicas = uint(3)

	// DefaultNMaxErrors is the maximum number of errors tolerated during a search.
	DefaultNMaxErrors = uint(3)

	// DefaultConcurrency is the number of parallel store workers.
	DefaultConcurrency = uint(3)

	// DefaultQueryTimeout is the timeout for each query to a peer.
	DefaultQueryTimeout = 5 * time.Second
)

Variables

View Source
var (
	// ErrTooManyStoreErrors indicates when a store has encountered too many Store request errors.
	ErrTooManyStoreErrors = errors.New("too many Find errors")
)

Functions

This section is empty.

Types

type Parameters

type Parameters struct {
	// NReplicas is the number of replicas to store
	NReplicas uint

	// maximum number of errors tolerated when querying peers during the store
	NMaxErrors uint

	// number of concurrent queries to use in store
	Concurrency uint

	// timeout for queries to individual peers
	Timeout time.Duration
}

Parameters defines the parameters of the store.

func NewDefaultParameters

func NewDefaultParameters() *Parameters

NewDefaultParameters creates an instance with default parameters.

func (*Parameters) MarshalLogObject

func (p *Parameters) MarshalLogObject(oe zapcore.ObjectEncoder) error

MarshalLogObject marshals the parameters to to a zap ObjectEncoder (usually a JsonEncoder).

type Result

type Result struct {
	// Responded contains the peers that have successfully stored the value
	Responded []peer.Peer

	// Unqueried is a queue of peers to send store queries to
	Unqueried []peer.Peer

	// Search is search result from first part of store operation
	Search *search.Result

	// Errors is a list of errors encounters while querying peers
	Errors []error

	// FatalErr is the fatal error that occurred during the search
	FatalErr error
}

Result holds the store's (intermediate) result: the number of peers that have successfully stored the value.

func NewFatalResult

func NewFatalResult(fatalErr error) *Result

NewFatalResult creates a new Result object with a fatal error.

func NewInitialResult

func NewInitialResult(sr *search.Result) *Result

NewInitialResult creates a new Result object from the final search result.

func (*Result) MarshalLogObject

func (r *Result) MarshalLogObject(oe zapcore.ObjectEncoder) error

MarshalLogObject marshals the result to a zap ObjectEncoder (usually a JsonEncoder).

type Store

type Store struct {
	// CreateRq creates new Store requests
	CreateRq func() *api.StoreRequest

	// Result of the store
	Result *Result

	// Search defines the first part of store operation
	Search *search.Search

	// Params defining the store part of the operation
	Params *Parameters
	// contains filtered or unexported fields
}

Store contains things involved in storing a particular key/value pair.

func NewStore

func NewStore(
	peerID ecid.ID,
	orgID ecid.ID,
	key id.ID,
	value *api.Document,
	searchParams *search.Parameters,
	storeParams *Parameters,
) *Store

NewStore creates a new Store instance for a given target, search type, and search parameters.

func (*Store) Errored

func (s *Store) Errored() bool

Errored returns whether the store has encountered too many errors when querying the peers.

func (*Store) Exhausted

func (s *Store) Exhausted() bool

Exhausted returns whether the store has exhausted all peers to store the value in.

func (*Store) Exists

func (s *Store) Exists() bool

Exists returns whether the value already exists (and the search has found it).

func (*Store) Finished

func (s *Store) Finished() bool

Finished returns whether the store operation has finished.

func (*Store) MarshalLogObject

func (s *Store) MarshalLogObject(oe zapcore.ObjectEncoder) error

MarshalLogObject marshals the search to a zap ObjectEncoder (usually a JsonEncoder).

func (*Store) Stored

func (s *Store) Stored() bool

Stored returns whether the store has stored sufficient replicas.

type Storer

type Storer interface {
	// Store executes a store operation, starting with a given set of seed peers.
	Store(store *Store, seeds []peer.Peer) error
}

Storer executes store operations.

func NewDefaultStorer

func NewDefaultStorer(
	peerSigner client.Signer,
	orgSigner client.Signer,
	rec comm.QueryRecorder,
	doc comm.Doctor,
	clients client.Pool,
) Storer

NewDefaultStorer creates a new Storer with default Searcher and StoreQuerier instances.

func NewStorer

func NewStorer(
	peerSigner client.Signer,
	orgSigner client.Signer,
	rec comm.QueryRecorder,
	doc comm.Doctor,
	searcher search.Searcher,
	c client.StorerCreator,
) Storer

NewStorer creates a new Storer instance with given Searcher and StoreQuerier instances.

Jump to

Keyboard shortcuts

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