Struct DegradationManager
pub struct DegradationManager {
level: RwLock<RawRwLock, DegradationLevel>,
policy: LoadSheddingPolicy,
callbacks: RwLock<RawRwLock, Vec<Arc<dyn Fn(DegradationLevel, DegradationLevel) + Send + Sync>>>,
shed_counter: AtomicU64,
total_requests: AtomicU64,
shed_requests: AtomicU64,
}Expand description
Graceful degradation manager.
Fields§
§level: RwLock<RawRwLock, DegradationLevel>§policy: LoadSheddingPolicy§callbacks: RwLock<RawRwLock, Vec<Arc<dyn Fn(DegradationLevel, DegradationLevel) + Send + Sync>>>§shed_counter: AtomicU64§total_requests: AtomicU64§shed_requests: AtomicU64Implementations§
§impl DegradationManager
impl DegradationManager
pub fn new() -> Arc<DegradationManager>
pub fn new() -> Arc<DegradationManager>
Create a new degradation manager.
pub fn with_policy(policy: LoadSheddingPolicy) -> Arc<DegradationManager>
pub fn with_policy(policy: LoadSheddingPolicy) -> Arc<DegradationManager>
Create with custom policy.
pub fn level(&self) -> DegradationLevel
pub fn level(&self) -> DegradationLevel
Get current degradation level.
pub fn set_level(&self, new_level: DegradationLevel)
pub fn set_level(&self, new_level: DegradationLevel)
Set degradation level.
pub fn on_level_change<F>(&self, callback: F)
pub fn on_level_change<F>(&self, callback: F)
Register level change callback.
pub fn should_shed(&self) -> bool
pub fn should_shed(&self) -> bool
Check if request should be shed.
pub fn is_feature_disabled(&self, required_level: DegradationLevel) -> bool
pub fn is_feature_disabled(&self, required_level: DegradationLevel) -> bool
Check if a feature should be disabled at current level.
pub fn stats(&self) -> DegradationStats
pub fn stats(&self) -> DegradationStats
Get shedding statistics.
Trait Implementations§
§impl Default for DegradationManager
impl Default for DegradationManager
§fn default() -> DegradationManager
fn default() -> DegradationManager
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for DegradationManager
impl !RefUnwindSafe for DegradationManager
impl Send for DegradationManager
impl Sync for DegradationManager
impl Unpin for DegradationManager
impl !UnwindSafe for DegradationManager
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.