refactor
This commit is contained in:
+4
-1
@@ -26,7 +26,7 @@ type Publisher interface {
|
||||
// still registered (so the editor lists it) but errors at run time — and since
|
||||
// hook errors never abort a flow, that failure is logged, not fatal.
|
||||
func RegisterEmitHook(reg *flow.Registry, pub Publisher) {
|
||||
reg.Hook("amqp_emit", func(_ context.Context, st *flow.State, info flow.HookInfo, params json.RawMessage) error {
|
||||
reg.HookWithMeta("amqp_emit", func(_ context.Context, st *flow.State, info flow.HookInfo, params json.RawMessage) error {
|
||||
if pub == nil {
|
||||
return fmt.Errorf("amqp_emit: no publisher configured")
|
||||
}
|
||||
@@ -54,5 +54,8 @@ func RegisterEmitHook(reg *flow.Registry, pub Publisher) {
|
||||
"vars": st.Vars,
|
||||
})
|
||||
return pub.Publish(p.Exchange, p.RoutingKey, body)
|
||||
}, flow.CapabilityMeta{
|
||||
Description: "Publish the flow event payload to RabbitMQ.",
|
||||
ExampleParams: json.RawMessage(`{"exchange":"order","routingKey":"order-events"}`),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user