Documentation ¶
Index ¶
- func NewComposableParallel(routers []*ParallelRouter) *composableParallel
- func NewComposableSequential(routers []*SequentialRouter) *composableSequential
- type Bootstrap
- type ComposableRouter
- type Compose
- func (cr *Compose) Bootstrap(ctx context.Context) (err error)
- func (cr *Compose) FindPeer(ctx context.Context, p peer.ID) (info peer.AddrInfo, err error)
- func (cr *Compose) FindProvidersAsync(ctx context.Context, c cid.Cid, count int) <-chan peer.AddrInfo
- func (cr *Compose) GetPublicKey(ctx context.Context, p peer.ID) (ci.PubKey, error)
- func (cr *Compose) GetValue(ctx context.Context, key string, opts ...routing.Option) (value []byte, err error)
- func (cr *Compose) Provide(ctx context.Context, c cid.Cid, local bool) (err error)
- func (cr *Compose) PutValue(ctx context.Context, key string, value []byte, opts ...routing.Option) (err error)
- func (cr *Compose) SearchValue(ctx context.Context, key string, opts ...routing.Option) (ch <-chan []byte, err error)
- type LimitedValueStore
- func (lvs *LimitedValueStore) Bootstrap(ctx context.Context) error
- func (lvs *LimitedValueStore) Close() error
- func (lvs *LimitedValueStore) GetPublicKey(ctx context.Context, p peer.ID) (ci.PubKey, error)
- func (lvs *LimitedValueStore) GetValue(ctx context.Context, key string, opts ...routing.Option) ([]byte, error)
- func (lvs *LimitedValueStore) KeySupported(key string) bool
- func (lvs *LimitedValueStore) PutValue(ctx context.Context, key string, value []byte, opts ...routing.Option) error
- func (lvs *LimitedValueStore) SearchValue(ctx context.Context, key string, opts ...routing.Option) (<-chan []byte, error)
- type Null
- func (nr Null) Bootstrap(context.Context) error
- func (nr Null) Close() error
- func (nr Null) FindPeer(context.Context, peer.ID) (peer.AddrInfo, error)
- func (nr Null) FindProvidersAsync(context.Context, cid.Cid, int) <-chan peer.AddrInfo
- func (nr Null) GetValue(context.Context, string, ...routing.Option) ([]byte, error)
- func (nr Null) Provide(context.Context, cid.Cid, bool) error
- func (nr Null) PutValue(context.Context, string, []byte, ...routing.Option) error
- func (nr Null) SearchValue(ctx context.Context, key string, opts ...routing.Option) (<-chan []byte, error)
- type Parallel
- func (r Parallel) Bootstrap(ctx context.Context) error
- func (r Parallel) Close() error
- func (r Parallel) FindPeer(ctx context.Context, p peer.ID) (peer.AddrInfo, error)
- func (r Parallel) FindProvidersAsync(ctx context.Context, c cid.Cid, count int) <-chan peer.AddrInfo
- func (r Parallel) GetPublicKey(ctx context.Context, p peer.ID) (ci.PubKey, error)
- func (r Parallel) GetValue(ctx context.Context, key string, opts ...routing.Option) ([]byte, error)
- func (r Parallel) Provide(ctx context.Context, c cid.Cid, local bool) error
- func (r Parallel) PutValue(ctx context.Context, key string, value []byte, opts ...routing.Option) error
- func (r Parallel) SearchValue(ctx context.Context, key string, opts ...routing.Option) (<-chan []byte, error)
- type ParallelRouter
- type ProvideManyRouter
- type ReadyAbleRouter
- type SequentialRouter
- type Tiered
- func (r Tiered) Bootstrap(ctx context.Context) error
- func (r Tiered) Close() error
- func (r Tiered) FindPeer(ctx context.Context, p peer.ID) (peer.AddrInfo, error)
- func (r Tiered) FindProvidersAsync(ctx context.Context, c cid.Cid, count int) <-chan peer.AddrInfo
- func (r Tiered) GetPublicKey(ctx context.Context, p peer.ID) (ci.PubKey, error)
- func (r Tiered) GetValue(ctx context.Context, key string, opts ...routing.Option) ([]byte, error)
- func (r Tiered) Provide(ctx context.Context, c cid.Cid, local bool) error
- func (r Tiered) PutValue(ctx context.Context, key string, value []byte, opts ...routing.Option) error
- func (r Tiered) SearchValue(ctx context.Context, key string, opts ...routing.Option) (<-chan []byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewComposableParallel ¶
func NewComposableParallel(routers []*ParallelRouter) *composableParallel
NewComposableParallel creates a Router that will execute methods from provided Routers in parallel. On all methods, If IgnoreError flag is set, that Router will not stop the entire execution. On all methods, If ExecuteAfter is set, that Router will be executed after the timer. Router specific timeout will start counting AFTER the ExecuteAfter timer.
func NewComposableSequential ¶
func NewComposableSequential(routers []*SequentialRouter) *composableSequential
Types ¶
type Bootstrap ¶
type Bootstrap interface { // Bootstrap bootstraps the router. Bootstrap(ctx context.Context) error }
Bootstrap is an interface that should be implemented by any routers wishing to be bootstrapped.
type ComposableRouter ¶
type Compose ¶
type Compose struct { ValueStore routing.ValueStore PeerRouting routing.PeerRouting ContentRouting routing.ContentRouting }
Compose composes the components into a single router. Not specifying a component (leaving it nil) is equivalent to specifying the Null router.
It also implements Bootstrap. All *distinct* components implementing Bootstrap will be bootstrapped in parallel. Identical components will not be bootstrapped twice.
func (*Compose) FindPeer ¶
FindPeer searches for a peer with given ID, returns a peer.AddrInfo with relevant addresses.
func (*Compose) FindProvidersAsync ¶
func (cr *Compose) FindProvidersAsync(ctx context.Context, c cid.Cid, count int) <-chan peer.AddrInfo
FindProvidersAsync searches for peers who are able to provide a given key.
If count > 0, it returns at most count providers. If count == 0, it returns an unbounded number of providers.
func (*Compose) GetPublicKey ¶
GetPublicKey returns the public key for the given peer.
func (*Compose) GetValue ¶
func (cr *Compose) GetValue(ctx context.Context, key string, opts ...routing.Option) (value []byte, err error)
GetValue searches for the value corresponding to given Key.
func (*Compose) Provide ¶
Provide adds the given cid to the content routing system. If 'true' is passed, it also announces it, otherwise it is just kept in the local accounting of which objects are being provided.
type LimitedValueStore ¶
type LimitedValueStore struct { routing.ValueStore Namespaces []string }
LimitedValueStore limits the internal value store to the given namespaces.
func (*LimitedValueStore) Bootstrap ¶
func (lvs *LimitedValueStore) Bootstrap(ctx context.Context) error
Bootstrap signals the underlying value store to get into the "bootstrapped" state, if it implements the Bootstrap interface.
func (*LimitedValueStore) Close ¶
func (lvs *LimitedValueStore) Close() error
Close closest the underlying value store if it implements the io.Closer interface.
func (*LimitedValueStore) GetPublicKey ¶
GetPublicKey returns the public key for the given peer, if and only if this router supports the /pk namespace. Otherwise, it returns routing.ErrNotFound.
func (*LimitedValueStore) GetValue ¶
func (lvs *LimitedValueStore) GetValue(ctx context.Context, key string, opts ...routing.Option) ([]byte, error)
GetValue retrieves the given key from the underlying value store if the namespace is supported. Otherwise, it returns routing.ErrNotFound.
func (*LimitedValueStore) KeySupported ¶
func (lvs *LimitedValueStore) KeySupported(key string) bool
KeySupported returns true if the passed key is supported by this value store.
func (*LimitedValueStore) PutValue ¶
func (lvs *LimitedValueStore) PutValue(ctx context.Context, key string, value []byte, opts ...routing.Option) error
PutValue puts the given key in the underlying value store if the namespace is supported. Otherwise, it returns routing.ErrNotSupported.
func (*LimitedValueStore) SearchValue ¶
func (lvs *LimitedValueStore) SearchValue(ctx context.Context, key string, opts ...routing.Option) (<-chan []byte, error)
SearchValue searches the underlying value store for the given key if the namespace is supported, returning results in monotonically increasing "freshness". Otherwise, it returns an empty, closed channel to indicate that the value wasn't found.
type Null ¶
type Null struct{}
Null is a router that doesn't do anything.
func (Null) FindProvidersAsync ¶
FindProvidersAsync always returns a closed channel
type Parallel ¶
Parallel operates on the slice of routers in parallel.
func (Parallel) FindPeer ¶
FindPeer finds the given peer in all sub-routers in parallel, returning the first result.
func (Parallel) FindProvidersAsync ¶
func (r Parallel) FindProvidersAsync(ctx context.Context, c cid.Cid, count int) <-chan peer.AddrInfo
FindProvidersAsync searches all sub-routers in parallel for peers who are able to provide a given key.
If count > 0, it returns at most count providers. If count == 0, it returns an unbounded number of providers.
func (Parallel) GetPublicKey ¶
GetPublicKey retrieves the public key from all sub-routers in parallel, returning the first result.
func (Parallel) GetValue ¶
GetValue searches all sub-routers for the given key, returning the result from the first sub-router to complete the query.
func (Parallel) Provide ¶
Provide announces that this peer provides the content in question to all sub-routers in parallel. Provide returns success as long as a single sub-router succeeds, but still waits for all sub-routers to finish before returning.
If count > 0, it returns at most count providers. If count == 0, it returns an unbounded number of providers.
type ParallelRouter ¶
type ProvideManyRouter ¶
type ReadyAbleRouter ¶
type ReadyAbleRouter interface {
Ready() bool
}
type SequentialRouter ¶
type Tiered ¶
Tiered is like the Parallel except that GetValue and FindPeer are called in series.
func (Tiered) FindPeer ¶
FindPeer sequentially searches for given peer using each sub-router, returning the first result.
func (Tiered) FindProvidersAsync ¶
FindProvidersAsync searches all sub-routers in parallel for peers who are able to provide a given key.
If count > 0, it returns at most count providers. If count == 0, it returns an unbounded number of providers.
func (Tiered) GetPublicKey ¶
GetPublicKey sequentially searches each sub-router for the the public key, returning the first result.
func (Tiered) GetValue ¶
GetValue sequentially searches each sub-router for the given key, returning the value from the first sub-router to complete the query.
func (Tiered) Provide ¶
Provide announces that this peer provides the content in question to all sub-routers in parallel. Provide returns success as long as a single sub-router succeeds, but still waits for all sub-routers to finish before returning.