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
0aa629c7
Commit
0aa629c7
authored
Nov 13, 2019
by
vyzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use *pb.TraceEvent as argument for Trace in the EventTracer interface
parent
f134d658
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
trace.go
trace.go
+1
-1
tracer.go
tracer.go
+5
-5
No files found.
trace.go
View file @
0aa629c7
...
...
@@ -11,7 +11,7 @@ import (
// Generic event tracer interface
type
EventTracer
interface
{
Trace
(
evt
interface
{}
)
Trace
(
evt
*
pb
.
TraceEvent
)
}
// pubsub tracer details
...
...
tracer.go
View file @
0aa629c7
...
...
@@ -14,10 +14,10 @@ import (
type
basicTracer
struct
{
ch
chan
struct
{}
mx
sync
.
Mutex
buf
[]
interface
{}
buf
[]
*
pb
.
TraceEvent
}
func
(
t
*
basicTracer
)
Trace
(
evt
interface
{}
)
{
func
(
t
*
basicTracer
)
Trace
(
evt
*
pb
.
TraceEvent
)
{
t
.
mx
.
Lock
()
t
.
buf
=
append
(
t
.
buf
,
evt
)
t
.
mx
.
Unlock
()
...
...
@@ -57,7 +57,7 @@ func OpenJSONTracer(file string, flags int, perm os.FileMode) (*JSONTracer, erro
}
func
(
t
*
JSONTracer
)
doWrite
()
{
var
buf
[]
interface
{}
var
buf
[]
*
pb
.
TraceEvent
enc
:=
json
.
NewEncoder
(
t
.
w
)
for
{
_
,
ok
:=
<-
t
.
ch
...
...
@@ -109,7 +109,7 @@ func OpenPBTracer(file string, flags int, perm os.FileMode) (*PBTracer, error) {
}
func
(
t
*
PBTracer
)
doWrite
()
{
var
buf
[]
interface
{}
var
buf
[]
*
pb
.
TraceEvent
w
:=
ggio
.
NewDelimitedWriter
(
t
.
w
)
for
{
_
,
ok
:=
<-
t
.
ch
...
...
@@ -121,7 +121,7 @@ func (t *PBTracer) doWrite() {
t
.
mx
.
Unlock
()
for
i
,
evt
:=
range
buf
{
err
:=
w
.
WriteMsg
(
evt
.
(
*
pb
.
TraceEvent
)
)
err
:=
w
.
WriteMsg
(
evt
)
if
err
!=
nil
{
log
.
Errorf
(
"error writing event trace: %s"
,
err
.
Error
())
}
...
...
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