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
c8ce5b67
Unverified
Commit
c8ce5b67
authored
Jan 15, 2020
by
Alex Trottier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add minimalsub interface
parent
d9380bd9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
pubsub.go
pubsub.go
+11
-2
No files found.
pubsub.go
View file @
c8ce5b67
...
@@ -24,6 +24,15 @@ import (
...
@@ -24,6 +24,15 @@ import (
var
log
=
logging
.
Logger
(
"pubsub-valuestore"
)
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
{
RegisterTopicValidator
(
topic
string
,
val
pubsub
.
Validator
,
opts
...
pubsub
.
ValidatorOpt
)
error
Join
(
topic
string
,
opts
...
pubsub
.
TopicOpt
)
(
*
pubsub
.
Topic
,
error
)
}
type
watchGroup
struct
{
type
watchGroup
struct
{
// Note: this chan must be buffered, see notifyWatchers
// Note: this chan must be buffered, see notifyWatchers
listeners
map
[
chan
[]
byte
]
struct
{}
listeners
map
[
chan
[]
byte
]
struct
{}
...
@@ -32,7 +41,7 @@ type watchGroup struct {
...
@@ -32,7 +41,7 @@ type watchGroup struct {
type
PubsubValueStore
struct
{
type
PubsubValueStore
struct
{
ctx
context
.
Context
ctx
context
.
Context
ds
ds
.
Datastore
ds
ds
.
Datastore
ps
*
pubsub
.
PubS
ub
ps
MinimalPubs
ub
host
host
.
Host
host
host
.
Host
fetch
*
fetchProtocol
fetch
*
fetchProtocol
...
@@ -72,7 +81,7 @@ func KeyToTopic(key string) string {
...
@@ -72,7 +81,7 @@ func KeyToTopic(key string) string {
type
Option
func
(
*
PubsubValueStore
)
error
type
Option
func
(
*
PubsubValueStore
)
error
// NewPubsubValueStore constructs a new ValueStore that gets and receives records through pubsub.
// NewPubsubValueStore constructs a new ValueStore that gets and receives records through pubsub.
func
NewPubsubValueStore
(
ctx
context
.
Context
,
host
host
.
Host
,
ps
*
pubsub
.
PubS
ub
,
validator
record
.
Validator
,
opts
...
Option
)
(
*
PubsubValueStore
,
error
)
{
func
NewPubsubValueStore
(
ctx
context
.
Context
,
host
host
.
Host
,
ps
MinimalPubs
ub
,
validator
record
.
Validator
,
opts
...
Option
)
(
*
PubsubValueStore
,
error
)
{
psValueStore
:=
&
PubsubValueStore
{
psValueStore
:=
&
PubsubValueStore
{
ctx
:
ctx
,
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