refactor: Update NATS subscription logic and configuration
The code changes in `main.go` update the NATS subscription logic and configuration. The `Subscribe` function now uses the `NatsHandler` struct to handle the subscription. The `NewNatsHandler` function is added to create a new instance of the `NatsHandler` with the provided configuration. The configuration values are passed to the `NatsSubscriber` constructor to set up the NATS subscription. This refactor improves the modularity and readability of the NATS subscription code.
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
@@ -29,10 +30,10 @@ type SubscriptionConfig struct {
|
||||
}
|
||||
|
||||
type TimeoutsConfig struct {
|
||||
ServerTimeout string `mapstructure:"server_timeout"`
|
||||
ReconnectWait string `mapstructure:"reconnect_wait"`
|
||||
CloseTimeout string `mapstructure:"close_timeout"`
|
||||
AckWaitTimeout string `mapstructure:"ack_wait_timeout"`
|
||||
ServerTimeout time.Duration `mapstructure:"server_timeout"`
|
||||
ReconnectWait time.Duration `mapstructure:"reconnect_wait"`
|
||||
CloseTimeout time.Duration `mapstructure:"close_timeout"`
|
||||
AckWaitTimeout time.Duration `mapstructure:"ack_wait_timeout"`
|
||||
}
|
||||
|
||||
type BodyConfig struct {
|
||||
|
||||
Reference in New Issue
Block a user