Skip to content

Document how to handle timeouts and retries #29

Description

@decentral1se

Radar is heavily rate limiting due to bot scraping. We could help API consumers with this.

#28 is a first start.

I am testing https://github.com/hashicorp/go-retryablehttp atm and have a patch:

package web

import (
	"net/http"
	"time"

	"github.com/hashicorp/go-retryablehttp"
)

func GetHttpClient() *http.Client {
	retryClient := retryablehttp.NewClient()
	retryClient.RetryMax = 10

	httpClient := retryClient.StandardClient()
	httpClient.Timeout = 30 * time.Second

	return httpClient
}

Which I use like so:

radarClient := radarPkg.NewRadarClient(
  radarPkg.WithLogger(slogHandler),
  radarPkg.WithClient(httpClient),
)

I am not sure if we should make the decision for people what client they should use but it might save work? OTOH, they'll probably want to configure the retryablehttp client also. So, I am not sure what is best. Documenting this approach could also be fine?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions