@@ -10,7 +10,6 @@ defmodule Mongo.ServerDescription do
1010 @ type type :: :standalone | :mongos | :possible_primary | :rs_primary | :rs_secondary | :rs_arbiter | :rs_other | :rs_ghost | :unknown
1111
1212 @ type compressor_types :: :zlib | :zstd
13- @ support_compressors Compressor . compressors ( )
1413
1514 @ type t :: % {
1615 address: String . t ( ) | nil ,
@@ -110,7 +109,7 @@ defmodule Mongo.ServerDescription do
110109 max_bson_object_size: hello_response [ "maxBsonObjectSize" ] || 16_777_216 ,
111110 max_message_size_bytes: hello_response [ "maxMessageSizeBytes" ] || 48_000_000 ,
112111 max_write_batch_size: hello_response [ "maxWriteBatchSize" ] || 100_000 ,
113- compression: map_compressors ( hello_response [ "compression" ] ) ,
112+ compression: Compressor . map_compressors ( hello_response [ "compression" ] ) ,
114113 read_only: hello_response [ "readOnly" ] || false ,
115114 logical_session_timeout: hello_response [ "logicalSessionTimeoutMinutes" ] || 30 ,
116115 supports_retryable_writes: supports_retryable_writes ,
@@ -143,24 +142,14 @@ defmodule Mongo.ServerDescription do
143142 max_bson_object_size: hello_response [ "maxBsonObjectSize" ] || 16_777_216 ,
144143 max_message_size_bytes: hello_response [ "maxMessageSizeBytes" ] || 48_000_000 ,
145144 max_write_batch_size: hello_response [ "maxWriteBatchSize" ] || 100_000 ,
146- compression: map_compressors ( hello_response [ "compression" ] ) ,
145+ compression: Mongo.Compressor . map_compressors ( hello_response [ "compression" ] ) ,
147146 read_only: hello_response [ "readOnly" ] || false ,
148147 logical_session_timeout: hello_response [ "logicalSessionTimeoutMinutes" ] || 30 ,
149148 supports_retryable_writes: server_type != :standalone && max_wire_version >= @ retryable_wire_version && hello_response [ "logicalSessionTimeoutMinutes" ] != nil ,
150149 replica?: replica? ( server_type )
151150 }
152151 end
153152
154- defp map_compressors ( nil ) do
155- [ ]
156- end
157-
158- defp map_compressors ( compressors ) do
159- compressors
160- |> Enum . filter ( fn compressor -> compressor in @ support_compressors end )
161- |> Enum . map ( fn compressor -> String . to_existing_atom ( compressor ) end )
162- end
163-
164153 # see https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#type
165154 defp determine_server_type ( % { "ok" => n } ) when n != 1 , do: :unknown
166155 defp determine_server_type ( % { "msg" => "isdbgrid" } ) , do: :mongos
@@ -178,10 +167,6 @@ defmodule Mongo.ServerDescription do
178167
179168 defp determine_server_type ( _ ) , do: :standalone
180169
181- def support_compressors ( ) do
182- Enum . map ( @ support_compressors , & String . to_existing_atom / 1 )
183- end
184-
185170 defp replica? ( server_type ) do
186171 server_type in [ :rs_primary , :rs_secondary , :rs_arbiter , :rs_other , :rs_ghost ]
187172 end
0 commit comments