From c78c204633f0669e8b64853fa48972676881987f Mon Sep 17 00:00:00 2001 From: Daniel Schmidt Date: Sun, 5 May 2024 10:04:17 -0700 Subject: [PATCH] Improve streaming read_timeout docs (#584) --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e0697050..c93bc619 100644 --- a/README.md +++ b/README.md @@ -588,7 +588,19 @@ Docker::Event { :status => die, :id => 663005cdeb56f50177c395a817dbc8bdcfbdfbdae # => nil ``` -These methods are prone to read timeouts. `Docker.options[:read_timeout]` will need to be made higher than 60 seconds if expecting a long time between events. +These methods are prone to read timeouts. The timeout can be disabled by setting it to zero, or simply made much higher: + +```ruby +# Disable timeouts completely +Docker::Event.stream({ read_timeout: 0 }) { |event| … } + +# Timeout if no events are received in 24h +Docker::Event.stream({ read_timeout: 60 * 60 * 24) }) { |event| … } + +# Set a high timeout globally. Be warned that you probably don't want this for other methods. +Docker.options[:read_timeout] = 60 * 60 * 24 +Docker::Event.stream { |event| … } +``` ## Connecting to Multiple Servers