From 9eed1a6da4ed47a67a1569a9aa8a02f0f7ead907 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Sun, 17 Dec 2023 15:08:39 +0700 Subject: http/sseclient: fix Retry value not set to millisecond When client receive "retry:" message, the value is in millisecond, but when we store it we only convert it to [time.Duration] which default to nanosecond. While at it, update comments on field [Client.Retry] and [Client.Insecure]. --- lib/http/sseclient/sseclient.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/http/sseclient/sseclient.go b/lib/http/sseclient/sseclient.go index 4ee7dc4d..8b0f9779 100644 --- a/lib/http/sseclient/sseclient.go +++ b/lib/http/sseclient/sseclient.go @@ -71,10 +71,10 @@ type Client struct { // before reconnecting back to server after disconnect. // Zero or negative value disable it. // - // This field is optional, default to 0, not retrying. + // This field is optional, default to 0 (not retrying). Retry time.Duration - // Insecure allow connect to HTTPS Endpoint with invalid + // Insecure allow connect to HTTPS endpoint with invalid // certificate. Insecure bool } @@ -442,7 +442,7 @@ func (cl *Client) parseEvent(raw []byte) { var retry int64 retry, err = strconv.ParseInt(string(fval), 10, 64) if err == nil { - cl.Retry = time.Duration(retry) + cl.Retry = time.Duration(retry) * time.Millisecond } default: // Ignore the field. -- cgit v1.3