k8s_openapi/v1_32/api/flowcontrol/v1/
queuing_configuration.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct QueuingConfiguration {
6 pub hand_size: Option<i32>,
8
9 pub queue_length_limit: Option<i32>,
11
12 pub queues: Option<i32>,
14}
15
16impl crate::DeepMerge for QueuingConfiguration {
17 fn merge_from(&mut self, other: Self) {
18 crate::DeepMerge::merge_from(&mut self.hand_size, other.hand_size);
19 crate::DeepMerge::merge_from(&mut self.queue_length_limit, other.queue_length_limit);
20 crate::DeepMerge::merge_from(&mut self.queues, other.queues);
21 }
22}
23
24impl<'de> crate::serde::Deserialize<'de> for QueuingConfiguration {
25 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
26 #[allow(non_camel_case_types)]
27 enum Field {
28 Key_hand_size,
29 Key_queue_length_limit,
30 Key_queues,
31 Other,
32 }
33
34 impl<'de> crate::serde::Deserialize<'de> for Field {
35 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
36 struct Visitor;
37
38 impl crate::serde::de::Visitor<'_> for Visitor {
39 type Value = Field;
40
41 fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42 f.write_str("field identifier")
43 }
44
45 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
46 Ok(match v {
47 "handSize" => Field::Key_hand_size,
48 "queueLengthLimit" => Field::Key_queue_length_limit,
49 "queues" => Field::Key_queues,
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 = QueuingConfiguration;
63
64 fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
65 f.write_str("QueuingConfiguration")
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_hand_size: Option<i32> = None;
70 let mut value_queue_length_limit: Option<i32> = None;
71 let mut value_queues: Option<i32> = None;
72
73 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
74 match key {
75 Field::Key_hand_size => value_hand_size = crate::serde::de::MapAccess::next_value(&mut map)?,
76 Field::Key_queue_length_limit => value_queue_length_limit = crate::serde::de::MapAccess::next_value(&mut map)?,
77 Field::Key_queues => value_queues = crate::serde::de::MapAccess::next_value(&mut map)?,
78 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
79 }
80 }
81
82 Ok(QueuingConfiguration {
83 hand_size: value_hand_size,
84 queue_length_limit: value_queue_length_limit,
85 queues: value_queues,
86 })
87 }
88 }
89
90 deserializer.deserialize_struct(
91 "QueuingConfiguration",
92 &[
93 "handSize",
94 "queueLengthLimit",
95 "queues",
96 ],
97 Visitor,
98 )
99 }
100}
101
102impl crate::serde::Serialize for QueuingConfiguration {
103 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
104 let mut state = serializer.serialize_struct(
105 "QueuingConfiguration",
106 self.hand_size.as_ref().map_or(0, |_| 1) +
107 self.queue_length_limit.as_ref().map_or(0, |_| 1) +
108 self.queues.as_ref().map_or(0, |_| 1),
109 )?;
110 if let Some(value) = &self.hand_size {
111 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "handSize", value)?;
112 }
113 if let Some(value) = &self.queue_length_limit {
114 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "queueLengthLimit", value)?;
115 }
116 if let Some(value) = &self.queues {
117 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "queues", value)?;
118 }
119 crate::serde::ser::SerializeStruct::end(state)
120 }
121}
122
123#[cfg(feature = "schemars")]
124impl crate::schemars::JsonSchema for QueuingConfiguration {
125 fn schema_name() -> String {
126 "io.k8s.api.flowcontrol.v1.QueuingConfiguration".to_owned()
127 }
128
129 fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
130 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
131 metadata: Some(Box::new(crate::schemars::schema::Metadata {
132 description: Some("QueuingConfiguration holds the configuration parameters for queuing".to_owned()),
133 ..Default::default()
134 })),
135 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
136 object: Some(Box::new(crate::schemars::schema::ObjectValidation {
137 properties: [
138 (
139 "handSize".to_owned(),
140 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
141 metadata: Some(Box::new(crate::schemars::schema::Metadata {
142 description: Some("`handSize` is a small positive number that configures the shuffle sharding of requests into queues. When enqueuing a request at this priority level the request's flow identifier (a string pair) is hashed and the hash value is used to shuffle the list of queues and deal a hand of the size specified here. The request is put into one of the shortest queues in that hand. `handSize` must be no larger than `queues`, and should be significantly smaller (so that a few heavy flows do not saturate most of the queues). See the user-facing documentation for more extensive guidance on setting this field. This field has a default value of 8.".to_owned()),
143 ..Default::default()
144 })),
145 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Integer))),
146 format: Some("int32".to_owned()),
147 ..Default::default()
148 }),
149 ),
150 (
151 "queueLengthLimit".to_owned(),
152 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
153 metadata: Some(Box::new(crate::schemars::schema::Metadata {
154 description: Some("`queueLengthLimit` is the maximum number of requests allowed to be waiting in a given queue of this priority level at a time; excess requests are rejected. This value must be positive. If not specified, it will be defaulted to 50.".to_owned()),
155 ..Default::default()
156 })),
157 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Integer))),
158 format: Some("int32".to_owned()),
159 ..Default::default()
160 }),
161 ),
162 (
163 "queues".to_owned(),
164 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
165 metadata: Some(Box::new(crate::schemars::schema::Metadata {
166 description: Some("`queues` is the number of queues for this priority level. The queues exist independently at each apiserver. The value must be positive. Setting it to 1 effectively precludes shufflesharding and thus makes the distinguisher method of associated flow schemas irrelevant. This field has a default value of 64.".to_owned()),
167 ..Default::default()
168 })),
169 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Integer))),
170 format: Some("int32".to_owned()),
171 ..Default::default()
172 }),
173 ),
174 ].into(),
175 ..Default::default()
176 })),
177 ..Default::default()
178 })
179 }
180}