Compare commits
7
Commits
995b5f4681
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5237c8ab85 | ||
|
|
f3e3269b7a | ||
|
|
a31ce71b08 | ||
|
|
eb2c02f0a9 | ||
|
|
ec072621bf | ||
|
|
47dfee4c77 | ||
|
|
c6687a5531 |
@@ -0,0 +1,2 @@
|
||||
.DS_Store
|
||||
data/*.dbz
|
||||
@@ -0,0 +1,57 @@
|
||||
# go-order-manager — agents map
|
||||
|
||||
Thin, small service: persists the side of order events that the cart-actor
|
||||
publishes. Reads from RabbitMQ; writes orders to disk. Almost all of the
|
||||
business logic lives in `go-cart-actor`; this is the durable, simple shadow.
|
||||
|
||||
## Where to start
|
||||
|
||||
- `main.go` — wiring (HTTP server + RabbitMQ client + persistence).
|
||||
- `order.go` — the `Order` struct + related types.
|
||||
- `order_client.go` — `RabbitTransportClient` (the AMQP consumer) +
|
||||
`UpdateHandler` interface.
|
||||
- `capture.go` — payment/fulfilment capture payload.
|
||||
- `README.md` — intent.
|
||||
- `deployment/order-manager.yaml` — k8s deployment (uses `AMQP_URL`).
|
||||
|
||||
## Architecture
|
||||
|
||||
- **Single binary, single role**: consumer of the order event stream
|
||||
(`order-queue` on a RabbitMQ exchange).
|
||||
- **Durable record**: persists orders received via the queue; the HTTP
|
||||
surface is mostly read/admin.
|
||||
- **No opinions on cart logic** — that's `go-cart-actor`'s domain. This
|
||||
service is the keeper of the resulting artefacts.
|
||||
|
||||
## Important files by area
|
||||
|
||||
| Area | File |
|
||||
| ------------------- | ------------------------------------------ |
|
||||
| Wiring | `main.go` |
|
||||
| Domain model | `order.go` |
|
||||
| Capture payload | `capture.go` |
|
||||
| AMQP consumer | `order_client.go` |
|
||||
| Deploy | `deployment/order-manager.yaml` |
|
||||
|
||||
## Cross-project seams
|
||||
|
||||
- **`go-cart-actor`**: emits order events; this service consumes them. Per
|
||||
`docs/checkout-order-handoff.md`, the ownership split is "cart-actor
|
||||
orchestrates active checkout, order-manager owns the persisted record."
|
||||
- **RabbitMQ**: exchanges per `docs/platform-event-messaging-sketch.md`.
|
||||
|
||||
## Improvement suggestions
|
||||
|
||||
- **Too small to deserve its own service?** Five files, one queue consumer,
|
||||
one model. Ask the deletion test: deleting this service would re-spread
|
||||
"what's an order?" across two repos. Currently earns its keep. Keep it,
|
||||
but periodically re-evaluate: if persistence moves into an outbox inside
|
||||
cart-actor, this service dilutes into a read API and may collapse.
|
||||
- **`capture.go` is its own file but isn't clearly used** —if it's only
|
||||
consumed by tests or an old webhook path, fold it into `order.go`.
|
||||
- **No tests.** The `OrderPlaced` and `UpdateHandler` interfaces are the
|
||||
test surface; a 50-line test with a fake `UpdateHandler` would lock in
|
||||
the contract that `go-cart-actor` depends on.
|
||||
- **Single `deployment/order-manager.yaml`** has no corollaries — if you're
|
||||
adding a second env (staging), copy it explicitly into a `deploy/k8s/`
|
||||
folder rather than hand-editing replicas later.
|
||||
+11
@@ -1,3 +1,14 @@
|
||||
// File capture.go holds CaptureData — the wire payload used when an order
|
||||
// claims a payment authorisation or records fulfilment capture.
|
||||
//
|
||||
// Consumers:
|
||||
// - PersistingOrderHandler in main.go on the OrderPlaced path.
|
||||
// - A small backoffice admin route kicks capture.
|
||||
//
|
||||
// It is NOT a public HTTP surface; its JSON field names mirror the UCP
|
||||
// capture.v1 schema that go-cart-actor publishes on the se_* RabbitMQ
|
||||
// exchange. If you change a field here, you almost certainly have to
|
||||
// change go-cart-actor's emit site at the same time.
|
||||
package main
|
||||
|
||||
type CaptureData struct {
|
||||
|
||||
@@ -47,7 +47,7 @@ spec:
|
||||
imagePullSecrets:
|
||||
- name: regcred
|
||||
containers:
|
||||
- image: registry.knatofs.se/go-order-manager:latest
|
||||
- image: registry.k6n.net/go-order-manager:latest
|
||||
name: order-manager-arm64
|
||||
imagePullPolicy: Always
|
||||
lifecycle:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module git.tornberg.me/go-order-manager
|
||||
module git.k6n.net/mats/go-order-manager
|
||||
|
||||
go 1.24.0
|
||||
go 1.26.2
|
||||
|
||||
require github.com/rabbitmq/amqp091-go v1.10.0
|
||||
|
||||
@@ -137,7 +137,14 @@ func main() {
|
||||
}
|
||||
defer client.Close()
|
||||
|
||||
// Routes are served at their CANONICAL public paths under /api/orders, so
|
||||
// ingress routes straight to this service with no rewrite/strip — you can
|
||||
// curl the pod or the ingress and the path is identical (deploy/API-ROUTING.md).
|
||||
// /healthz stays pod-local for probes (never exposed at the edge).
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
})
|
||||
mux.HandleFunc("GET /api/orders", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
Reference in New Issue
Block a user