engine

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultNetworkPool = &NetworkPool{
	configMap:    make(map[poolKey]*transportLease),
	transportMap: make(map[*http.Transport]*transportLease),
}

DefaultNetworkPool is the global instance managed by the engine layer.

Functions

This section is empty.

Types

type MultiLimiter added in v0.9.0

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

func NewMultiLimiter added in v0.9.0

func NewMultiLimiter(limiters ...*RateLimiter) *MultiLimiter

func (*MultiLimiter) WaitN added in v0.9.0

func (m *MultiLimiter) WaitN(ctx context.Context, n int64) error

type NetworkPool

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

NetworkPool manages shared HTTP transports for TCP connection reuse.

func (*NetworkPool) AcquireTransport

func (p *NetworkPool) AcquireTransport(proxyURL, customDNS string, maxConns int) *http.Transport

AcquireTransport returns a shared transport for the given configuration.

func (*NetworkPool) ReleaseTransport

func (p *NetworkPool) ReleaseTransport(t *http.Transport)

ReleaseTransport marks a specific transport lease as returned.

type RateLimiter added in v0.9.0

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

RateLimiter is a custom token-bucket rate limiter. We use a custom implementation instead of golang.org/x/time/rate because x/time/rate's SetLimit does not wake up already-blocked WaitN calls. For a download manager with interactive UX, we need WaitN to instantly react to a rate increase (via wakeCh) so the user doesn't experience "stuck" downloads after lifting a heavy throttle.

func NewRateLimiter added in v0.9.0

func NewRateLimiter(rate int64, bucketSize int64) *RateLimiter

func (*RateLimiter) Refund added in v0.9.0

func (r *RateLimiter) Refund(n int64)

func (*RateLimiter) SetRate added in v0.9.0

func (r *RateLimiter) SetRate(rate int64, bucketSize int64)

func (*RateLimiter) WaitN added in v0.9.0

func (r *RateLimiter) WaitN(ctx context.Context, n int64) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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