You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/mongo/streaming_hello_monitor.ex
+34-48Lines changed: 34 additions & 48 deletions
Original file line number
Diff line number
Diff line change
@@ -1,57 +1,44 @@
1
-
# see https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#monitoring
2
1
defmoduleMongo.StreamingHelloMonitordo
3
2
@moduledoc"""
4
-
Each server has a monitor process. The monitor process is created by the topology process.
3
+
See https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-monitoring.rst#streaming-protocol
5
4
6
-
If the network connection is working, then the monitor process reports this and the topology process starts the
7
-
connection pool. Per server we get 1 + pool size connections to each server.
5
+
The streaming protocol is used to monitor MongoDB 4.4+ servers and optimally reduces the time it takes for a client to discover server state changes.
6
+
Multi-threaded or asynchronous drivers MUST use the streaming protocol when connected to a server that supports the awaitable hello or legacy hello commands.
7
+
This protocol requires an extra thread and an extra socket for each monitor to perform RTT calculations.
8
8
9
-
After waiting for `heartbeat_frequency_ms` milliseconds, the monitor process calls `isMaster` command and
10
-
reports the result to the topology process.
11
-
12
-
The result of the `isMaster` command is mapped the `ServerDescription` structure and sent to the topology process, which
13
-
updates it internal data structure.
9
+
This module implements the streaming protocol. The GenServer is started and maintained by the Monitor process. The streaming hello monitor uses the
10
+
more to come flag while updating the current server description.
# this is not configurable because the specification says so
26
-
# see https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#minheartbeatfrequencyms
@@ -119,39 +106,32 @@ defmodule Mongo.StreamingHelloMonitor do
119
106
120
107
# see https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#network-error-when-calling-ismaster
121
108
##
122
-
# Calls isMaster and parses the result to update the server description
123
-
# In case of one network error, the function tries one more time to call isMaster command
109
+
# Calls hello command and parses the result to update the server description
0 commit comments