rework route to just process payload

This commit is contained in:
Joel Wetzell
2025-12-28 08:24:12 -06:00
parent fcb1378784
commit ed4c14e82b
3 changed files with 32 additions and 19 deletions

View File

@@ -133,7 +133,9 @@ func (r *Router) HandleInput(sourceId string, payload any) []route.RouteIOError
var routingErrors []route.RouteIOError
for routeIndex, routeInstance := range r.RouteInstances {
if routeInstance.Input() == sourceId {
err := routeInstance.HandleInput(context.WithValue(r.Context, route.SourceContextKey, sourceId), payload)
routeContext := context.WithValue(r.Context, route.SourceContextKey, sourceId)
payload, err := routeInstance.ProcessPayload(routeContext, payload)
if err != nil {
if routingErrors == nil {
routingErrors = []route.RouteIOError{}
@@ -144,6 +146,7 @@ func (r *Router) HandleInput(sourceId string, payload any) []route.RouteIOError
})
r.logger.Error("unable to route input", "route", routeIndex, "source", sourceId, "error", err)
}
r.HandleOutput(routeContext, routeInstance.Output(), payload)
}
}
return routingErrors