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
Commits
fb11aa98
Commit
fb11aa98
authored
Nov 11, 2019
by
vyzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initialize tracer with peer ID, trace RPC from join/leave announcements
parent
958e09a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
1 deletion
+6
-1
pubsub.go
pubsub.go
+5
-1
trace.go
trace.go
+1
-0
No files found.
pubsub.go
View file @
fb11aa98
...
...
@@ -326,7 +326,7 @@ func WithDiscovery(d discovery.Discovery, opts ...DiscoverOpt) Option {
// WithEventTracer provides a tracer for the pubsub system
func
WithEventTracer
(
tracer
EventTracer
)
Option
{
return
func
(
p
*
PubSub
)
error
{
p
.
tracer
=
&
pubsubTracer
{
tracer
:
tracer
}
p
.
tracer
=
&
pubsubTracer
{
tracer
:
tracer
,
pid
:
p
.
host
.
ID
()
}
return
nil
}
}
...
...
@@ -582,8 +582,10 @@ func (p *PubSub) announce(topic string, sub bool) {
for
pid
,
peer
:=
range
p
.
peers
{
select
{
case
peer
<-
out
:
p
.
tracer
.
SendRPC
(
out
,
pid
)
default
:
log
.
Infof
(
"Can't send announce message to peer %s: queue full; scheduling retry"
,
pid
)
p
.
tracer
.
DropRPC
(
out
,
pid
)
go
p
.
announceRetry
(
pid
,
topic
,
sub
)
}
}
...
...
@@ -619,8 +621,10 @@ func (p *PubSub) doAnnounceRetry(pid peer.ID, topic string, sub bool) {
out
:=
rpcWithSubs
(
subopt
)
select
{
case
peer
<-
out
:
p
.
tracer
.
SendRPC
(
out
,
pid
)
default
:
log
.
Infof
(
"Can't send announce message to peer %s: queue full; scheduling retry"
,
pid
)
p
.
tracer
.
DropRPC
(
out
,
pid
)
go
p
.
announceRetry
(
pid
,
topic
,
sub
)
}
}
...
...
trace.go
View file @
fb11aa98
...
...
@@ -12,6 +12,7 @@ type EventTracer interface {
type
pubsubTracer
struct
{
tracer
EventTracer
pid
peer
.
ID
}
func
(
t
*
pubsubTracer
)
PublishMessage
(
msg
*
Message
)
{
...
...
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