k8s_openapi/v1_34/api/flowcontrol/v1/
queuing_configuration.rs

1// Generated from definition io.k8s.api.flowcontrol.v1.QueuingConfiguration
2
3/// 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.
7    pub hand_size: Option<i32>,
8
9    /// `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.
10    pub queue_length_limit: Option<i32>,
11
12    /// `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.
13    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 core::fmt::Formatter<'_>) -> core::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 core::fmt::Formatter<'_>) -> core::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() -> std::borrow::Cow<'static, str> {
126        "io.k8s.api.flowcontrol.v1.QueuingConfiguration".into()
127    }
128
129    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
130        crate::schemars::json_schema!({
131            "description": "QueuingConfiguration holds the configuration parameters for queuing",
132            "type": "object",
133            "properties": {
134                "handSize": {
135                    "description": "`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.",
136                    "type": "integer",
137                    "format": "int32",
138                },
139                "queueLengthLimit": {
140                    "description": "`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.",
141                    "type": "integer",
142                    "format": "int32",
143                },
144                "queues": {
145                    "description": "`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.",
146                    "type": "integer",
147                    "format": "int32",
148                },
149            },
150        })
151    }
152}