pub struct HttpClient { /* private fields */ }
Expand description
A high-performance HTTP client with rate limiting and timeout capabilities.
This struct is designed to handle HTTP requests efficiently, providing
support for rate limiting, timeouts, and custom headers. The client is
built on top of reqwest
and can be used for both synchronous and
asynchronous HTTP requests.
Implementations§
Source§impl HttpClient
impl HttpClient
Sourcepub fn py_new(
header_keys: Vec<String>,
keyed_quotas: Vec<(String, Quota)>,
default_quota: Option<Quota>,
) -> Self
pub fn py_new( header_keys: Vec<String>, keyed_quotas: Vec<(String, Quota)>, default_quota: Option<Quota>, ) -> Self
Create a new HttpClient.
header_keys
: The key value pairs for the given header_keys
are retained from the responses.
keyed_quota
: A list of string quota pairs that gives quota for specific key values.
default_quota
: The default rate limiting quota for any request.
Default quota is optional and no quota is passthrough.
Rate limiting can be configured on a per-endpoint basis by passing key-value pairs of endpoint URLs and their respective quotas.
For /foo -> 10 reqs/sec configure limit with (“foo”, Quota.rate_per_second(10))
Hierarchical rate limiting can be achieved by configuring the quotas for each level.
For /foo/bar -> 10 reqs/sec and /foo -> 20 reqs/sec configure limits for keys “foo/bar” and “foo” respectively.
When a request is made the URL should be split into all the keys within it.
For request /foo/bar, should pass keys [“foo/bar”, “foo”] for rate limiting.
Trait Implementations§
Source§impl IntoPy<Py<PyAny>> for HttpClient
impl IntoPy<Py<PyAny>> for HttpClient
Source§impl PyClass for HttpClient
impl PyClass for HttpClient
Source§impl PyClassImpl for HttpClient
impl PyClassImpl for HttpClient
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§type ThreadChecker = SendablePyClass<HttpClient>
type ThreadChecker = SendablePyClass<HttpClient>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyClassNewTextSignature<HttpClient> for PyClassImplCollector<HttpClient>
impl PyClassNewTextSignature<HttpClient> for PyClassImplCollector<HttpClient>
fn new_text_signature(self) -> Option<&'static str>
Source§impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a HttpClient
impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a HttpClient
Source§impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut HttpClient
impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut HttpClient
Source§impl PyMethods<HttpClient> for PyClassImplCollector<HttpClient>
impl PyMethods<HttpClient> for PyClassImplCollector<HttpClient>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for HttpClient
impl PyTypeInfo for HttpClient
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
object
is an instance of this type or a subclass of this type.§fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
object
is an instance of this type.