refactor
Build and Publish / BuildAndDeployArm64 (push) Failing after 6s
Build and Publish / BuildAndDeployAmd64 (push) Failing after 4s

This commit is contained in:
2026-06-29 12:34:58 +02:00
parent d711348863
commit 46be260fcc
35 changed files with 1765 additions and 198 deletions
+6 -4
View File
@@ -21,7 +21,7 @@ import (
// retries delivery on its own. With a nil publisher (dev without AMQP) it is a
// no-op. Attach it to the "after" hooks of the final paid step, e.g. capture.
func RegisterOrderCreatedEmit(reg *flow.Registry, app Applier, pub Publisher, exchange, source string) {
reg.Hook("emit_order_created", func(ctx context.Context, st *flow.State, _ flow.HookInfo, _ json.RawMessage) error {
reg.HookWithMeta("emit_order_created", func(ctx context.Context, st *flow.State, _ flow.HookInfo, _ json.RawMessage) error {
if pub == nil {
return nil // no broker configured (dev)
}
@@ -51,19 +51,21 @@ func RegisterOrderCreatedEmit(reg *flow.Registry, app Applier, pub Publisher, ex
return err
}
return pub.Publish(exchange, string(event.OrderCreated), body)
}, flow.CapabilityMeta{
Description: "Emit the order.created domain event after a paid order is finalized.",
})
}
// buildOrderCreated projects the grain onto the exported order.created contract.
// Lines carry only SKU + quantity (what reactors need); inventory commits at the
// order's Country location.
// 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.
func buildOrderCreated(o *OrderGrain) contract.Created {
lines := make([]contract.Line, 0, len(o.Lines))
for _, l := range o.Lines {
if l.Sku == "" || l.Quantity <= 0 {
continue
}
lines = append(lines, contract.Line{SKU: l.Sku, Quantity: l.Quantity, Location: l.Location})
lines = append(lines, contract.Line{SKU: l.Sku, Quantity: l.Quantity, Location: l.Location, DropShip: l.DropShip})
}
return contract.Created{
OrderID: OrderId(o.Id).String(),