Replace Submitter + ErrorHandler with Dispatcher#20
Conversation
- Extract codec/ package: Codec interface, ContentType enum, all codec implementations, marshal/unmarshal helpers - Extract transport/ package: Conn interface wrapping *nats.Conn, all subscribe option types, connection adapter implementation - Fix queue subscription bug: inverted conditions in Subscribe() and SubscribeHandler() where queue="" called queue methods - Remove Publisher, Requester, Subscriber, Connection, Drainer, Closer interfaces from root package - Rename symbols: CodecContentType → codec.ForContentType, WrapConnection → transport.Wrap, ContentTypeJson → codec.JSON, etc. - Update all tests, examples, mocks, and documentation
Self-ReviewThree independent review passes (code review, silent-failure hunting, type design analysis) converged on the same core issues. CRITICAL: No call site ever calls
|
| Severity | Count | Key Issues |
|---|---|---|
| CRITICAL | 3 | No call site drains errors; Wait discards errors on ctx cancel; Pond WaitGroup leak |
| HIGH | 2 | Goroutine leak in Wait; Shared singleton memory leak |
| MEDIUM | 3 | Post-Wait dispatch; nil guard; Missing pond tests |
The core design (Dispatch + Wait replacing Submitter + ErrorHandler) is sound. The issues are all in lifecycle management and error surfacing — the framework dispatches errors into a collector that nothing ever reads.
Summary
Submitter+ErrorHandlerinterfaces with a singleDispatcherinterface (Dispatch(func() error)+Wait(context.Context) error)sync.WaitGrouptracking, mutex-guarded error collection viaerrors.JoinWait()contrib/pondupdated with pool-backedDispatcher/DispatcherPoolTest plan
go build ./...passesgo test ./...passes (all existing tests green)dispatcher_test.gocovers: no errors, multiple error collection, empty wait, context timeout