flow
Build and Publish / BuildAndDeployAmd64 (push) Failing after 4s
Build and Publish / BuildAndDeployArm64 (push) Failing after 7s

This commit is contained in:
2026-07-19 00:36:01 +02:00
parent 81569b051a
commit 83ed477aa4
3 changed files with 99 additions and 22 deletions
+40 -20
View File
@@ -29,33 +29,53 @@ func RegisterOrderCreatedEmit(reg *flow.Registry, app Applier, pub Publisher, ex
if err != nil {
return err
}
created := buildOrderCreated(o)
if len(created.Lines) == 0 {
exchange, routingKey, body, err := BuildOrderCreatedPayload(o, source)
if err != nil {
return err
}
if body == nil {
return nil // nothing for a reactor to act on
}
payload, err := created.Encode()
if err != nil {
return err
}
ev := event.Event{
ID: "order-created-" + created.OrderID,
Type: event.OrderCreated,
Source: source,
Subject: created.OrderID,
Payload: payload,
Time: time.Now(),
Meta: map[string]string{"country": created.Country},
}
body, err := json.Marshal(ev)
if err != nil {
return err
}
return pub.Publish(exchange, string(event.OrderCreated), body)
return pub.Publish(exchange, routingKey, body)
}, flow.CapabilityMeta{
Description: "Emit the order.created domain event after a paid order is finalized.",
})
}
// BuildOrderCreatedPayload builds the full order.created outbox entry
// (exchange, routingKey, body) for the order grain. Returns ("", "", nil, nil)
// when there are no lines (nothing for a reactor to act on) or on encode failure.
// This is the same logic as the emit_order_created hook, extracted for reuse by
// the applier's atomic emitOnApply callback.
//
// The body is a marshalled event.Event{Type: event.OrderCreated} envelope whose
// payload is the versioned contract.Created wire shape. The routing key is the
// string form of event.OrderCreated ("order.created").
func BuildOrderCreatedPayload(o *OrderGrain, source string) (exchange, routingKey string, body []byte, err error) {
created := buildOrderCreated(o)
if len(created.Lines) == 0 {
return "", "", nil, nil // nothing for a reactor to act on
}
payload, err := created.Encode()
if err != nil {
return "", "", nil, err
}
ev := event.Event{
ID: "order-created-" + created.OrderID,
Type: event.OrderCreated,
Source: source,
Subject: created.OrderID,
Payload: payload,
Time: time.Now(),
Meta: map[string]string{"country": created.Country},
}
body, err = json.Marshal(ev)
if err != nil {
return "", "", nil, err
}
return "order", string(event.OrderCreated), body, nil
}
// buildOrderCreated projects the grain onto the exported order.created contract.
// Lines carry SKU, quantity, the inventory commit location, and the drop-ship
// flag so the inventory reactor can skip the stock decrement for supplier-fulfilled items.