Refactor NATS consumer management by introducing a dedicated ConsumerManager and StreamManager for lifecycle management. Enhance error handling with a new ErrorHandler to streamline message processing and recovery logic. Update consumer initialization to utilize the new managers, improving code organization and maintainability. Add comprehensive tests for the new components to ensure reliability and robustness in handling NATS operations.

This commit is contained in:
windyboy
2025-11-18 08:38:03 +08:00
parent 61647cf849
commit 5d05237283
12 changed files with 793 additions and 232 deletions
@@ -76,7 +76,7 @@ func TestJetStreamToTimescaleFlow(t *testing.T) {
t.Fatalf("failed to init jetstream: %v", err)
}
publisher, err := natsinfra.ProvidePublisher(js, cfg, logger)
publisher, err := natsinfra.ProvidePublisher(js, conn, cfg, logger)
if err != nil {
t.Fatalf("failed to init publisher: %v", err)
}