Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-pubsub-router
Commits
eebeec43
Unverified
Commit
eebeec43
authored
Jan 16, 2020
by
Steven Allen
Committed by
GitHub
Jan 16, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #52 from libp2p/minimalsub
fix: rename MinimalPubsub -> Pubsub interface and improve docs
parents
93f8ec99
aa0520d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
7 deletions
+8
-7
go.sum
go.sum
+2
-0
pubsub.go
pubsub.go
+6
-7
No files found.
go.sum
View file @
eebeec43
...
...
@@ -123,6 +123,7 @@ github.com/libp2p/go-flow-metrics v0.0.1 h1:0gxuFd2GuK7IIP5pKljLwps6TvcuYgvG7Atq
github.com/libp2p/go-flow-metrics
v0.0.1/go.mod h1:
Iv1GH0sG8DtYN3SVJ2eG221wMiNpZxBdp967ls1g+k8=
github.com/libp2p/go-flow-metrics
v0.0.2 h1:
U5TvqfoyR6GVRM+bC15Ux1ltar1kbj6Zw6xOVR02CZs=
github.com/libp2p/go-flow-metrics
v0.0.2/go.mod h1:
HeoSNUrOJVK1jEpDqVEiUOIXqhbnS27omG0uWU5slZs=
github.com/libp2p/go-flow-metrics
v0.0.3 h1:
8tAs/hSdNvUiLgtlSy3mxwxWP4I9y/jlkPFT7epKdeM=
github.com/libp2p/go-flow-metrics
v0.0.3/go.mod h1:
HeoSNUrOJVK1jEpDqVEiUOIXqhbnS27omG0uWU5slZs=
github.com/libp2p/go-libp2p-blankhost
v0.1.1 h1:
X919sCh+KLqJcNRApj43xCSiQRYqOSI88Fdf55ngf78=
github.com/libp2p/go-libp2p-blankhost
v0.1.1/go.mod h1:
pf2fvdLJPsC1FsVrNP3DUUvMzUts2dsLLBEpo1vW1ro=
...
...
@@ -326,6 +327,7 @@ github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:
go.opencensus.io
v0.21.0/go.mod h1:
mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io
v0.22.1 h1:
8dP3SGL7MPB94crU3bEPplMPe83FI4EouesJUeFHv50=
go.opencensus.io
v0.22.1/go.mod h1:
Ap50jQcDJrx6rB6VgeeFPtuPIf3wMRvRfrfYDO6+BmA=
go.opencensus.io
v0.22.2 h1:
75k/FF0Q2YM8QYo07VPddOLBslDt1MZOdEslOHvmzAs=
go.opencensus.io
v0.22.2/go.mod h1:
yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
golang.org/x/crypto
v0.0.0-20170930174604-9419663f5a44/go.mod h1:
6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto
v0.0.0-20180904163835-0709b304e793/go.mod h1:
6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
...
...
pubsub.go
View file @
eebeec43
...
...
@@ -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
Minimal
Pubsub
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
Minimal
Pubsub
,
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
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment