mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-09-11 16:09:26 +00:00
remove unused router level output
This commit is contained in:
@@ -15,7 +15,6 @@ import (
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
@@ -254,55 +253,6 @@ func (r *Router) HandleInput(ctx context.Context, sourceId string, payload any)
|
||||
return routeFound.Load(), routeIOErrors
|
||||
}
|
||||
|
||||
func (r *Router) HandleOutput(ctx context.Context, destinationId string, payload any) error {
|
||||
spanCtx, span := otel.Tracer("router").Start(ctx, "output", trace.WithAttributes(attribute.String("destination.id", destinationId)))
|
||||
defer span.End()
|
||||
outputEvent := common.Event{
|
||||
Type: "output",
|
||||
Data: map[string]any{
|
||||
"destination": destinationId,
|
||||
},
|
||||
}
|
||||
destinationModule := r.getModule(destinationId)
|
||||
|
||||
if destinationModule == nil {
|
||||
err := errors.New("no module found for destination id")
|
||||
span.SetStatus(codes.Error, err.Error())
|
||||
span.RecordError(err)
|
||||
r.logger.Error("no module found for destination id", "destinationId", destinationId)
|
||||
outputEvent.Error = err.Error()
|
||||
r.broadcastEvent(outputEvent)
|
||||
return err
|
||||
}
|
||||
|
||||
outputModule, ok := destinationModule.(common.OutputModule)
|
||||
if !ok {
|
||||
err := errors.New("module does not support output")
|
||||
span.SetStatus(codes.Error, err.Error())
|
||||
span.RecordError(err)
|
||||
r.logger.Error("module does not support output", "destinationId", destinationId)
|
||||
outputEvent.Error = err.Error()
|
||||
r.broadcastEvent(outputEvent)
|
||||
return err
|
||||
}
|
||||
|
||||
moduleOutputCtx, moduleOutputSpan := otel.Tracer("module").Start(spanCtx, "output", trace.WithAttributes(attribute.String("module.id", destinationModule.Id()), attribute.String("module.type", destinationModule.Type())))
|
||||
defer moduleOutputSpan.End()
|
||||
err := outputModule.Output(moduleOutputCtx, payload)
|
||||
if err != nil {
|
||||
moduleOutputSpan.SetStatus(codes.Error, err.Error())
|
||||
moduleOutputSpan.RecordError(err)
|
||||
r.logger.ErrorContext(moduleOutputCtx, "module output encountered error", "module", destinationModule.Id(), "error", err)
|
||||
outputEvent.Error = err.Error()
|
||||
r.broadcastEvent(outputEvent)
|
||||
return err
|
||||
} else {
|
||||
moduleOutputSpan.SetStatus(codes.Ok, "module output successful")
|
||||
}
|
||||
r.broadcastEvent(outputEvent)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Router) startModules() {
|
||||
for moduleId := range r.ModuleInstances {
|
||||
// TODO(jwetzell): handle module run errors
|
||||
|
||||
Reference in New Issue
Block a user