Enhance NATS configuration and error handling. Introduce stream limits and consumer rules in configuration files. Refactor message processing to handle permanent errors. Update README and development configuration to reflect changes. Add tests for new error handling mechanisms.

This commit is contained in:
windyboy
2025-11-14 21:42:04 +08:00
parent a574cfcf27
commit 9cce4610b6
13 changed files with 510 additions and 57 deletions
+7 -7
View File
@@ -19,27 +19,27 @@ func InitializeApp() (*app.MessageProcessor, *nats.Consumer, error) {
wire.Build(
// Config
config.ProvideConfig,
// Logger
log.ProvideLogger,
// Database
postgres.ProvideDB,
postgres.ProvideRepository,
// NATS
nats.ProvideNATSConn,
nats.ProvideJetStream,
nats.ProvidePublisher,
// Parser
parser.ProvideParser,
// App
app.NewMessageProcessor,
// Consumer
nats.ProvideConsumer,
)
return nil, nil, nil
}
+6 -2
View File
@@ -32,7 +32,11 @@ func InitializeApp() (*app.MessageProcessor, *nats.Consumer, error) {
if err != nil {
return nil, nil, err
}
natsJetStreamContext, err := nats.ProvideJetStream(configConfig, zapLogger)
natsConn, err := nats.ProvideNATSConn(configConfig, zapLogger)
if err != nil {
return nil, nil, err
}
natsJetStreamContext, err := nats.ProvideJetStream(natsConn, configConfig, zapLogger)
if err != nil {
return nil, nil, err
}
@@ -42,7 +46,7 @@ func InitializeApp() (*app.MessageProcessor, *nats.Consumer, error) {
}
parserParser := parser.ProvideParser()
appMessageProcessor := app.NewMessageProcessor(parserParser, adapterRepository, adapterPublisher, zapLogger)
natsConsumer, err := nats.ProvideConsumer(natsJetStreamContext, appMessageProcessor, configConfig, zapLogger)
natsConsumer, err := nats.ProvideConsumer(natsConn, natsJetStreamContext, appMessageProcessor, configConfig, zapLogger)
if err != nil {
return nil, nil, err
}