onyxcord 3.2.6 → 3.2.7
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/onyxcord/core/version.rb +1 -1
- data/lib/onyxcord/internal/http.rb +25 -8
- data/lib/onyxcord/rest/client.rb +1 -0
- 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: 11790e2e347a44d298323d5f3fe9d01bda9a0c087a53452440d2bcaa80e141ec
|
|
4
|
+
data.tar.gz: aced6ea00fc6a5909654524c0c24c8ba9e50200a90528d4efdb20cd238ac4a98
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a920b096a309c8ffd55af075dcd1e65321e107556d4559855f6cc3663c35a2f90c38baab65add1f623fc0bbdfd59e7f8f1d5574ac08c4dfeaad3218b0a34410d
|
|
7
|
+
data.tar.gz: 458f16d158eddb9b038ef2f3b03fe08e6477e49832508a3328d560d09664fd3081f33fca923119173d0824019e700c84702f15546303936e989247fdd235d569
|
|
@@ -54,19 +54,36 @@ module OnyxCord
|
|
|
54
54
|
|
|
55
55
|
module_function
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
POOL_OPTIONS = {
|
|
58
|
+
max_connections: 50,
|
|
59
|
+
max_connections_per_origin: 20,
|
|
60
|
+
pool_timeout: 10
|
|
61
|
+
}.freeze
|
|
62
|
+
|
|
63
|
+
# The shared HTTPX session with persistent, pooled connections.
|
|
58
64
|
def session
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
session_mutex.synchronize do
|
|
66
|
+
@session ||= HTTPX.plugin(:persistent)
|
|
67
|
+
.plugin(:follow_redirects)
|
|
68
|
+
.with(
|
|
69
|
+
fallback_protocol: 'http/1.1',
|
|
70
|
+
ssl: { alpn_protocols: ['http/1.1'] },
|
|
71
|
+
pool_options: POOL_OPTIONS
|
|
72
|
+
)
|
|
73
|
+
end
|
|
65
74
|
end
|
|
66
75
|
|
|
67
76
|
# Reset the HTTP session (useful for tests).
|
|
68
77
|
def reset!
|
|
69
|
-
|
|
78
|
+
session_mutex.synchronize do
|
|
79
|
+
@session&.close if @session.respond_to?(:close)
|
|
80
|
+
ensure
|
|
81
|
+
@session = nil
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def session_mutex
|
|
86
|
+
@session_mutex ||= Mutex.new
|
|
70
87
|
end
|
|
71
88
|
|
|
72
89
|
# Perform a raw HTTP request and return a {Response}.
|
data/lib/onyxcord/rest/client.rb
CHANGED
|
@@ -172,6 +172,7 @@ module OnyxCord::REST
|
|
|
172
172
|
retries += 1
|
|
173
173
|
raise unless retries < max_retries
|
|
174
174
|
|
|
175
|
+
::OnyxCord::Internal::HTTP.reset!
|
|
175
176
|
OnyxCord::LOGGER.warn("Temporary HTTP failure while sending request (#{e.class}), retrying")
|
|
176
177
|
OnyxCord::Internal::AsyncRuntime.sleep(retries * 0.5)
|
|
177
178
|
next
|