clients

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLimiter added in v0.8.4

func NewLimiter(count int) grpc_ratelimit.Limiter

NewLimiter return new go-grpc Limiter, specified the number of requests you want to limit as a counts per second.

func NewRateLimitedTransport

func NewRateLimitedTransport(transport http.RoundTripper, limiter *rate.Limiter) http.RoundTripper

NewRateLimitedTransport creates a new RateLimitedTransport that wraps the provided http.RoundTripper and uses the provided rate.Limiter to control the rate of outgoing requests. It returns an http.RoundTripper that can be used wherever an http.RoundTripper is expected.

Parameters:

  • transport: The underlying http.RoundTripper to wrap. This is typically an instance of http.Transport or any custom implementation of http.RoundTripper.
  • limiter: The rate.Limiter to use for controlling the rate of outgoing requests.

func UnaryClientInterceptor added in v0.8.4

func UnaryClientInterceptor(limiter grpc_ratelimit.Limiter) grpc.UnaryClientInterceptor

UnaryClientInterceptor return server unary interceptor that limit requests.

Types

type RateLimitedTransport

type RateLimitedTransport struct {
	Transport http.RoundTripper
	Limiter   *rate.Limiter
}

RateLimitedTransport is a wrapper around http.RoundTripper that adds rate limiting functionality to HTTP requests. It uses a rate.Limiter to control the rate of outgoing requests.

func (*RateLimitedTransport) RoundTrip

func (t *RateLimitedTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes a single HTTP transaction on the wrapped http.RoundTripper, applying rate limiting before making the request. If the rate limit is exceeded, it waits until the limiter allows the request.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL