From 640a025a1fbe47ac1cc39a13f5ecb08e447cfe44 Mon Sep 17 00:00:00 2001 From: Jordan Smith Date: Wed, 9 Jul 2025 12:10:24 -0400 Subject: [PATCH 1/5] add network compression page --- source/connect.txt | 3 -- source/connect/connection-options.txt | 8 ++++ source/connect/network-compression.txt | 61 ++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 source/connect/network-compression.txt diff --git a/source/connect.txt b/source/connect.txt index 22eeab0b..6d64baec 100644 --- a/source/connect.txt +++ b/source/connect.txt @@ -23,9 +23,6 @@ Connect to MongoDB :maxdepth: 1 Create a Client - Stable API Choose a Connection Target Connection Options - Configure TLS - Limit Server Execution Time AWS Lambda diff --git a/source/connect/connection-options.txt b/source/connect/connection-options.txt index 769ff176..b39c9c8a 100644 --- a/source/connect/connection-options.txt +++ b/source/connect/connection-options.txt @@ -17,6 +17,14 @@ Specify Connection Options .. meta:: :keywords: connection string, URI, server, Atlas, settings, configure +.. toctree:: + :titlesonly: + :maxdepth: 1 + + Compress Network Traffic + Stable API + Limit Server Execution Time + Overview -------- diff --git a/source/connect/network-compression.txt b/source/connect/network-compression.txt new file mode 100644 index 00000000..177a9918 --- /dev/null +++ b/source/connect/network-compression.txt @@ -0,0 +1,61 @@ +======================== +Compress Network Traffic +======================== + +.. meta:: + :keywords: network compression, zlib, snappy, zstd, Ruby driver, connection string, URI, settings, configure + +.. contents:: On this page + :local: + :depth: 2 + +Overview +-------- + +The {+driver-short+} supports network compression to reduce the amount +of data transmitted between the client and the server. + +The driver supports the following compression algorithms: + +1. `Snappy `__ + +2. `Zlib `__ + +3. `Zstandard `__ + + +If you specify multiple compression algorithms, the driver selects the first +one in the list supported by your MongoDB instance. + +Specify Connection Algorithms +----------------------------- + +To enable compression for the connection to your MongoDB instance, +specify the algorithms you want to use in one of the following ways: + +1. Add the algorithms to your connection string as a parameter +2. Specify the algorithms in the ``compressors`` option of your ``Mongo::Client`` object + +.. tabs:: + + .. tab:: Connection String + :tabid: connection-string + + To enable network compression by using the connection string, add the ``compressors`` option. + You can specify one or more algorithms as a comma-separated list. + + .. code-block:: ruby + + uri = "mongodb://:/?compressors=zlib,snappy" + client = Mongo::Client.new(uri) + + .. tab:: Client Settings + :tabid: client-settings + + To enable compression in your Client object, pass the ``:compressors`` option + to the ``Mongo::Client`` constructor, as shown in the following example: + + .. code-block:: ruby + + client = Mongo::Client.new([":"], + compressors: ["zlib", "snappy"]) From 63b14c80a1d8d8d6784a85d3a26b02deec6e8e23 Mon Sep 17 00:00:00 2001 From: Jordan Smith Date: Wed, 9 Jul 2025 12:19:15 -0400 Subject: [PATCH 2/5] make connection options clickable --- snooty.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/snooty.toml b/snooty.toml index 7d7ee58b..45851f60 100644 --- a/snooty.toml +++ b/snooty.toml @@ -1,6 +1,7 @@ name = "ruby-driver" title = "Ruby Driver" toc_landing_pages = [ + "connect/connection-options", "/crud/query", "/indexes", "/security/authentication" From a8d15fc53297ebad1aa04bc2a9815c96be91f9da Mon Sep 17 00:00:00 2001 From: Jordan Smith Date: Wed, 9 Jul 2025 12:31:26 -0400 Subject: [PATCH 3/5] indentation --- source/connect/network-compression.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/connect/network-compression.txt b/source/connect/network-compression.txt index 177a9918..b9bff765 100644 --- a/source/connect/network-compression.txt +++ b/source/connect/network-compression.txt @@ -58,4 +58,4 @@ specify the algorithms you want to use in one of the following ways: .. code-block:: ruby client = Mongo::Client.new([":"], - compressors: ["zlib", "snappy"]) + compressors: ["zlib", "snappy"]) From 299e7e0379cc780bc929d083174960dcc89921fe Mon Sep 17 00:00:00 2001 From: Jordan Smith Date: Thu, 10 Jul 2025 09:49:08 -0400 Subject: [PATCH 4/5] feedback --- snooty.toml | 2 +- source/connect/network-compression.txt | 32 +++++++++---------- .../includes/connect/network-compression.rb | 9 ++++++ 3 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 source/includes/connect/network-compression.rb diff --git a/snooty.toml b/snooty.toml index 45851f60..d2e2e4a1 100644 --- a/snooty.toml +++ b/snooty.toml @@ -1,7 +1,7 @@ name = "ruby-driver" title = "Ruby Driver" toc_landing_pages = [ - "connect/connection-options", + "/connect/connection-options", "/crud/query", "/indexes", "/security/authentication" diff --git a/source/connect/network-compression.txt b/source/connect/network-compression.txt index b9bff765..9a3df329 100644 --- a/source/connect/network-compression.txt +++ b/source/connect/network-compression.txt @@ -17,11 +17,9 @@ of data transmitted between the client and the server. The driver supports the following compression algorithms: -1. `Snappy `__ - -2. `Zlib `__ - -3. `Zstandard `__ +- `Snappy `__ +- `Zlib `__ +- `Zstandard `__ If you specify multiple compression algorithms, the driver selects the first @@ -33,8 +31,8 @@ Specify Connection Algorithms To enable compression for the connection to your MongoDB instance, specify the algorithms you want to use in one of the following ways: -1. Add the algorithms to your connection string as a parameter -2. Specify the algorithms in the ``compressors`` option of your ``Mongo::Client`` object +- Add the algorithms to your connection string as a parameter +- Specify the algorithms in the ``compressors`` option of your ``Mongo::Client`` object .. tabs:: @@ -44,18 +42,18 @@ specify the algorithms you want to use in one of the following ways: To enable network compression by using the connection string, add the ``compressors`` option. You can specify one or more algorithms as a comma-separated list. - .. code-block:: ruby - - uri = "mongodb://:/?compressors=zlib,snappy" - client = Mongo::Client.new(uri) + .. literalinclude:: /includes/connect/network-compression.rb + :start-after: start-connection-string + :end-before: end-connection-string + :language: ruby .. tab:: Client Settings :tabid: client-settings - To enable compression in your Client object, pass the ``:compressors`` option - to the ``Mongo::Client`` constructor, as shown in the following example: - - .. code-block:: ruby + To enable compression in your Client object, pass the ``compressors`` option + to the ``Mongo::Client`` constructor. - client = Mongo::Client.new([":"], - compressors: ["zlib", "snappy"]) + .. literalinclude:: /includes/connect/network-compression.rb + :start-after: start-client-settings + :end-before: end-client-settings + :language: ruby diff --git a/source/includes/connect/network-compression.rb b/source/includes/connect/network-compression.rb new file mode 100644 index 00000000..65281115 --- /dev/null +++ b/source/includes/connect/network-compression.rb @@ -0,0 +1,9 @@ +# start-connection-string +uri = "mongodb://:/?compressors=zlib,snappy" +client = Mongo::Client.new(uri) +# end-connection-string + +# start-client-settings +client = Mongo::Client.new([":"], + compressors: ["zlib", "snappy"]) +# end-client-settings \ No newline at end of file From 75b795715e69bf856693de45babb4423e1077909 Mon Sep 17 00:00:00 2001 From: Jordan Smith Date: Thu, 10 Jul 2025 09:54:47 -0400 Subject: [PATCH 5/5] typo --- source/connect/network-compression.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/connect/network-compression.txt b/source/connect/network-compression.txt index 9a3df329..b1901893 100644 --- a/source/connect/network-compression.txt +++ b/source/connect/network-compression.txt @@ -25,8 +25,8 @@ The driver supports the following compression algorithms: If you specify multiple compression algorithms, the driver selects the first one in the list supported by your MongoDB instance. -Specify Connection Algorithms ------------------------------ +Specify Compression Algorithms +------------------------------ To enable compression for the connection to your MongoDB instance, specify the algorithms you want to use in one of the following ways: