k8s_openapi/v1_30/api/flowcontrol/v1beta3/
exempt_priority_level_configuration.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct ExemptPriorityLevelConfiguration {
6 pub lendable_percent: Option<i32>,
10
11 pub nominal_concurrency_shares: Option<i32>,
17}
18
19impl crate::DeepMerge for ExemptPriorityLevelConfiguration {
20 fn merge_from(&mut self, other: Self) {
21 crate::DeepMerge::merge_from(&mut self.lendable_percent, other.lendable_percent);
22 crate::DeepMerge::merge_from(&mut self.nominal_concurrency_shares, other.nominal_concurrency_shares);
23 }
24}
25
26impl<'de> crate::serde::Deserialize<'de> for ExemptPriorityLevelConfiguration {
27 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
28 #[allow(non_camel_case_types)]
29 enum Field {
30 Key_lendable_percent,
31 Key_nominal_concurrency_shares,
32 Other,
33 }
34
35 impl<'de> crate::serde::Deserialize<'de> for Field {
36 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
37 struct Visitor;
38
39 impl crate::serde::de::Visitor<'_> for Visitor {
40 type Value = Field;
41
42 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
43 f.write_str("field identifier")
44 }
45
46 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
47 Ok(match v {
48 "lendablePercent" => Field::Key_lendable_percent,
49 "nominalConcurrencyShares" => Field::Key_nominal_concurrency_shares,
50 _ => Field::Other,
51 })
52 }
53 }
54
55 deserializer.deserialize_identifier(Visitor)
56 }
57 }
58
59 struct Visitor;
60
61 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
62 type Value = ExemptPriorityLevelConfiguration;
63
64 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
65 f.write_str("ExemptPriorityLevelConfiguration")
66 }
67
68 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
69 let mut value_lendable_percent: Option<i32> = None;
70 let mut value_nominal_concurrency_shares: Option<i32> = None;
71
72 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
73 match key {
74 Field::Key_lendable_percent => value_lendable_percent = crate::serde::de::MapAccess::next_value(&mut map)?,
75 Field::Key_nominal_concurrency_shares => value_nominal_concurrency_shares = crate::serde::de::MapAccess::next_value(&mut map)?,
76 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
77 }
78 }
79
80 Ok(ExemptPriorityLevelConfiguration {
81 lendable_percent: value_lendable_percent,
82 nominal_concurrency_shares: value_nominal_concurrency_shares,
83 })
84 }
85 }
86
87 deserializer.deserialize_struct(
88 "ExemptPriorityLevelConfiguration",
89 &[
90 "lendablePercent",
91 "nominalConcurrencyShares",
92 ],
93 Visitor,
94 )
95 }
96}
97
98impl crate::serde::Serialize for ExemptPriorityLevelConfiguration {
99 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
100 let mut state = serializer.serialize_struct(
101 "ExemptPriorityLevelConfiguration",
102 self.lendable_percent.as_ref().map_or(0, |_| 1) +
103 self.nominal_concurrency_shares.as_ref().map_or(0, |_| 1),
104 )?;
105 if let Some(value) = &self.lendable_percent {
106 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "lendablePercent", value)?;
107 }
108 if let Some(value) = &self.nominal_concurrency_shares {
109 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nominalConcurrencyShares", value)?;
110 }
111 crate::serde::ser::SerializeStruct::end(state)
112 }
113}
114
115#[cfg(feature = "schemars")]
116impl crate::schemars::JsonSchema for ExemptPriorityLevelConfiguration {
117 fn schema_name() -> std::borrow::Cow<'static, str> {
118 "io.k8s.api.flowcontrol.v1beta3.ExemptPriorityLevelConfiguration".into()
119 }
120
121 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
122 crate::schemars::json_schema!({
123 "description": "ExemptPriorityLevelConfiguration describes the configurable aspects of the handling of exempt requests. In the mandatory exempt configuration object the values in the fields here can be modified by authorized users, unlike the rest of the `spec`.",
124 "type": "object",
125 "properties": {
126 "lendablePercent": {
127 "description": "`lendablePercent` prescribes the fraction of the level's NominalCL that can be borrowed by other priority levels. This value of this field must be between 0 and 100, inclusive, and it defaults to 0. The number of seats that other levels can borrow from this level, known as this level's LendableConcurrencyLimit (LendableCL), is defined as follows.\n\nLendableCL(i) = round( NominalCL(i) * lendablePercent(i)/100.0 )",
128 "type": "integer",
129 "format": "int32",
130 },
131 "nominalConcurrencyShares": {
132 "description": "`nominalConcurrencyShares` (NCS) contributes to the computation of the NominalConcurrencyLimit (NominalCL) of this level. This is the number of execution seats nominally reserved for this priority level. This DOES NOT limit the dispatching from this priority level but affects the other priority levels through the borrowing mechanism. The server's concurrency limit (ServerCL) is divided among all the priority levels in proportion to their NCS values:\n\nNominalCL(i) = ceil( ServerCL * NCS(i) / sum_ncs ) sum_ncs = sum[priority level k] NCS(k)\n\nBigger numbers mean a larger nominal concurrency limit, at the expense of every other priority level. This field has a default value of zero.",
133 "type": "integer",
134 "format": "int32",
135 },
136 },
137 })
138 }
139}