diff --git a/const.go b/const.go index 50ef4c7..2d2e52d 100644 --- a/const.go +++ b/const.go @@ -78,3 +78,5 @@ var ( OutputHookStdout bool OutputHookStderr bool ) + +var RetryBackoff = true diff --git a/supervisor.go b/supervisor.go index 2d11b95..b26f64b 100644 --- a/supervisor.go +++ b/supervisor.go @@ -111,7 +111,10 @@ func StartSupervisor(conf *config.Config) (Supervisor, error) { for cnt := 0; cnt < RetryOnceCount; cnt++ { select { case req := <-s.retryq: - delay := time.Duration(math.Pow(float64(req.Tries), 2)) * 100 * time.Millisecond + var delay time.Duration + if RetryBackoff { + delay = time.Duration(math.Pow(float64(req.Tries), 2)) * 100 * time.Millisecond + } time.AfterFunc(delay, func() { reqs := &[]Request{req} select { diff --git a/supervisor_test.go b/supervisor_test.go index 708d914..205e0b2 100644 --- a/supervisor_test.go +++ b/supervisor_test.go @@ -58,6 +58,7 @@ func (tr TestResponseHandler) HookCmd() string { func init() { logrus.SetLevel(logrus.WarnLevel) conf.Apns.Host = gunfish.MockServer + gunfish.RetryBackoff = false // for testing } func TestEnqueuRequestToSupervisor(t *testing.T) {