2022-05-08 20:49:53 +02:00
|
|
|
package protocols
|
|
|
|
|
2022-05-09 23:19:19 +02:00
|
|
|
import (
|
|
|
|
"beelzebub/parser"
|
|
|
|
"beelzebub/tracer"
|
|
|
|
)
|
2022-05-08 20:49:53 +02:00
|
|
|
|
2022-05-11 22:58:03 +02:00
|
|
|
type ServiceStrategy interface {
|
|
|
|
Init(beelzebubServiceConfiguration parser.BeelzebubServiceConfiguration, tracer tracer.Tracer) error
|
|
|
|
}
|
|
|
|
|
2022-05-08 20:49:53 +02:00
|
|
|
type ProtocolManager struct {
|
|
|
|
strategy ServiceStrategy
|
2022-05-09 23:19:19 +02:00
|
|
|
tracer *tracer.Tracer
|
2022-05-08 20:49:53 +02:00
|
|
|
}
|
|
|
|
|
2022-05-11 22:58:03 +02:00
|
|
|
func InitProtocolManager(tracerStrategy tracer.Strategy, strategy ServiceStrategy) *ProtocolManager {
|
2022-05-09 23:19:19 +02:00
|
|
|
return &ProtocolManager{
|
2022-05-11 22:58:03 +02:00
|
|
|
tracer: tracer.Init(tracerStrategy),
|
|
|
|
strategy: strategy,
|
2022-05-09 23:19:19 +02:00
|
|
|
}
|
2022-05-08 20:49:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (pm *ProtocolManager) SetProtocolStrategy(strategy ServiceStrategy) {
|
|
|
|
pm.strategy = strategy
|
|
|
|
}
|
|
|
|
|
|
|
|
func (pm *ProtocolManager) InitService(beelzebubServiceConfiguration parser.BeelzebubServiceConfiguration) error {
|
2022-05-09 23:19:19 +02:00
|
|
|
return pm.strategy.Init(beelzebubServiceConfiguration, *pm.tracer)
|
2022-05-08 20:49:53 +02:00
|
|
|
}
|