feat: check unused package (#232)

* feat: check unused package

update edganiukov/fcm to appleboy/go-fcm

* update readme

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update comment

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu
2017-06-01 02:52:01 -05:00
committed by GitHub
parent 77bce18c9f
commit 14dc899b02
42 changed files with 47 additions and 2661 deletions

34
vendor/github.com/appleboy/go-fcm/retry.go generated vendored Normal file
View File

@@ -0,0 +1,34 @@
package fcm
import (
"net"
"time"
)
const (
minBackoff = 100 * time.Millisecond
maxBackoff = 1 * time.Minute
factor = 2.7
)
func retry(fn func() error, attempts int) error {
var attempt int
for {
err := fn()
if err == nil {
return nil
}
if tErr, ok := err.(net.Error); !ok || !tErr.Temporary() {
return err
}
attempt++
backoff := minBackoff * time.Duration(attempt*attempt)
if attempt > attempts || backoff > maxBackoff {
return err
}
time.Sleep(backoff)
}
}