limitcaller

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultQueueingTimeout = 10 * time.Second

DefaultQueueingTimeout is the default timeout for queueing the request.

Variables

View Source
var ErrConnectionQueueingTimeout = errors.New("rateLimitingTransport: queueing timeout")

ErrConnectionQueueingTimeout indicates that we've exceeded the time allocated for queueing the current request before the request attempt could be made.

Functions

This section is empty.

Types

type ConnectionTimeStore

type ConnectionTimeStore interface {
	GetConnectionWaitTime(addrOrPeerID string) (bool, time.Duration, time.Time)
	UpdateConnectionTime(addrOrPeerID string, provisionalTime time.Time) bool
}

ConnectionTimeStore is a subset of the phonebook that is used to store the connection times.

type Dialer

type Dialer struct {
	// contains filtered or unexported fields
}

Dialer establish tcp-level connection with the destination

func MakeRateLimitingDialer

func MakeRateLimitingDialer(phonebook phonebook.Phonebook, resolver dnssec.ResolverIf) Dialer

MakeRateLimitingDialer creates a rate limiting dialer that would limit the connections according to the entries in the phonebook.

func (*Dialer) Dial

func (d *Dialer) Dial(network, address string) (net.Conn, error)

Dial connects to the address on the named network. It waits if needed not to exceed connectionsRateLimitingCount.

func (*Dialer) DialContext

func (d *Dialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)

DialContext connects to the address on the named network using the provided context. It waits if needed not to exceed connectionsRateLimitingCount.

type RateLimitingBoundTransport

type RateLimitingBoundTransport struct {
	// contains filtered or unexported fields
}

RateLimitingBoundTransport is the transport for execute a single HTTP transaction, obtaining the Response for a given Request.

func MakeRateLimitingBoundTransport

func MakeRateLimitingBoundTransport(phonebook ConnectionTimeStore, queueingTimeout time.Duration, dialer *Dialer, maxIdleConnsPerHost int, target string) RateLimitingBoundTransport

MakeRateLimitingBoundTransport creates a rate limiting http transport that that: 1. would limit the requests rate according to the entries in the phonebook. 2. is bound to a specific target.

func MakeRateLimitingBoundTransportWithRoundTripper

func MakeRateLimitingBoundTransportWithRoundTripper(phonebook ConnectionTimeStore, queueingTimeout time.Duration, rt http.RoundTripper, target string) RateLimitingBoundTransport

MakeRateLimitingBoundTransportWithRoundTripper creates a rate limiting http transport that: 1. would limit the requests rate according to the entries in the phonebook. 2. is bound to a specific target.

func (*RateLimitingBoundTransport) RoundTrip

func (r *RateLimitingBoundTransport) RoundTrip(req *http.Request) (res *http.Response, err error)

RoundTrip connects to the address on the named network using the provided context. It waits if needed not to exceed connectionsRateLimitingCount.

Jump to

Keyboard shortcuts

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