async-rest 0.18.0 → 0.19.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/async/rest/version.rb +1 -1
- data/lib/async/rest/wrapper/generic.rb +29 -3
- data/readme.md +7 -0
- data.tar.gz.sig +1 -2
- metadata +5 -5
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae3aeb21790cedb9bbbe38afbf40b3d5990b28cb1a6eaf076495fab5a25a77e1
|
4
|
+
data.tar.gz: 4c8fd49d8c4be1fe367f62fe50231f527ad9fb440a8533d40e34e4bd15fe5c60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf1569c2fb59d7e216d3e677504e2b846cd3d47bf3411d55c5027c8cfb26334d3946996bb2e2c9e0180b2b040d543a6fa806a4af6e7952888387cce2f80b1dc2
|
7
|
+
data.tar.gz: 1fe580a38cc6a60d43943eb64ff28efddf32e3399b43c371fafeb7e6f6d39263bf66c45c2148742eaf628bfa5a6f123933859b2052f87b23c4e2e3b259a32737
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/async/rest/version.rb
CHANGED
@@ -7,12 +7,36 @@ module Async
|
|
7
7
|
module REST
|
8
8
|
module Wrapper
|
9
9
|
class Generic
|
10
|
+
def retry_after_duration(value)
|
11
|
+
retry_after_time = Time.httpdate(value)
|
12
|
+
return [retry_after_time - Time.now, 0].max
|
13
|
+
rescue ArgumentError
|
14
|
+
return value.to_f
|
15
|
+
end
|
16
|
+
|
17
|
+
def response_for(resource, request)
|
18
|
+
while true
|
19
|
+
response = resource.call(request)
|
20
|
+
|
21
|
+
if response.status == 429
|
22
|
+
if retry_after = response.headers["retry-after"]
|
23
|
+
sleep(retry_after_duration(retry_after))
|
24
|
+
else
|
25
|
+
# Without the `retry-after` header, we can't determine how long to wait, so we just return the response.
|
26
|
+
return response
|
27
|
+
end
|
28
|
+
else
|
29
|
+
return response
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
10
34
|
def call(resource, method = "GET", payload = nil, &block)
|
11
35
|
request = ::Protocol::HTTP::Request[method, nil]
|
12
36
|
|
13
37
|
self.prepare_request(request, payload)
|
14
38
|
|
15
|
-
response =
|
39
|
+
response = self.response_for(resource, request)
|
16
40
|
|
17
41
|
# If we exit this block because of an exception, we close the response. This ensures we don't have any dangling connections.
|
18
42
|
begin
|
@@ -42,13 +66,15 @@ module Async
|
|
42
66
|
|
43
67
|
def parser_for(response)
|
44
68
|
# It's not always clear why this error is being thrown.
|
45
|
-
return
|
69
|
+
return nil
|
46
70
|
end
|
47
71
|
|
48
72
|
# Wrap the response body in the given klass.
|
49
73
|
def wrap_response(response)
|
50
74
|
if body = response.body
|
51
|
-
|
75
|
+
if parser = parser_for(response)
|
76
|
+
response.body = parser.new(body)
|
77
|
+
end
|
52
78
|
end
|
53
79
|
|
54
80
|
return response
|
data/readme.md
CHANGED
@@ -15,6 +15,13 @@ Please see the [project documentation](https://socketry.github.io/async-rest/) f
|
|
15
15
|
|
16
16
|
- [Getting Started](https://socketry.github.io/async-rest/guides/getting-started/index) - This guide explains the design of the `async-rest` gem and how to use it to access RESTful APIs.
|
17
17
|
|
18
|
+
## See Also
|
19
|
+
|
20
|
+
- [async-ollama](https://github.com/socketry/async-ollama) - A client for Ollama, a local large language model server.
|
21
|
+
- [async-discord](https://github.com/socketry/async-discord) - A client for Discord, a popular chat platform.
|
22
|
+
- [cloudflare](https://github.com/socketry/cloudflare) - A client for Cloudflare, a popular CDN and DDoS protection service.
|
23
|
+
- [async-slack](https://github.com/socketry/async-slack) - A client for Slack, a popular chat platform.
|
24
|
+
|
18
25
|
## Contributing
|
19
26
|
|
20
27
|
We welcome contributions to this project.
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
��CD�(�ceR!��y��h$��t2��Ut�QS��i!��;k���z�G��h,C�A�$��̂�Cvq��s�r�1���R�)��,8-8x�o�5��Em����@pr���N)�d�ӗ$�Ioo*�3��^?��(xP�.OF*����*E�Y��5Gg�����ŕ5�$;n�oj�m��@O.A@ə�
|
1
|
+
~�7�t�O�<�����q3i��$m�M �����0i�ktL���б&�544��� ���E��S\����Vhbm����ڨ� =h1�[�m���CD��J4�5��c|07|�Њ��mJ\�.Ħ����Sܑ�����ə�s7�o�2�v��6�˿�Y�Rz`��7��us�?�_^Z���k�����VG�����1~Wk���[W�@�<
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -40,7 +40,7 @@ cert_chain:
|
|
40
40
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
41
41
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
42
42
|
-----END CERTIFICATE-----
|
43
|
-
date: 2024-
|
43
|
+
date: 2024-11-26 00:00:00.000000000 Z
|
44
44
|
dependencies:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: async-http
|
@@ -62,14 +62,14 @@ dependencies:
|
|
62
62
|
requirements:
|
63
63
|
- - "~>"
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version: '0.
|
65
|
+
version: '0.45'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
68
|
version_requirements: !ruby/object:Gem::Requirement
|
69
69
|
requirements:
|
70
70
|
- - "~>"
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version: '0.
|
72
|
+
version: '0.45'
|
73
73
|
description:
|
74
74
|
email:
|
75
75
|
executables: []
|
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
|
-
rubygems_version: 3.5.
|
111
|
+
rubygems_version: 3.5.22
|
112
112
|
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: A library for RESTful clients (and hopefully servers).
|
metadata.gz.sig
CHANGED
Binary file
|