From 30225e0fd0f32430d0231ad4ae2c0da3557ce69f Mon Sep 17 00:00:00 2001 From: Umputun Date: Mon, 12 Nov 2018 02:08:37 -0600 Subject: [PATCH] repeater in tg send --- backend/app/notify/notify.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/app/notify/notify.go b/backend/app/notify/notify.go index 5bfff2a8..14b2c6b1 100644 --- a/backend/app/notify/notify.go +++ b/backend/app/notify/notify.go @@ -7,6 +7,9 @@ import ( "log" "sync" + "github.com/go-pkgz/repeater" + "github.com/go-pkgz/repeater/strategy" + "github.com/umputun/remark/backend/app/store" "github.com/umputun/remark/backend/app/store/service" ) @@ -86,12 +89,16 @@ func (s *Service) Close() { } func (s *Service) do() { + rpt := repeater.New(strategy.NewBackoff(5, 1.5, true)) for c := range s.queue { var wg sync.WaitGroup for _, dest := range s.destinations { wg.Add(1) go func(d Destination) { - if err := d.Send(s.ctx, c); err != nil { + err := rpt.Do(func() error { + return d.Send(s.ctx, c) + }) + if err != nil { log.Printf("[WARN] failed to send to %s, %s", d, err) } wg.Done()