async-aws 0.0.1 → 0.1.0
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/.gitignore +1 -0
- data/Gemfile.lock +5 -1
- data/async-aws.gemspec +1 -0
- data/lib/async/aws.rb +5 -4
- data/lib/async/aws/connection_pool.rb +35 -0
- data/lib/async/aws/http_handler.rb +5 -3
- data/lib/async/aws/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f66e1b7e1b1178fd52c4e335d59b1a80bbe4e6bf56cfd0fec68159637d14de3
|
4
|
+
data.tar.gz: f5157db3e501d22ed4fa6b67b76a26e43c374043d78beb06e71dfc4addc101eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf165148969134b4be3c89512dd6747533d16283c425c33bba13217630b8693b672816e90d4823aeb242201a3b5b311f6cb4f60da1044dae87989c16f2b9ec0b
|
7
|
+
data.tar.gz: f5a363af14e10d7cb6c2d3e2da88c44a24cf0d6a8495d77c046ade4b02053d3269cffddb0dc9d56d912631f8e178d11ca407d1f86d743da0af9daaa893601f9c
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
async-aws (0.0
|
4
|
+
async-aws (0.1.0)
|
5
5
|
async-http (> 0.48)
|
6
6
|
|
7
7
|
GEM
|
@@ -26,6 +26,9 @@ GEM
|
|
26
26
|
aws-partitions (~> 1.0)
|
27
27
|
aws-sigv4 (~> 1.1)
|
28
28
|
jmespath (~> 1.0)
|
29
|
+
aws-sdk-dynamodb (1.36.0)
|
30
|
+
aws-sdk-core (~> 3, >= 3.61.1)
|
31
|
+
aws-sigv4 (~> 1.1)
|
29
32
|
aws-sdk-kms (1.24.0)
|
30
33
|
aws-sdk-core (~> 3, >= 3.61.1)
|
31
34
|
aws-sigv4 (~> 1.1)
|
@@ -68,6 +71,7 @@ PLATFORMS
|
|
68
71
|
DEPENDENCIES
|
69
72
|
async
|
70
73
|
async-aws!
|
74
|
+
aws-sdk-dynamodb
|
71
75
|
aws-sdk-s3
|
72
76
|
bundler (~> 2.0)
|
73
77
|
rake (~> 10.0)
|
data/async-aws.gemspec
CHANGED
@@ -34,5 +34,6 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_development_dependency "rake", "~> 10.0"
|
35
35
|
spec.add_development_dependency "rspec", "~> 3.0"
|
36
36
|
spec.add_development_dependency "aws-sdk-s3"
|
37
|
+
spec.add_development_dependency "aws-sdk-dynamodb"
|
37
38
|
spec.add_development_dependency "async"
|
38
39
|
end
|
data/lib/async/aws.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'async/http'
|
2
2
|
require 'async/http/internet'
|
3
|
+
require 'async/aws/connection_pool'
|
3
4
|
require 'async/aws/http_handler'
|
4
5
|
require 'async/aws/http_plugin'
|
5
6
|
|
@@ -7,12 +8,12 @@ module Async
|
|
7
8
|
module Aws
|
8
9
|
module_function
|
9
10
|
|
10
|
-
def
|
11
|
-
@
|
11
|
+
def connection_pool=(arg)
|
12
|
+
@connection_pool = arg
|
12
13
|
end
|
13
14
|
|
14
|
-
def
|
15
|
-
@
|
15
|
+
def connection_pool
|
16
|
+
@connection_pool ||= ConnectionPool.new
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Async
|
2
|
+
module Aws
|
3
|
+
class ConnectionPool
|
4
|
+
def initialize(connection_limit: nil)
|
5
|
+
@clients = {}
|
6
|
+
@connection_limit = connection_limit
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(method, url, headers = [], body = nil)
|
10
|
+
endpoint = ::Async::HTTP::Endpoint.parse(url)
|
11
|
+
client = client_for(endpoint)
|
12
|
+
|
13
|
+
request_body = ::Async::HTTP::Body::Buffered.wrap(body)
|
14
|
+
request = ::Protocol::HTTP::Request.new(
|
15
|
+
endpoint.scheme, endpoint.authority, method, endpoint.path, nil, headers,
|
16
|
+
request_body
|
17
|
+
)
|
18
|
+
|
19
|
+
client.call(request)
|
20
|
+
end
|
21
|
+
|
22
|
+
def client_for(endpoint)
|
23
|
+
@clients[endpoint] ||= ::Async::HTTP::Client.new(
|
24
|
+
endpoint, endpoint.protocol, endpoint.scheme, endpoint.authority,
|
25
|
+
retries: 3, connection_limit: @connection_limit
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
def close
|
30
|
+
@clients.each_value(&:close)
|
31
|
+
@clients.clear
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -6,9 +6,11 @@ module Async
|
|
6
6
|
resp = context.http_response
|
7
7
|
|
8
8
|
begin
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
headers_arr = req.headers.reject do |k, v|
|
10
|
+
k == 'host' || k == 'content-length'
|
11
|
+
end
|
12
|
+
response = Async::Aws.connection_pool.call(
|
13
|
+
req.http_method, req.endpoint.to_s, headers_arr, req.body
|
12
14
|
)
|
13
15
|
body = response.read
|
14
16
|
resp.signal_headers(response.status.to_i, response.headers.to_h)
|
data/lib/async/aws/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julien D.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async-http
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: aws-sdk-dynamodb
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: async
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,6 +130,7 @@ files:
|
|
116
130
|
- lib/async-aws.rb
|
117
131
|
- lib/async/aws.rb
|
118
132
|
- lib/async/aws/all.rb
|
133
|
+
- lib/async/aws/connection_pool.rb
|
119
134
|
- lib/async/aws/http_handler.rb
|
120
135
|
- lib/async/aws/http_plugin.rb
|
121
136
|
- lib/async/aws/version.rb
|