coreos / issue-sync

A tool for synchronizing issue tracking between GitHub and JIRA
Apache License 2.0
124 stars 34 forks source link

api clients: Print request errors on backoff #25

Closed MorganEPatch closed 6 years ago

MorganEPatch commented 7 years ago

If an API request error occurs, print out the error and the next backoff time.

@squat

squat commented 7 years ago

Ok, then please use this function instead: https://golang.org/pkg/time/#Time.Truncate

On Mon, Aug 21, 2017 at 4:26 PM, Morgan Patch notifications@github.com wrote:

@LyonesGamer commented on this pull request.

In lib/clients/github.go https://github.com/coreos/issue-sync/pull/25#discussion_r134353993:

@@ -167,7 +171,12 @@ func (g realGHClient) request(f func() (interface{}, *github.Response, error)) ( b := backoff.NewExponentialBackOff() b.MaxElapsedTime = g.config.GetTimeout()

  • er := backoff.Retry(op, b)
  • er := backoff.RetryNotify(op, b, func(err error, duration time.Duration) {
  • duration /= 1000000 // Convert nanoseconds to milliseconds
  • duration *= 1000000 // Convert back so it appears correct

Right, but the numbers are randomized. I was instead getting things like 1s374.926427ms, so I wanted to truncate it to millisecond-level precision to make it more readable.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/coreos/issue-sync/pull/25#discussion_r134353993, or mute the thread https://github.com/notifications/unsubscribe-auth/ATiQPyCte0qGt2LDR953kxgIG_OCJQjtks5sahJBgaJpZM4O96X- .

MorganEPatch commented 7 years ago

@squat That's a function on time.Time, not time.Duration. How would you recommend doing that conversion?

squat commented 7 years ago

Ah yes very true. OK, well for lack of a time.Round for durations. Please truncate using the const time.Millisecond instead of 1000000. sound good?