MCPcopy Index your code
hub / github.com/dnote/dnote / NewRateLimitedHTTPClient

Function NewRateLimitedHTTPClient

pkg/cli/client/client.go:89–100  ·  view source on GitHub ↗

NewRateLimitedHTTPClient creates an HTTP client with rate limiting

()

Source from the content-addressed store, hash-verified

87
88// NewRateLimitedHTTPClient creates an HTTP client with rate limiting
89func NewRateLimitedHTTPClient() *http.Client {
90 // Calculate interval from rate: 1 second / requests per second
91 interval := time.Second / time.Duration(clientRateLimitPerSecond)
92
93 transport := &rateLimitedTransport{
94 transport: http.DefaultTransport,
95 limiter: rate.NewLimiter(rate.Every(interval), clientRateLimitBurst),
96 }
97 return &http.Client{
98 Transport: transport,
99 }
100}
101
102func getHTTPClient(ctx context.DnoteCtx, options *requestOptions) *http.Client {
103 if options != nil && options.HTTPClient != nil {

Callers 3

setupCtxFunction · 0.92
TestSignInFunction · 0.85
TestSignOutFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestSignInFunction · 0.68
TestSignOutFunction · 0.68