Documentation
¶
Index ¶
- func GetJsonBody(body interface{}) (buf io.ReadWriter, err error)
- type RateLimitError
- type Request
- func (r *Request) Delete(ctx context.Context, result interface{}, path string) error
- func (r *Request) Execute(ctx context.Context, method string, url string, body io.Reader, ...) error
- func (r *Request) ExecuteRaw(ctx context.Context, method string, url string, body io.Reader, ...) error
- func (r *Request) Get(ctx context.Context, result interface{}, path string, query url.Values) error
- func (r *Request) GetBase(path string) string
- func (r *Request) GetRaw(ctx context.Context, result *bytes.Buffer, path string, query url.Values) error
- func (r *Request) Patch(ctx context.Context, result interface{}, path string, body interface{}) error
- func (r *Request) Post(ctx context.Context, result interface{}, path string, body interface{}) error
- func (r *Request) PostWithOutEncoded(ctx context.Context, result interface{}, path string, body interface{}) error
- func (r *Request) PostWithPlain(ctx context.Context, result interface{}, path string, body io.Reader) error
- func (r *Request) PostWithXWWWFormUrlencoded(ctx context.Context, result interface{}, path string, body interface{}) error
- func (r *Request) SetBaseUrl(url string)
- func (r *Request) SetHeader(k, v string)
- func (r *Request) SetRateLimit(qps float64, burst int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetJsonBody ¶
func GetJsonBody(body interface{}) (buf io.ReadWriter, err error)
Types ¶
type RateLimitError ¶
func (*RateLimitError) Error ¶
func (e *RateLimitError) Error() string
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func NewRequest ¶
NewRequest constructs a Request with a 200 QPS / burst 500 default rate limiter — dev-friendly, unopinionated. Any client that hits a third-party with a documented cap (Jupiter, Bungee, CoinGecko free tier, ...) should call SetRateLimit with the cap so a chatty poll doesn't blow the budget and 429 everyone.
func (*Request) ExecuteRaw ¶
func (*Request) PostWithOutEncoded ¶
func (*Request) PostWithPlain ¶
func (*Request) PostWithXWWWFormUrlencoded ¶
func (*Request) SetBaseUrl ¶
func (*Request) SetRateLimit ¶
SetRateLimit replaces the per-Request rate limiter. Every Execute / ExecuteRaw call already waits on r.limiter, so this is the single knob for outbound throughput.
qps is requests per second (fractional OK — 0.5 = 30/min). burst is the number of tokens the bucket can hold above steady state: small (1-3) for latency-sensitive polls where we WANT to feel the limit; larger (~qps) for batch sweeps that legitimately arrive in bursts. rate.Inf on qps disables limiting entirely.