ezclient 1.5.0 → 1.5.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/lib/ezclient/persistent_client.rb +6 -2
- data/lib/ezclient/persistent_client_registry.rb +1 -3
- data/lib/ezclient/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: 9a7c441970d24a2206c3cd0f2f93ed5cbecb592ae8344d6a7ba449dd3d0b16f6
|
4
|
+
data.tar.gz: '049c93b96e988fc0e2898161e87ff1b8cadb6282c4deb2a88d34f00ffc2cccb0'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b5a1fb31992687e9bf84f10cc1bdd4fc34b84672ce7a3e6f097778f2e07a0b8516f7c82d8a55e655dd85a7cf24de6b92484c5d7c0165f2408bcf3309ce60808
|
7
|
+
data.tar.gz: e3a4e0dde38f1da48c7d18c330014e14275853cacd7e3b693ab58b5ac6735524a89d081c818f56def176a06bde8ba1714a2d0f5b4de24c4c3daac3792e59f396
|
@@ -5,8 +5,6 @@ class EzClient::PersistentClient
|
|
5
5
|
|
6
6
|
def_delegators :http_client, :build_request, :default_options, :timeout
|
7
7
|
|
8
|
-
attr_accessor :origin, :keep_alive_timeout, :last_request_at
|
9
|
-
|
10
8
|
def initialize(origin, keep_alive_timeout)
|
11
9
|
self.origin = origin
|
12
10
|
self.keep_alive_timeout = keep_alive_timeout
|
@@ -19,8 +17,14 @@ class EzClient::PersistentClient
|
|
19
17
|
end
|
20
18
|
end
|
21
19
|
|
20
|
+
def timed_out?
|
21
|
+
last_request_at && EzClient.get_time - last_request_at >= keep_alive_timeout
|
22
|
+
end
|
23
|
+
|
22
24
|
private
|
23
25
|
|
26
|
+
attr_accessor :origin, :keep_alive_timeout, :last_request_at
|
27
|
+
|
24
28
|
def http_client
|
25
29
|
@http_client ||= HTTP.persistent(origin, timeout: keep_alive_timeout)
|
26
30
|
end
|
@@ -16,8 +16,6 @@ class EzClient::PersistentClientRegistry
|
|
16
16
|
attr_accessor :registry
|
17
17
|
|
18
18
|
def cleanup_registry!
|
19
|
-
registry.delete_if
|
20
|
-
EzClient.get_time - value.last_request_at >= value.keep_alive_timeout
|
21
|
-
end
|
19
|
+
registry.delete_if { |_origin, client| client.timed_out? }
|
22
20
|
end
|
23
21
|
end
|
data/lib/ezclient/version.rb
CHANGED