Refactor application initialization to load configuration and enhance message processing. Introduce effective subscription topic handling and improve error management in NATS consumer. Update tests for publisher error handling and add new dependency injection method for app initialization.

This commit is contained in:
windyboy
2025-11-14 22:43:04 +08:00
parent 9cce4610b6
commit 02e54a2670
8 changed files with 196 additions and 35 deletions
+13
View File
@@ -244,3 +244,16 @@ func (c *Config) Validate() error {
func ProvideConfig() (*Config, error) {
return LoadConfig()
}
// EffectiveSubscriptionTopic returns the active subscription subject.
// Retains support for legacy config.Subscription fields while allowing
// future consolidation.
func (c *Config) EffectiveSubscriptionTopic() string {
if c == nil {
return ""
}
if topic := c.Subscription.Topic; topic != "" {
return topic
}
return "telegram.>"
}