|
1 | 1 | use std::time::Duration;
|
2 | 2 |
|
3 |
| -use crate::{client::options::ServerAddress, is_master::IsMasterReply, sdam::ServerType}; |
| 3 | +use crate::{client::options::ServerAddress, hello::HelloReply, sdam::ServerType}; |
4 | 4 |
|
5 | 5 | /// Contains information about a given server in a format digestible by a connection.
|
6 | 6 | #[derive(Debug, Default, Clone)]
|
@@ -32,24 +32,27 @@ pub(crate) struct StreamDescription {
|
32 | 32 | /// can be included in a write batch. If more than this number of writes are included, the
|
33 | 33 | /// server cannot guarantee space in the response document to reply to the batch.
|
34 | 34 | pub(crate) max_write_batch_size: i64,
|
| 35 | + |
| 36 | + /// Whether the server associated with this connection supports the `hello` command. |
| 37 | + pub(crate) hello_ok: bool, |
35 | 38 | }
|
36 | 39 |
|
37 | 40 | impl StreamDescription {
|
38 |
| - /// Constructs a new StreamDescription from an IsMasterReply. |
39 |
| - pub(crate) fn from_is_master(reply: IsMasterReply) -> Self { |
| 41 | + /// Constructs a new StreamDescription from a `HelloReply`. |
| 42 | + pub(crate) fn from_hello_reply(reply: &HelloReply) -> Self { |
40 | 43 | Self {
|
41 |
| - server_address: reply.server_address, |
| 44 | + server_address: reply.server_address.clone(), |
42 | 45 | initial_server_type: reply.command_response.server_type(),
|
43 | 46 | max_wire_version: reply.command_response.max_wire_version,
|
44 | 47 | min_wire_version: reply.command_response.min_wire_version,
|
45 |
| - sasl_supported_mechs: reply.command_response.sasl_supported_mechs, |
46 |
| - // TODO RUST-204: Add "saslSupportedMechs" if applicable. |
| 48 | + sasl_supported_mechs: reply.command_response.sasl_supported_mechs.clone(), |
47 | 49 | logical_session_timeout: reply
|
48 | 50 | .command_response
|
49 | 51 | .logical_session_timeout_minutes
|
50 | 52 | .map(|mins| Duration::from_secs(mins as u64 * 60)),
|
51 | 53 | max_bson_object_size: reply.command_response.max_bson_object_size,
|
52 | 54 | max_write_batch_size: reply.command_response.max_write_batch_size,
|
| 55 | + hello_ok: reply.command_response.hello_ok.unwrap_or(false), |
53 | 56 | }
|
54 | 57 | }
|
55 | 58 |
|
@@ -78,6 +81,7 @@ impl StreamDescription {
|
78 | 81 | logical_session_timeout: Some(Duration::from_secs(30 * 60)),
|
79 | 82 | max_bson_object_size: 16 * 1024 * 1024,
|
80 | 83 | max_write_batch_size: 100_000,
|
| 84 | + hello_ok: false, |
81 | 85 | }
|
82 | 86 | }
|
83 | 87 | }
|
0 commit comments