ndb 1.21.2 → 1.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/ndb/client.rb +1 -1
- data/lib/ndb/connection.rb +14 -0
- data/lib/ndb/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c413fb7547ef9b5d1dda39f692986db5747d33f25a02629321de3495dc18f931
|
|
4
|
+
data.tar.gz: 2957aa64a92ca6ea2a832b12ff77dc63a6289d98392c41cd3c44ce8908058e8e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 40a1dbf3d57b20a00867e4fcb18aaf5c41a8be98b765e24e435becaaed20129dd88a52e0f21016f26038338913bd5f0a8d048a40a076b550f3d4f44344420647
|
|
7
|
+
data.tar.gz: 232f4b71f71183a47e9db78a65583a243e323f20253f80ec24d6aaf04ec3d3e29b030354d0160e7db73744fd9da161275005513db4ea77b6d76bb349eb133467
|
data/README.md
CHANGED
|
@@ -59,7 +59,7 @@ Ndb::Client.new(
|
|
|
59
59
|
- A bad address raises `ArgumentError` at once.
|
|
60
60
|
- `ready_timeout` is how long a call retries while the daemon is not ready (`not_ready`, or the socket is missing or refuses). It uses exponential backoff (50 ms up to 1 s) with jitter. A write is retried only when the daemon certainly did not process it. A read is also retried after a dropped connection. A timeout is never retried. When the deadline passes, the last error is raised.
|
|
61
61
|
- `health` does not wait: a daemon that is recovering raises `Ndb::NotReady`.
|
|
62
|
-
-
|
|
62
|
+
- Before it uses an idle keep-alive connection again, the client checks that the server did not close it (the idle timeout of the daemon is 60 s, and a proxy can have a shorter one). A closed one is replaced, so a write after a quiet time does not fail. A connection that drops during a request is sent again only for a read. A write is never sent twice.
|
|
63
63
|
- The pool is thread-safe and drops its connections after a `fork`.
|
|
64
64
|
|
|
65
65
|
## Collections
|
data/lib/ndb/client.rb
CHANGED
data/lib/ndb/connection.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "io/wait"
|
|
3
4
|
require "openssl"
|
|
4
5
|
require "socket"
|
|
5
6
|
require "uri"
|
|
@@ -110,6 +111,8 @@ module Ndb
|
|
|
110
111
|
# stream read waits longer than the default). A read timeout
|
|
111
112
|
# (IO::TimeoutError) raises Ndb::TimeoutError and is never sent again.
|
|
112
113
|
def request(method, target, body, headers: {}, idempotent: false, timeout: nil)
|
|
114
|
+
close if closed_by_server?
|
|
115
|
+
|
|
113
116
|
reused = !@socket.nil?
|
|
114
117
|
|
|
115
118
|
begin
|
|
@@ -171,6 +174,17 @@ module Ndb
|
|
|
171
174
|
|
|
172
175
|
private
|
|
173
176
|
|
|
177
|
+
# An idle keep-alive connection has nothing to read. When it is readable,
|
|
178
|
+
# the server closed it (the idle timeout of the daemon, a proxy): the
|
|
179
|
+
# next request opens a new one, so a write is never lost on it.
|
|
180
|
+
def closed_by_server?
|
|
181
|
+
return false unless @socket
|
|
182
|
+
|
|
183
|
+
@socket.to_io.wait_readable(0) ? true : false
|
|
184
|
+
rescue IOError, SystemCallError
|
|
185
|
+
true
|
|
186
|
+
end
|
|
187
|
+
|
|
174
188
|
def open_socket
|
|
175
189
|
@socket = @endpoint.connect(@timeout)
|
|
176
190
|
@socket.timeout = @timeout if @socket.respond_to?(:timeout=)
|
data/lib/ndb/version.rb
CHANGED