1
0
mirror of https://github.com/nikoksr/notify.git synced 2025-04-11 11:41:58 +02:00

chore(code): clean up a little

This commit is contained in:
Niko Köser 2022-04-22 20:33:24 +02:00
parent 20ec590e87
commit c6054bc20a
No known key found for this signature in database
GPG Key ID: F3F28C118DAA6375
2 changed files with 13 additions and 8 deletions

19
send.go
View File

@ -12,16 +12,21 @@ 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 {
s := service
eg.Go(func() error {
return s.Send(ctx, subject, message)
})
if service == nil {
continue
}
service := service
eg.Go(func() error {
return service.Send(ctx, subject, message)
})
}
err := eg.Wait()
@ -39,5 +44,5 @@ func (n *Notify) Send(ctx context.Context, subject, message string) error {
// 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)
return std.Send(ctx, subject, message)
}

2
use.go
View File

@ -21,5 +21,5 @@ func (n *Notify) UseServices(service ...Notifier) {
// UseServices adds the given service(s) to the Notifier's services list.
func UseServices(service ...Notifier) {
std.useServices(service...)
std.UseServices(service...)
}