pub struct ConcurrentLimitLayer { /* private fields */ }
Expand description
Add concurrent request limit.
§Notes
Users can control how many concurrent connections could be established between OpenDAL and underlying storage services.
All operators wrapped by this layer will share a common semaphore. This allows you to reuse the same layer across multiple operators, ensuring that the total number of concurrent requests across the entire application does not exceed the limit.
§Examples
Add a concurrent limit layer to the operator:
let _ = Operator::new(services::Memory::default())?
.layer(ConcurrentLimitLayer::new(1024))
.finish();
Ok(())
Share a concurrent limit layer between the operators:
let limit = ConcurrentLimitLayer::new(1024);
let _operator_a = Operator::new(services::Memory::default())?
.layer(limit.clone())
.finish();
let _operator_b = Operator::new(services::Memory::default())?
.layer(limit.clone())
.finish();
Ok(())
Implementations§
Source§impl ConcurrentLimitLayer
impl ConcurrentLimitLayer
Sourcepub fn new(permits: usize) -> Self
pub fn new(permits: usize) -> Self
Create a new ConcurrentLimitLayer will specify permits.
This permits will applied to all operations.
Sourcepub fn with_http_concurrent_limit(self, permits: usize) -> Self
pub fn with_http_concurrent_limit(self, permits: usize) -> Self
Set a concurrent limit for HTTP requests.
This will limit the number of concurrent HTTP requests made by the operator.
Trait Implementations§
Source§impl Clone for ConcurrentLimitLayer
impl Clone for ConcurrentLimitLayer
Source§fn clone(&self) -> ConcurrentLimitLayer
fn clone(&self) -> ConcurrentLimitLayer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<A: Access> Layer<A> for ConcurrentLimitLayer
impl<A: Access> Layer<A> for ConcurrentLimitLayer
Source§type LayeredAccess = ConcurrentLimitAccessor<A>
type LayeredAccess = ConcurrentLimitAccessor<A>
The layered accessor that returned by this layer.
Source§fn layer(&self, inner: A) -> Self::LayeredAccess
fn layer(&self, inner: A) -> Self::LayeredAccess
Intercept the operations on the underlying storage.
Auto Trait Implementations§
impl Freeze for ConcurrentLimitLayer
impl !RefUnwindSafe for ConcurrentLimitLayer
impl Send for ConcurrentLimitLayer
impl Sync for ConcurrentLimitLayer
impl Unpin for ConcurrentLimitLayer
impl !UnwindSafe for ConcurrentLimitLayer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Apply a transformation to the response body. Read more
Source§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
Decompress response bodies. Read more
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using HTTP status codes. Read more
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using gRPC headers. Read more