Skip to content

Commit 9ba94c2

Browse files
RUST-719 Correct casing in ServerType variants
1 parent dba1265 commit 9ba94c2

File tree

6 files changed

+50
-50
lines changed

6 files changed

+50
-50
lines changed

src/is_master.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,18 @@ impl IsMasterCommandResponse {
7171
ServerType::Mongos
7272
} else if self.set_name.is_some() {
7373
if let Some(true) = self.hidden {
74-
ServerType::RSOther
74+
ServerType::RsOther
7575
} else if let Some(true) = self.is_master {
76-
ServerType::RSPrimary
76+
ServerType::RsPrimary
7777
} else if let Some(true) = self.secondary {
78-
ServerType::RSSecondary
78+
ServerType::RsSecondary
7979
} else if let Some(true) = self.arbiter_only {
80-
ServerType::RSArbiter
80+
ServerType::RsArbiter
8181
} else {
82-
ServerType::RSOther
82+
ServerType::RsOther
8383
}
8484
} else if let Some(true) = self.is_replica_set {
85-
ServerType::RSGhost
85+
ServerType::RsGhost
8686
} else {
8787
ServerType::Standalone
8888
}

src/sdam/description/server.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ const DRIVER_MAX_WIRE_VERSION: i32 = 7;
1919
pub enum ServerType {
2020
Standalone,
2121
Mongos,
22-
RSPrimary,
23-
RSSecondary,
24-
RSArbiter,
25-
RSOther,
26-
RSGhost,
22+
RsPrimary,
23+
RsSecondary,
24+
RsArbiter,
25+
RsOther,
26+
RsGhost,
2727
Unknown,
2828
}
2929

@@ -32,8 +32,8 @@ impl ServerType {
3232
matches!(
3333
self,
3434
ServerType::Standalone
35-
| ServerType::RSPrimary
36-
| ServerType::RSSecondary
35+
| ServerType::RsPrimary
36+
| ServerType::RsSecondary
3737
| ServerType::Mongos
3838
)
3939
}
@@ -42,8 +42,8 @@ impl ServerType {
4242
matches!(
4343
self,
4444
ServerType::Standalone
45-
| ServerType::RSPrimary
46-
| ServerType::RSSecondary
45+
| ServerType::RsPrimary
46+
| ServerType::RsSecondary
4747
| ServerType::Mongos
4848
)
4949
}

