pub struct Rule {Show 15 fields
pub id: Id,
pub resource: String,
pub ref_resource: String,
pub calculate_strategy: CalculateStrategy,
pub control_strategy: ControlStrategy,
pub relation_strategy: RelationStrategy,
pub threshold: f64,
pub warm_up_period_sec: u32,
pub warm_up_cold_factor: u32,
pub max_queueing_time_ms: u32,
pub stat_interval_ms: u32,
pub low_mem_usage_threshold: u64,
pub high_mem_usage_threshold: u64,
pub mem_low_water_mark: u64,
pub mem_high_water_mark: u64,
}Expand description
Rule describes the strategy of flow control, the flow control strategy is based on QPS statistic metric
Fields§
§id: Idid represents the unique ID of the rule (optional).
resource: Stringresource represents the resource name.
ref_resource: String§calculate_strategy: CalculateStrategy§control_strategy: ControlStrategy§relation_strategy: RelationStrategy§threshold: f64threshold means the threshold during stat_interval_ms
If stat_interval_ms is 1000(1 second), threshold means QPS
warm_up_period_sec: u32§warm_up_cold_factor: u32§max_queueing_time_ms: u32max_queueing_time_ms only takes effect when control_strategy is Throttling.
When max_queueing_time_ms is 0, it means Throttling only controls interval of requests,
and requests exceeding the threshold will be rejected directly.
stat_interval_ms: u32stat_interval_ms indicates the statistic interval and it’s the optional setting for flow Rule. If user doesn’t set stat_interval_ms, that means using default metric statistic of resource. If the stat_interval_ms user specifies can not reuse the global statistic of resource, sentinel will generate independent statistic structure for this self.
low_mem_usage_threshold: u64adaptive flow control algorithm related parameters limitation: low_mem_usage_threshold > high_mem_usage_threshold && mem_high_water_mark > mem_low_water_mark
- if the current memory usage is less than or equals to mem_low_water_mark, threshold == low_mem_usage_threshold
- if the current memory usage is more than or equals to mem_high_water_mark, threshold == high_mem_usage_threshold
- if the current memory usage is in (mem_low_water_mark, mem_high_water_mark), threshold is in (high_mem_usage_threshold, low_mem_usage_threshold)
high_mem_usage_threshold: u64§mem_low_water_mark: u64§mem_high_water_mark: u64Implementations§
Source§impl Rule
impl Rule
pub fn is_stat_reusable(&self, other: &Self) -> bool
pub fn need_statistic(&self) -> bool
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Rule
impl<'de> Deserialize<'de> for Rule
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for Rule
impl JsonSchema for Rule
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreSource§impl SentinelRule for Rule
impl SentinelRule for Rule
impl Eq for Rule
Auto Trait Implementations§
impl Freeze for Rule
impl RefUnwindSafe for Rule
impl Send for Rule
impl Sync for Rule
impl Unpin for Rule
impl UnwindSafe for Rule
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
Source§impl<T> CallHasher for T
impl<T> CallHasher for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> 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>
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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request