Add automatic connection retries
This commit is contained in:
@ -33,7 +33,9 @@ type BridgeConfig struct {
|
||||
UsernameTemplate string `yaml:"username_template"`
|
||||
DisplaynameTemplate string `yaml:"displayname_template"`
|
||||
|
||||
ConnectionTimeout int `yaml:"connection_timeout"`
|
||||
ConnectionTimeout int `yaml:"connection_timeout"`
|
||||
MaxConnectionAttempts int `yaml:"max_connection_attempts"`
|
||||
ReportConnectionRetry bool `yaml:"report_connection_retry"`
|
||||
|
||||
CommandPrefix string `yaml:"command_prefix"`
|
||||
|
||||
@ -43,6 +45,12 @@ type BridgeConfig struct {
|
||||
displaynameTemplate *template.Template `yaml:"-"`
|
||||
}
|
||||
|
||||
func (bc *BridgeConfig) setDefaults() {
|
||||
bc.ConnectionTimeout = 20
|
||||
bc.MaxConnectionAttempts = 3
|
||||
bc.ReportConnectionRetry = true
|
||||
}
|
||||
|
||||
type umBridgeConfig BridgeConfig
|
||||
|
||||
func (bc *BridgeConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
@ -61,7 +69,7 @@ func (bc *BridgeConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
}
|
||||
|
||||
type UsernameTemplateArgs struct {
|
||||
UserID string
|
||||
UserID string
|
||||
}
|
||||
|
||||
func (bc BridgeConfig) FormatDisplayname(contact whatsapp.Contact) (string, int8) {
|
||||
|
@ -64,6 +64,7 @@ type Config struct {
|
||||
func (config *Config) setDefaults() {
|
||||
config.AppService.Database.MaxOpenConns = 20
|
||||
config.AppService.Database.MaxIdleConns = 2
|
||||
config.Bridge.setDefaults()
|
||||
}
|
||||
|
||||
func Load(path string) (*Config, error) {
|
||||
|
Reference in New Issue
Block a user