1 Star 0 Fork 0

qq5272689/notify

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
send.go 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
Niko Köser 提交于 2022-04-22 20:45 . style: remove unecessary new-line
package notify
import (
"context"
"github.com/pkg/errors"
"golang.org/x/sync/errgroup"
)
// send calls the underlying notification services to send the given subject and message to their respective endpoints.
func (n *Notify) send(ctx context.Context, subject, message string) error {
if n.Disabled {
return nil
}
if ctx == nil {
ctx = context.Background()
}
var eg errgroup.Group
for _, service := range n.notifiers {
if service == nil {
continue
}
service := service
eg.Go(func() error {
return service.Send(ctx, subject, message)
})
}
err := eg.Wait()
if err != nil {
err = errors.Wrap(ErrSendNotification, err.Error())
}
return err
}
// Send calls the underlying notification services to send the given subject and message to their respective endpoints.
func (n *Notify) Send(ctx context.Context, subject, message string) error {
return n.send(ctx, subject, message)
}
// Send calls the underlying notification services to send the given subject and message to their respective endpoints.
func Send(ctx context.Context, subject, message string) error {
return std.Send(ctx, subject, message)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/golden-go/notify.git
git@gitee.com:golden-go/notify.git
golden-go
notify
notify
master

搜索帮助