1// Generated from definition io.k8s.api.flowcontrol.v1beta3.QueuingConfiguration
23/// QueuingConfiguration holds the configuration parameters for queuing
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct QueuingConfiguration {
6/// `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.
7pub hand_size: Option<i32>,
89/// `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.
10pub queue_length_limit: Option<i32>,
1112/// `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.
13pub queues: Option<i32>,
14}
1516impl crate::DeepMerge for QueuingConfiguration {
17fn merge_from(&mut self, other: Self) {
18crate::DeepMerge::merge_from(&mut self.hand_size, other.hand_size);
19crate::DeepMerge::merge_from(&mut self.queue_length_limit, other.queue_length_limit);
20crate::DeepMerge::merge_from(&mut self.queues, other.queues);
21 }
22}
2324impl<'de> crate::serde::Deserialize<'de> for QueuingConfiguration {
25fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
26#[allow(non_camel_case_types)]
27enum Field {
28 Key_hand_size,
29 Key_queue_length_limit,
30 Key_queues,
31 Other,
32 }
3334impl<'de> crate::serde::Deserialize<'de> for Field {
35fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
36struct Visitor;
3738impl<'de> crate::serde::de::Visitor<'de> for Visitor {
39type Value = Field;
4041fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42 f.write_str("field identifier")
43 }
4445fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
46Ok(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 }
5455 deserializer.deserialize_identifier(Visitor)
56 }
57 }
5859struct Visitor;
6061impl<'de> crate::serde::de::Visitor<'de> for Visitor {
62type Value = QueuingConfiguration;
6364fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
65 f.write_str("QueuingConfiguration")
66 }
6768fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
69let mut value_hand_size: Option<i32> = None;
70let mut value_queue_length_limit: Option<i32> = None;
71let mut value_queues: Option<i32> = None;
7273while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
74match 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 }
8182Ok(QueuingConfiguration {
83 hand_size: value_hand_size,
84 queue_length_limit: value_queue_length_limit,
85 queues: value_queues,
86 })
87 }
88 }
8990 deserializer.deserialize_struct(
91"QueuingConfiguration",
92&[
93"handSize",
94"queueLengthLimit",
95"queues",
96 ],
97 Visitor,
98 )
99 }
100}
101102impl crate::serde::Serialize for QueuingConfiguration {
103fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
104let mut state = serializer.serialize_struct(
105"QueuingConfiguration",
106self.hand_size.as_ref().map_or(0, |_| 1) +
107self.queue_length_limit.as_ref().map_or(0, |_| 1) +
108self.queues.as_ref().map_or(0, |_| 1),
109 )?;
110if let Some(value) = &self.hand_size {
111crate::serde::ser::SerializeStruct::serialize_field(&mut state, "handSize", value)?;
112 }
113if let Some(value) = &self.queue_length_limit {
114crate::serde::ser::SerializeStruct::serialize_field(&mut state, "queueLengthLimit", value)?;
115 }
116if let Some(value) = &self.queues {
117crate::serde::ser::SerializeStruct::serialize_field(&mut state, "queues", value)?;
118 }
119crate::serde::ser::SerializeStruct::end(state)
120 }
121}
122123#[cfg(feature = "schemars")]
124impl crate::schemars::JsonSchema for QueuingConfiguration {
125fn schema_name() -> String {
126"io.k8s.api.flowcontrol.v1beta3.QueuingConfiguration".to_owned()
127 }
128129fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
130crate::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(),
140crate::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(),
152crate::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(),
164crate::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}