diff --git a/parser/configurationsParser.go b/parser/configurationsParser.go index a550076..8b5e837 100644 --- a/parser/configurationsParser.go +++ b/parser/configurationsParser.go @@ -58,7 +58,7 @@ type ReadFileBytesByFilePath func(filePath string) ([]byte, error) type GelAllFilesNameByDirName func(dirName string) ([]string, error) -// Init Parser, return a configurationsParser and use the DI Pattern to inject the dependencies +// Init Parser, return a configurationsParser and use the D.I. Pattern to inject the dependencies func Init(configurationsCorePath, configurationsServicesDirectory string) *configurationsParser { return &configurationsParser{ configurationsCorePath: configurationsCorePath, diff --git a/protocols/protocolManager.go b/protocols/protocolManager.go index 1d5c029..b607694 100644 --- a/protocols/protocolManager.go +++ b/protocols/protocolManager.go @@ -11,7 +11,7 @@ type ServiceStrategy interface { type ProtocolManager struct { strategy ServiceStrategy - tracer *tracer.Tracer + tracer tracer.Tracer } func InitProtocolManager(tracerStrategy tracer.Strategy, strategy ServiceStrategy) *ProtocolManager { @@ -26,5 +26,5 @@ func (pm *ProtocolManager) SetProtocolStrategy(strategy ServiceStrategy) { } func (pm *ProtocolManager) InitService(beelzebubServiceConfiguration parser.BeelzebubServiceConfiguration) error { - return pm.strategy.Init(beelzebubServiceConfiguration, *pm.tracer) + return pm.strategy.Init(beelzebubServiceConfiguration, pm.tracer) } diff --git a/tracer/tracer.go b/tracer/tracer.go index 26f7276..cc05355 100644 --- a/tracer/tracer.go +++ b/tracer/tracer.go @@ -6,17 +6,21 @@ import ( type Strategy func(event Event) -type Tracer struct { +type Tracer interface { + TraceEvent(event Event) +} + +type tracer struct { strategy Strategy } -func Init(strategy Strategy) *Tracer { - return &Tracer{ +func Init(strategy Strategy) *tracer { + return &tracer{ strategy: strategy, } } -func (tracer *Tracer) TraceEvent(event Event) { +func (tracer *tracer) TraceEvent(event Event) { event.DateTime = time.Now().UTC().Format(time.RFC3339) tracer.strategy(event) }