From 0177210321622bd55474ca574c1db8af79029760 Mon Sep 17 00:00:00 2001 From: johnnyshields <27655+johnnyshields@users.noreply.github.com> Date: Sun, 3 Sep 2023 02:27:41 +0900 Subject: [PATCH] Proof-of-concept for compression warning --- docs/reference/create-client.txt | 6 ++++++ lib/mongo/client.rb | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/docs/reference/create-client.txt b/docs/reference/create-client.txt index f54805651a..b4ea052380 100644 --- a/docs/reference/create-client.txt +++ b/docs/reference/create-client.txt @@ -517,6 +517,12 @@ Ruby Options - ``Array`` - none + * - ``:warn_compression_disabled`` + - By default, the driver warns if you have not set the ``:compressors`` option. + Set this option ``false`` to silence the warning. + - ``true``, ``false`` + - none + * - ``:connect`` - **Deprecated.** Disables deployment topology discovery normally performed by the dirver and forces the cluster topology to a specific diff --git a/lib/mongo/client.rb b/lib/mongo/client.rb index e06231d4ad..8eb43e6dcf 100644 --- a/lib/mongo/client.rb +++ b/lib/mongo/client.rb @@ -1353,6 +1353,13 @@ def validate_new_options!(opts) end _options end + + unless !opts[:compressors]&.empty? || + opts[:warn_compression_disabled] == false || + @@warned_compression_disabled + log_warn("Compression is disabled. Refer to: https://www.mongodb.com/docs/ruby-driver/current/reference/create-client/#compression. You may silence this warning by setting :warn_compression_disabled = false.") + @@warned_compression_disabled = true + end end # Validates all options after they are set on the client.