Refactoring protocolManager.go and tracer.go, improce dependency injection

This commit is contained in:
Mario
2022-05-11 22:58:03 +02:00
parent 3683659d35
commit 3c5ac84ef0
4 changed files with 24 additions and 23 deletions

View File

@ -1,22 +1,23 @@
package tracer
import (
log "github.com/sirupsen/logrus"
"net/http"
)
type Strategy func(event Event)
type Tracer struct {
strategy Strategy
}
func Init() *Tracer {
return &Tracer{}
func Init(strategy Strategy) *Tracer {
return &Tracer{
strategy: strategy,
}
}
func (tracer *Tracer) TraceEvent(event Event) {
log.WithFields(log.Fields{
"status": event.Status.String(),
"event": event,
}).Info("New Event")
tracer.strategy(event)
}
type Event struct {