Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ExtraSenders #1536

Merged
merged 2 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions alert/dispatch/dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ type Dispatch struct {

alerting aconf.Alerting

senders map[string]sender.Sender
tpls map[string]*template.Template
senders map[string]sender.Sender
tpls map[string]*template.Template
ExtraSenders map[string]sender.Sender

ctx *ctx.Context

Expand All @@ -50,8 +51,9 @@ func NewDispatch(alertRuleCache *memsto.AlertRuleCacheType, userCache *memsto.Us

alerting: alerting,

senders: make(map[string]sender.Sender),
tpls: make(map[string]*template.Template),
senders: make(map[string]sender.Sender),
tpls: make(map[string]*template.Template),
ExtraSenders: make(map[string]sender.Sender),

ctx: ctx,
}
Expand Down Expand Up @@ -89,6 +91,12 @@ func (e *Dispatch) relaodTpls() error {
models.Telegram: sender.NewSender(models.Telegram, tmpTpls, smtp),
}

e.RwLock.RLock()
for channel, sender := range e.ExtraSenders {
senders[channel] = sender
}
e.RwLock.RUnlock()

e.RwLock.Lock()
e.tpls = tmpTpls
e.senders = senders
Expand Down
1 change: 0 additions & 1 deletion cli/upgrade/upgrade.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ alter table `board` add built_in tinyint(1) not null default 0 comment '0:false
alter table `board` add hide tinyint(1) not null default 0 comment '0:false 1:true';

alter table `chart_share` add datasource_id bigint unsigned not null default 0;
alter table `chart_share` drop dashboard_id;

alter table `alert_rule` add datasource_ids varchar(255) not null default '';
alter table `alert_rule` add rule_config text not null comment 'rule_config';
Expand Down