Unverified Commit eebeec43 authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #52 from libp2p/minimalsub

fix: rename MinimalPubsub -> Pubsub interface and improve docs
parents 93f8ec99 aa0520d8
......@@ -24,11 +24,10 @@ import (
var log = logging.Logger("pubsub-valuestore")
// MinimalPubsub allows us to provide the bare minimum pubsub functionality
// to the router, while still using the same pubsub instance in other goroutines.
// This is primarily done to allow callers to not have to worry about topic management
// due to topics only allowing a single "joiner".
type MinimalPubsub interface {
// 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 Pubsub interface {
RegisterTopicValidator(topic string, val pubsub.Validator, opts ...pubsub.ValidatorOpt) error
Join(topic string, opts ...pubsub.TopicOpt) (*pubsub.Topic, error)
}
......@@ -41,7 +40,7 @@ type watchGroup struct {
type PubsubValueStore struct {
ctx context.Context
ds ds.Datastore
ps MinimalPubsub
ps Pubsub
host host.Host
fetch *fetchProtocol
......@@ -81,7 +80,7 @@ func KeyToTopic(key string) string {
type Option func(*PubsubValueStore) error
// NewPubsubValueStore constructs a new ValueStore that gets and receives records through pubsub.
func NewPubsubValueStore(ctx context.Context, host host.Host, ps MinimalPubsub, validator record.Validator, opts ...Option) (*PubsubValueStore, error) {
func NewPubsubValueStore(ctx context.Context, host host.Host, ps Pubsub, validator record.Validator, opts ...Option) (*PubsubValueStore, error) {
psValueStore := &PubsubValueStore{
ctx: ctx,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment