Skip to content

Commit

Permalink
Add client WithTimeout and WithRetry
Browse files Browse the repository at this point in the history
  • Loading branch information
mladBlum committed Jan 15, 2025
1 parent adc8ee9 commit bd79de6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ func WithAdminEmailPassword22(email, password string) ClientOption {
}
}

// WithTimeout set the timeout for requests
func WithTimeout(timeout time.Duration) ClientOption {
return func(c *Client) {
c.client.SetTimeout(timeout)
}
}

// WithRetry set the retry settings for requests (defaults: count=3, waitTime=3s, maxWaitTime=10s)
func WithRetry(count int, waitTime, maxWaitTime time.Duration) ClientOption {
return func(c *Client) {
c.client.SetRetryCount(count)
c.client.SetRetryWaitTime(waitTime)
c.client.SetRetryMaxWaitTime(maxWaitTime)
}
}

func WithAdminEmailPassword(email, password string) ClientOption {
return func(c *Client) {
c.authorizer = newAuthorizeEmailPassword(c.client, c.url+fmt.Sprintf("/api/collections/%s/auth-with-password", core.CollectionNameSuperusers), email, password)
Expand Down

0 comments on commit bd79de6

Please sign in to comment.