src/sdam/description/topology/mod.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -446,16 +446,16 @@ impl TopologyDescription {
446446
server_description: ServerDescription,
447447
) -> Result<(), String> {
448448
match server_description.server_type {
449-
ServerType::Unknown | ServerType::RSGhost => {}
449+
ServerType::Unknown | ServerType::RsGhost => {}
450450
ServerType::Standalone => {
451451
self.update_unknown_with_standalone_server(server_description)
452452
}
453453
ServerType::Mongos => self.topology_type = TopologyType::Sharded,
454-
ServerType::RSPrimary => {
454+
ServerType::RsPrimary => {
455455
self.topology_type = TopologyType::ReplicaSetWithPrimary;
456456
self.update_rs_from_primary_server(server_description)?;
457457
}
458-
ServerType::RSSecondary | ServerType::RSArbiter | ServerType::RSOther => {
458+
ServerType::RsSecondary | ServerType::RsArbiter | ServerType::RsOther => {
459459
self.topology_type = TopologyType::ReplicaSetNoPrimary;
460460
self.update_rs_without_primary_server(server_description)?;
461461
}
@@ -480,15 +480,15 @@ impl TopologyDescription {
480480
server_description: ServerDescription,
481481
) -> Result<(), String> {
482482
match server_description.server_type {
483-
ServerType::Unknown | ServerType::RSGhost => {}
483+
ServerType::Unknown | ServerType::RsGhost => {}
484484
ServerType::Standalone | ServerType::Mongos => {
485485
self.servers.remove(&server_description.address);
486486
}
487-
ServerType::RSPrimary => {
487+
ServerType::RsPrimary => {
488488
self.topology_type = TopologyType::ReplicaSetWithPrimary;
489489
self.update_rs_from_primary_server(server_description)?
490490
}
491-
ServerType::RSSecondary | ServerType::RSArbiter | ServerType::RSOther => {
491+
ServerType::RsSecondary | ServerType::RsArbiter | ServerType::RsOther => {
492492
self.update_rs_without_primary_server(server_description)?;
493493
}
494494
}
@@ -502,15 +502,15 @@ impl TopologyDescription {
502502
server_description: ServerDescription,
503503
) -> Result<(), String> {
504504
match server_description.server_type {
505-
ServerType::Unknown | ServerType::RSGhost => {
505+
ServerType::Unknown | ServerType::RsGhost => {
506506
self.record_primary_state();
507507
}
508508
ServerType::Standalone | ServerType::Mongos => {
509509
self.servers.remove(&server_description.address);
510510
self.record_primary_state();
511511
}
512-
ServerType::RSPrimary => self.update_rs_from_primary_server(server_description)?,
513-
ServerType::RSSecondary | ServerType::RSArbiter | ServerType::RSOther => {
512+
ServerType::RsPrimary => self.update_rs_from_primary_server(server_description)?,
513+
ServerType::RsSecondary | ServerType::RsArbiter | ServerType::RsOther => {
514514
self.update_rs_with_primary_from_member(server_description)?;
515515
}
516516
}
@@ -629,7 +629,7 @@ impl TopologyDescription {
629629
continue;
630630
}
631631

632-
if let ServerType::RSPrimary = self.servers.get(&address).unwrap().server_type {
632+
if let ServerType::RsPrimary = self.servers.get(&address).unwrap().server_type {
633633
self.servers
634634
.insert(address.clone(), ServerDescription::new(address, None));
635635
}
@@ -657,7 +657,7 @@ impl TopologyDescription {
657657
self.topology_type = if self
658658
.servers
659659
.values()
660-
.any(|server| server.server_type == ServerType::RSPrimary)
660+
.any(|server| server.server_type == ServerType::RsPrimary)
661661
{
662662
TopologyType::ReplicaSetWithPrimary
663663
} else {

src/sdam/description/topology/server_selection/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,38 +189,38 @@ impl TopologyDescription {
189189
read_preference: &'a ReadPreference,
190190
) -> Result<Vec<&'a ServerDescription>> {
191191
let servers = match read_preference {
192-
ReadPreference::Primary => self.servers_with_type(&[ServerType::RSPrimary]).collect(),
192+
ReadPreference::Primary => self.servers_with_type(&[ServerType::RsPrimary]).collect(),
193193
ReadPreference::Secondary { ref options } => self
194194
.suitable_servers_for_read_preference(
195-
&[ServerType::RSSecondary],
195+
&[ServerType::RsSecondary],
196196
options.tag_sets.as_ref(),
197197
options.max_staleness,
198198
)?,
199199
ReadPreference::PrimaryPreferred { ref options } => {
200-
match self.servers_with_type(&[ServerType::RSPrimary]).next() {
200+
match self.servers_with_type(&[ServerType::RsPrimary]).next() {
201201
Some(primary) => vec![primary],
202202
None => self.suitable_servers_for_read_preference(
203-
&[ServerType::RSSecondary],
203+
&[ServerType::RsSecondary],
204204
options.tag_sets.as_ref(),
205205
options.max_staleness,
206206
)?,
207207
}
208208
}
209209
ReadPreference::SecondaryPreferred { ref options } => {
210210
let suitable_servers = self.suitable_servers_for_read_preference(
211-
&[ServerType::RSSecondary],
211+
&[ServerType::RsSecondary],
212212
options.tag_sets.as_ref(),
213213
options.max_staleness,
214214
)?;
215215

216216
if suitable_servers.is_empty() {
217-
self.servers_with_type(&[ServerType::RSPrimary]).collect()
217+
self.servers_with_type(&[ServerType::RsPrimary]).collect()
218218
} else {
219219
suitable_servers
220220
}
221221
}
222222
ReadPreference::Nearest { ref options } => self.suitable_servers_for_read_preference(
223-
&[ServerType::RSPrimary, ServerType::RSSecondary],
223+
&[ServerType::RsPrimary, ServerType::RsSecondary],
224224
options.tag_sets.as_ref(),
225225
options.max_staleness,
226226
)?,
@@ -263,7 +263,7 @@ impl TopologyDescription {
263263
let primary = self
264264
.servers
265265
.values()
266-
.find(|server| server.server_type == ServerType::RSPrimary);
266+
.find(|server| server.server_type == ServerType::RsPrimary);
267267

268268
match primary {
269269
Some(primary) => {
@@ -299,7 +299,7 @@ impl TopologyDescription {
299299
let max_write_date = self
300300
.servers
301301
.values()
302-
.filter(|server| server.server_type == ServerType::RSSecondary)
302+
.filter(|server| server.server_type == ServerType::RsSecondary)
303303
.filter_map(|server| {
304304
server
305305
.last_write_date()

src/sdam/description/topology/server_selection/test/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ impl TestServerType {
134134
match self {
135135
TestServerType::Standalone => Some(ServerType::Standalone),
136136
TestServerType::Mongos => Some(ServerType::Mongos),
137-
TestServerType::RSPrimary => Some(ServerType::RSPrimary),
138-
TestServerType::RSSecondary => Some(ServerType::RSSecondary),
139-
TestServerType::RSArbiter => Some(ServerType::RSArbiter),
140-
TestServerType::RSOther => Some(ServerType::RSOther),
141-
TestServerType::RSGhost => Some(ServerType::RSGhost),
137+
TestServerType::RSPrimary => Some(ServerType::RsPrimary),
138+
TestServerType::RSSecondary => Some(ServerType::RsSecondary),
139+
TestServerType::RSArbiter => Some(ServerType::RsArbiter),
140+
TestServerType::RSOther => Some(ServerType::RsOther),
141+
TestServerType::RSGhost => Some(ServerType::RsGhost),
142142
TestServerType::Unknown => Some(ServerType::Unknown),
143143
TestServerType::PossiblePrimary => None,
144144
}
@@ -166,27 +166,27 @@ fn is_master_response_from_server_type(server_type: ServerType) -> IsMasterComma
166166
response.ok = Some(1.0);
167167
response.msg = Some("isdbgrid".into());
168168
}
169-
ServerType::RSPrimary => {
169+
ServerType::RsPrimary => {
170170
response.ok = Some(1.0);
171171
response.set_name = Some("foo".into());
172172
response.is_master = Some(true);
173173
}
174-
ServerType::RSOther => {
174+
ServerType::RsOther => {
175175
response.ok = Some(1.0);
176176
response.set_name = Some("foo".into());
177177
response.hidden = Some(true);
178178
}
179-
ServerType::RSSecondary => {
179+
ServerType::RsSecondary => {
180180
response.ok = Some(1.0);
181181
response.set_name = Some("foo".into());
182182
response.secondary = Some(true);
183183
}
184-
ServerType::RSArbiter => {
184+
ServerType::RsArbiter => {
185185
response.ok = Some(1.0);
186186
response.set_name = Some("foo".into());
187187
response.arbiter_only = Some(true);
188188
}
189-
ServerType::RSGhost => {
189+
ServerType::RsGhost => {
190190
response.ok = Some(1.0);
191191
response.is_replica_set = Some(true);
192192
}

src/sdam/description/topology/test/sdam.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ fn server_type_from_str(s: &str) -> Option<ServerType> {
5858
let t = match s {
5959
"Standalone" => ServerType::Standalone,
6060
"Mongos" => ServerType::Mongos,
61-
"RSPrimary" => ServerType::RSPrimary,
62-
"RSSecondary" => ServerType::RSSecondary,
63-
"RSArbiter" => ServerType::RSArbiter,
64-
"RSOther" => ServerType::RSOther,
65-
"RSGhost" => ServerType::RSGhost,
61+
"RSPrimary" => ServerType::RsPrimary,
62+
"RSSecondary" => ServerType::RsSecondary,
63+
"RSArbiter" => ServerType::RsArbiter,
64+
"RSOther" => ServerType::RsOther,
65+
"RSGhost" => ServerType::RsGhost,
6666
"Unknown" | "PossiblePrimary" => ServerType::Unknown,
6767
_ => return None,
6868
};

0 commit comments

Comments
 (0)