Rename jsonEvent to evt

This commit is contained in:
Mak Muftic 2021-09-15 16:16:12 +02:00
parent add13c2646
commit 67c1d633c6
3 changed files with 15 additions and 15 deletions

View File

@ -33,20 +33,20 @@ type elasticSearchTransport struct {
cl *elasticsearch.Client
}
func (est *elasticSearchTransport) Transport(event TracerTransportEvent) error {
func (est *elasticSearchTransport) Transport(evt TracerTransportEvent) error {
var e interface{}
var docId string
if event.lotusTraceEvent != nil {
e = *event.lotusTraceEvent
if evt.lotusTraceEvent != nil {
e = *evt.lotusTraceEvent
docId = ElasticSearch_DOC_LOTUS
} else if event.pubsubTraceEvent != nil {
e = *event.pubsubTraceEvent
} else if evt.pubsubTraceEvent != nil {
e = *evt.pubsubTraceEvent
docId = ElasticSearch_DOC_PUBSUB
} else {
return nil
}
jsonEvent, err := json.Marshal(e)
jsonEvt, err := json.Marshal(e)
if err != nil {
return fmt.Errorf("error while marshaling event: %s", err)
}
@ -54,7 +54,7 @@ func (est *elasticSearchTransport) Transport(event TracerTransportEvent) error {
req := esapi.IndexRequest{
Index: ElasticSearch_INDEX,
DocumentID: docId,
Body: strings.NewReader(string(jsonEvent)),
Body: strings.NewReader(string(jsonEvt)),
Refresh: "true",
}

View File

@ -16,21 +16,21 @@ func NewJsonTracerTransport(out *os.File) TracerTransport {
}
}
func (jtt *jsonTracerTransport) Transport(event TracerTransportEvent) error {
func (jtt *jsonTracerTransport) Transport(evt TracerTransportEvent) error {
var e interface{}
if event.lotusTraceEvent != nil {
e = *event.lotusTraceEvent
} else if event.pubsubTraceEvent != nil {
e = *event.pubsubTraceEvent
if evt.lotusTraceEvent != nil {
e = *evt.lotusTraceEvent
} else if evt.pubsubTraceEvent != nil {
e = *evt.pubsubTraceEvent
} else {
return nil
}
jsonEvent, err := json.Marshal(e)
jsonEvt, err := json.Marshal(e)
if err != nil {
return fmt.Errorf("error while marshaling event: %s", err)
}
_, err = jtt.out.Write(jsonEvent)
_, err = jtt.out.Write(jsonEvt)
return err
}

View File

@ -3,7 +3,7 @@ package tracer
import pubsub_pb "github.com/libp2p/go-libp2p-pubsub/pb"
type TracerTransport interface {
Transport(jsonEvent TracerTransportEvent) error
Transport(evt TracerTransportEvent) error
}
type TracerTransportEvent struct {