From 0aa629c79cbea3146929fd787b12cc4941478e74 Mon Sep 17 00:00:00 2001 From: vyzo Date: Wed, 13 Nov 2019 12:22:40 +0200 Subject: [PATCH] use *pb.TraceEvent as argument for Trace in the EventTracer interface --- trace.go | 2 +- tracer.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/trace.go b/trace.go index 5b3a558..293f166 100644 --- a/trace.go +++ b/trace.go @@ -11,7 +11,7 @@ import ( // Generic event tracer interface type EventTracer interface { - Trace(evt interface{}) + Trace(evt *pb.TraceEvent) } // pubsub tracer details diff --git a/tracer.go b/tracer.go index fe6e47f..01b1ec6 100644 --- a/tracer.go +++ b/tracer.go @@ -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()) }