Skip to content
Snippets Groups Projects
Commit 568b9f38 authored by André Sterba's avatar André Sterba Committed by Neil-Jocelyn Schark
Browse files

Bootstrap ctrl

parent a206ff24
No related branches found
No related tags found
1 merge request!3Bootstrap ctrl
Pipeline #268936 passed
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
"runtime/debug" "runtime/debug"
config "code.fbi.h-da.de/danet/costaquanta/ctrl/internal" config "code.fbi.h-da.de/danet/costaquanta/ctrl/internal"
"code.fbi.h-da.de/danet/costaquanta/ctrl/internal/core/application" "code.fbi.h-da.de/danet/costaquanta/ctrl/internal/application"
pb "code.fbi.h-da.de/danet/costaquanta/gen/go/ctrl/v1" pb "code.fbi.h-da.de/danet/costaquanta/gen/go/ctrl/v1"
"code.fbi.h-da.de/danet/costaquanta/libs/logging" "code.fbi.h-da.de/danet/costaquanta/libs/logging"
"code.fbi.h-da.de/danet/costaquanta/libs/tracing" "code.fbi.h-da.de/danet/costaquanta/libs/tracing"
...@@ -100,5 +100,10 @@ func main() { ...@@ -100,5 +100,10 @@ func main() {
app := application.NewApplication(log, traceProvider) app := application.NewApplication(log, traceProvider)
pb.RegisterHealthCtrlServer(grpcServer, app.HealthServer) pb.RegisterHealthCtrlServer(grpcServer, app.HealthServer)
_ = grpcServer.Serve(listen) pb.RegisterCtrlRoutingServiceServer(grpcServer, app.RoutingServer)
err = grpcServer.Serve(listen)
if err != nil {
panic(err)
}
} }
...@@ -8,17 +8,23 @@ import ( ...@@ -8,17 +8,23 @@ import (
) )
type Application struct { type Application struct {
tracer *sdktrace.TracerProvider tracer *sdktrace.TracerProvider
HealthServer *interaction.HealthServer HealthServer *interaction.HealthServer
RoutingServer *interaction.RoutingServer
} }
func NewApplication(log *zap.Logger, tracer *sdktrace.TracerProvider) *Application { func NewApplication(log *zap.Logger, tracer *sdktrace.TracerProvider) *Application {
healthServerLogger := logging.CreateChildLogger(log, "healthServer") healthLogger := logging.CreateChildLogger(log, "healthServer")
childTracer := tracer.Tracer("healthServer") healthTracer := tracer.Tracer("healthServer")
healthSrv := interaction.NewHealthServer(healthServerLogger, childTracer) healthSrv := interaction.NewHealthServer(healthLogger, healthTracer)
routingLogger := logging.CreateChildLogger(log, "routingServer")
routingTracer := tracer.Tracer("routingServer")
routerSrv := interaction.NewRoutingServer(routingLogger, routingTracer)
return &Application{ return &Application{
HealthServer: healthSrv, tracer: tracer,
tracer: tracer, HealthServer: healthSrv,
RoutingServer: routerSrv,
} }
} }
...@@ -15,6 +15,15 @@ type HealthServer struct { ...@@ -15,6 +15,15 @@ type HealthServer struct {
tracer trace.Tracer tracer trace.Tracer
} }
func NewHealthServer(logger *zap.SugaredLogger, tracer trace.Tracer) *HealthServer {
s := &HealthServer{
logger: logger,
tracer: tracer,
}
return s
}
func (h *HealthServer) Health( func (h *HealthServer) Health(
ctx context.Context, ctx context.Context,
request *pb.HealthRequest, request *pb.HealthRequest,
...@@ -28,12 +37,3 @@ func (h *HealthServer) Health( ...@@ -28,12 +37,3 @@ func (h *HealthServer) Health(
Message: request.Message, Message: request.Message,
}, nil }, nil
} }
func NewHealthServer(logger *zap.SugaredLogger, tracer trace.Tracer) *HealthServer {
s := &HealthServer{
logger: logger,
tracer: tracer,
}
return s
}
package interaction
import (
pb "code.fbi.h-da.de/danet/costaquanta/gen/go/ctrl/v1"
"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"
)
type RoutingServer struct {
pb.UnimplementedCtrlRoutingServiceServer
logger *zap.SugaredLogger
tracer trace.Tracer
}
func NewRoutingServer(logger *zap.SugaredLogger, tracer trace.Tracer) *RoutingServer {
s := &RoutingServer{
logger: logger,
tracer: tracer,
}
return s
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment