bbgo: load slack notifier queue size from config

This commit is contained in:
c9s 2024-11-11 17:16:42 +08:00
parent 2eca15bb61
commit a9c51e824d
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 7 additions and 1 deletions

View File

@ -65,6 +65,7 @@ func (m *ExchangeStrategyMount) Map() (map[string]interface{}, error) {
type SlackNotification struct {
DefaultChannel string `json:"defaultChannel,omitempty" yaml:"defaultChannel,omitempty"`
ErrorChannel string `json:"errorChannel,omitempty" yaml:"errorChannel,omitempty"`
QueueSize int `json:"queueSize,omitempty" yaml:"queueSize,omitempty"`
}
type SlackNotificationRouting struct {

View File

@ -862,7 +862,12 @@ func (environ *Environment) setupSlack(userConfig *Config, slackToken string, pe
var client = slack.New(slackToken, slackOpts...)
var notifier = slacknotifier.New(client, conf.DefaultChannel)
var notifierOpts []slacknotifier.NotifyOption
if conf.QueueSize > 0 {
notifierOpts = append(notifierOpts, slacknotifier.OptionQueueSize(conf.QueueSize))
}
var notifier = slacknotifier.New(client, conf.DefaultChannel, notifierOpts...)
Notification.AddNotifier(notifier)
// allocate a store, so that we can save the chatID for the owner