Documentation ¶
Index ¶
Constants ¶
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 ¶
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 ¶
NewFatalResult creates a new Result object with a fatal error.
func NewInitialResult ¶
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 ¶
Errored returns whether the store has encountered too many errors when querying the peers.
func (*Store) Exhausted ¶
Exhausted returns whether the store has exhausted all peers to store the value in.
func (*Store) Exists ¶
Exists returns whether the value already exists (and the search has found it).
func (*Store) MarshalLogObject ¶
func (s *Store) MarshalLogObject(oe zapcore.ObjectEncoder) error
MarshalLogObject marshals the search to a zap ObjectEncoder (usually a JsonEncoder).
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.