You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wire up the first stage of the queue pipeline: Gateway publishes land requests
to the queue, Orchestrator consumes and processes them.
**Consumer Infrastructure:**
- Add Consumer interface (Register/Start/Stop) for orchestrating multiple controllers
- Add consumer.Delivery interface to enforce separation of concerns (type-safe)
- Controllers receive consumer.Delivery (no Ack/Nack), Consumer handles ack/nack
- Implement subscription lifecycle, automatic ack/nack, metrics, graceful shutdown
**Gateway:**
- Land controller publishes requests to land_request queue after storage
- Queue infrastructure optional (controlled by QUEUE_MYSQL_DSN env var)
**Orchestrator:**
- Request controller consumes from land_request queue
- Wire up consumer with graceful shutdown in main.go
**CLAUDE.md:**
- Document RPC vs Queue Message controller patterns
- Add code style guidelines: use SugaredLogger, use interfaces for contracts
All unit and integration tests pass. Backward compatible with existing tests.
├── protopb/ # Generated proto code (committed to repo)
52
57
└── integration_test/
53
58
```
54
59
55
60
### Controllers
56
61
57
-
Controllers contain pure business logic, independent of the transport layer (gRPC/YARPC). They live in `{service}/controller/` and are wired up in `example/server/{service}/main.go`.
62
+
Controllers contain pure business logic, independent of infrastructure. There are two types:
63
+
64
+
**RPC Controllers** - Handle synchronous API requests in `{service}/controller/`. Accept protobuf types, independent of gRPC/YARPC transport.
// Return nil to ack, error to nack. Consumer handles ack/nack automatically.
76
+
}
77
+
```
78
+
79
+
Controllers receive `consumer.Delivery` (subset interface without Ack/Nack methods) to enforce separation: controllers do business logic, consumer framework handles infrastructure.
58
80
59
81
### Entities
60
82
@@ -70,7 +92,10 @@ entity/
70
92
**Entity guidelines:**
71
93
1. Keep entities pure and framework-agnostic — no external dependencies
72
94
2. Use value types, not references
73
-
3. Prefer `int64` Unix epoch milliseconds over `time.Time`
95
+
3. Prefer `int64` milliseconds over `time.Time` and `time.Duration`:
@@ -204,3 +240,20 @@ make clean-proto # Remove generated proto files
204
240
1.**Avoid asserting on error messages** — assert on error type if it is part of the contract, or assert generic error otherwise.
205
241
2.**Avoid blocking operations for synchronization** — do not use `time.Sleep`. Design the tested routine to signal back (channels, callbacks, condition variables).
206
242
3.**Use testify assertions** — use `stretchr/assert` or `require` instead of `t.Fatal()`.
243
+
244
+
### Code Style Guidelines
245
+
246
+
1.**Use SugaredLogger for structured logging** — always use `zap.SugaredLogger` with structured logging methods:
247
+
-`logger.Debugw(msg, key1, val1, key2, val2, ...)` for debug logs
248
+
-`logger.Infow(msg, key1, val1, key2, val2, ...)` for info logs
249
+
-`logger.Errorw(msg, key1, val1, key2, val2, ...)` for error logs
250
+
- Never use unstructured methods like `Debug()`, `Info()`, `Error()`, or `Printf()`
0 commit comments