Skip to content
Snippets Groups Projects
app.go 1.76 KiB
Newer Older
  • Learn to ignore specific revisions
  • André Sterba's avatar
    André Sterba committed
    package application
    
    import (
    
    	"code.fbi.h-da.de/danet/costaquanta/ctrl/internal/core/ports"
    
    André Sterba's avatar
    André Sterba committed
    	"code.fbi.h-da.de/danet/costaquanta/ctrl/internal/infrastructure/interaction"
    
    	"code.fbi.h-da.de/danet/costaquanta/ctrl/internal/infrastructure/store"
    
    	"code.fbi.h-da.de/danet/costaquanta/ctrl/internal/service"
    
    André Sterba's avatar
    André Sterba committed
    	"code.fbi.h-da.de/danet/costaquanta/libs/logging"
    	sdktrace "go.opentelemetry.io/otel/sdk/trace"
    	"go.uber.org/zap"
    )
    
    type Application struct {
    
    	tracer *sdktrace.TracerProvider
    
    	HealthServer *interaction.HealthServer
    
    	RoutingService ports.RoutingService
    	RoutingServer  *interaction.RoutingServer
    	KmsStore       ports.KmsStore
    
    André Sterba's avatar
    André Sterba committed
    }
    
    func NewApplication(log *zap.Logger, tracer *sdktrace.TracerProvider) *Application {
    	healthLogger := logging.CreateChildLogger(log, "healthServer")
    	healthTracer := tracer.Tracer("healthServer")
    	healthSrv := interaction.NewHealthServer(healthLogger, healthTracer)
    
    
    	routingServiceLogger := logging.CreateChildLogger(log, "routingService")
    	routingServiceTracer := tracer.Tracer("routingService")
    	rSrv := service.NewRoutingService(routingServiceLogger, routingServiceTracer)
    
    
    André Sterba's avatar
    André Sterba committed
    	routingLogger := logging.CreateChildLogger(log, "routingServer")
    	routingTracer := tracer.Tracer("routingServer")
    
    	routerSrv := interaction.NewRoutingServer(routingLogger, routingTracer, rSrv)
    
    André Sterba's avatar
    André Sterba committed
    
    
    	// Create the in-memory KMS store, as we currently have no other option.
    	// Can be replaced by a store choice via flags or config file later.
    	kmsStoreLogger := logging.CreateChildLogger(log, "KmsStore")
    	kmsStoreTracer := tracer.Tracer("KmsStore")
    	kmsStore := store.NewInMemoryKmsStore(kmsStoreLogger, kmsStoreTracer)
    
    
    André Sterba's avatar
    André Sterba committed
    	return &Application{
    
    		tracer:         tracer,
    		HealthServer:   healthSrv,
    		RoutingServer:  routerSrv,
    		RoutingService: rSrv,
    		KmsStore:       kmsStore,
    
    André Sterba's avatar
    André Sterba committed
    	}
    }