mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-26 21:05:30 +00:00
make an OutputModule interface and remove output from modules that don't implement it
This commit is contained in:
13
router.go
13
router.go
@@ -269,9 +269,20 @@ func (r *Router) HandleOutput(ctx context.Context, destinationId string, payload
|
||||
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 := destinationModule.Output(moduleOutputCtx, payload)
|
||||
err := outputModule.Output(moduleOutputCtx, payload)
|
||||
if err != nil {
|
||||
moduleOutputSpan.SetStatus(codes.Error, err.Error())
|
||||
moduleOutputSpan.RecordError(err)
|
||||
|
||||
Reference in New Issue
Block a user