mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-25 17:53:15 +01:00
[chore] use string formatting package agnostic way of printing request attempts ptr (#3371)
This commit is contained in:
parent
504b3a9162
commit
18b7e00fef
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||||
@ -32,6 +33,7 @@
|
|||||||
// Request wraps an HTTP request
|
// Request wraps an HTTP request
|
||||||
// to add our own retry / backoff.
|
// to add our own retry / backoff.
|
||||||
type Request struct {
|
type Request struct {
|
||||||
|
|
||||||
// Current backoff dur.
|
// Current backoff dur.
|
||||||
backoff time.Duration
|
backoff time.Duration
|
||||||
|
|
||||||
@ -57,8 +59,7 @@ func WrapRequest(r *http.Request) *Request {
|
|||||||
// Only add content-type header if a request body exists.
|
// Only add content-type header if a request body exists.
|
||||||
entry = entry.WithField("contentType", r.Header.Get("Content-Type"))
|
entry = entry.WithField("contentType", r.Header.Get("Content-Type"))
|
||||||
}
|
}
|
||||||
// note our formatting library follows ptr values
|
entry = entry.WithField("attempt", uintPtr{&rr.attempts})
|
||||||
entry = entry.WithField("attempt", &rr.attempts)
|
|
||||||
rr.Entry = entry
|
rr.Entry = entry
|
||||||
return rr
|
return rr
|
||||||
}
|
}
|
||||||
@ -73,3 +74,12 @@ func (r *Request) BackOff() time.Duration {
|
|||||||
}
|
}
|
||||||
return r.backoff
|
return r.backoff
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type uintPtr struct{ u *uint }
|
||||||
|
|
||||||
|
func (f uintPtr) String() string {
|
||||||
|
if f.u == nil {
|
||||||
|
return "<nil>"
|
||||||
|
}
|
||||||
|
return strconv.FormatUint(uint64(*f.u), 10)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user