Documentation ¶
Index ¶
- Constants
- func KeyToTopic(key string) string
- type Option
- type Pubsub
- type PubsubValueStore
- func (p *PubsubValueStore) Cancel(name string) (bool, error)
- func (p *PubsubValueStore) GetSubscriptions() []string
- func (p *PubsubValueStore) GetValue(ctx context.Context, key string, opts ...routing.Option) ([]byte, error)
- func (p *PubsubValueStore) PutValue(ctx context.Context, key string, value []byte, opts ...routing.Option) error
- func (p *PubsubValueStore) SearchValue(ctx context.Context, key string, opts ...routing.Option) (<-chan []byte, error)
- func (p *PubsubValueStore) Subscribe(key string) error
Constants ¶
const FetchProtoID = protocol.ID("/p2p/fetch/0.0.1")
Variables ¶
This section is empty.
Functions ¶
func KeyToTopic ¶
KeyToTopic converts a binary record key to a pubsub topic key.
Types ¶
type Option ¶
type Option func(*PubsubValueStore) error
Option is a function that configures a PubsubValueStore during initialization
func WithDatastore ¶
WithDatastore returns an option that overrides the default datastore.
func WithRebroadcastInterval ¶
type Pubsub ¶
type Pubsub interface { RegisterTopicValidator(topic string, validator interface{}, opts ...pubsub.ValidatorOpt) error Join(topic string, opts ...pubsub.TopicOpt) (*pubsub.Topic, error) }
Pubsub is the minimal subset of the pubsub interface required by the pubsub value store. This way, users can wrap the underlying pubsub implementation without re-exporting/implementing the entire interface.
type PubsubValueStore ¶
type PubsubValueStore struct { Validator record.Validator // contains filtered or unexported fields }
func NewPubsubValueStore ¶
func NewPubsubValueStore(ctx context.Context, host host.Host, ps Pubsub, validator record.Validator, opts ...Option) (*PubsubValueStore, error)
NewPubsubValueStore constructs a new ValueStore that gets and receives records through pubsub.
func (*PubsubValueStore) Cancel ¶
func (p *PubsubValueStore) Cancel(name string) (bool, error)
Cancel cancels a topic subscription; returns true if an active subscription was canceled
func (*PubsubValueStore) GetSubscriptions ¶
func (p *PubsubValueStore) GetSubscriptions() []string
GetSubscriptions retrieves a list of active topic subscriptions
func (*PubsubValueStore) PutValue ¶
func (p *PubsubValueStore) PutValue(ctx context.Context, key string, value []byte, opts ...routing.Option) error
PutValue publishes a record through pubsub
func (*PubsubValueStore) SearchValue ¶
func (*PubsubValueStore) Subscribe ¶
func (p *PubsubValueStore) Subscribe(key string) error