async-aws 0.0.1 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6bc119fed228b54ab55a83f186195c9fb28ebaaf04079f07be9d7b175cf99566
4
- data.tar.gz: 0d930ab3603a8cead12e282cd7659726567045f728c2bc7d9947a4c0fea7ec84
3
+ metadata.gz: e683070aa09b21e7398f22f30e2d99e8e2aadbf1cc91c465e8097dff22323056
4
+ data.tar.gz: 7bbbc5beadfc57d8d0aaaee36b9c67c070016e67e52abed0a71c00b61285c762
5
5
  SHA512:
6
- metadata.gz: d6c58e600851479de82dd5eba803c15f4a8be58b7c7aa5e69cb282c215a555c7c963e4f3d073052524b3225034208d42c8e193190267425055f567d9131c0bb7
7
- data.tar.gz: 1d67f05cf1577ca2f14a30691372fe326bd029d750ffc22f102c23290f96f7fd1a078a3b48e94d772dc6951c57d25c14a12bd5478fda81af33562d11449e691e
6
+ metadata.gz: 97652b664a9991837852cf9070861e0b0136baef7e03cbccf502e984554a310d54d52c05758ce507fcc1412444587644baeb3f77ad36d417345c0dd7c4dbd451
7
+ data.tar.gz: 223569a72176af151fbb747947d4194673335b2877fc92cb477d69272d82481803318c4624bdce87372f16fc0ad5b8452cec774e76ccd82f0599cf65c0db4617
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /*.gem
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
@@ -1,65 +1,74 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- async-aws (0.0.1)
5
- async-http (> 0.48)
4
+ async-aws (1.0.2)
5
+ async-http (~> 0.51)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- async (1.23.0)
10
+ async (1.24.2)
11
11
  console (~> 1.0)
12
12
  nio4r (~> 2.3)
13
13
  timers (~> 4.1)
14
- async-http (0.48.2)
15
- async (~> 1.19)
16
- async-io (~> 1.25)
17
- protocol-http (~> 0.12.0)
18
- protocol-http1 (~> 0.9.0)
19
- protocol-http2 (~> 0.9.0)
20
- async-io (1.27.0)
14
+ async-http (0.51.2)
15
+ async (~> 1.23)
16
+ async-io (~> 1.28)
17
+ async-pool (~> 0.2)
18
+ protocol-http (~> 0.18.0)
19
+ protocol-http1 (~> 0.12.0)
20
+ protocol-http2 (~> 0.13.0)
21
+ async-io (1.28.0)
21
22
  async (~> 1.14)
22
- aws-eventstream (1.0.3)
23
- aws-partitions (1.223.0)
24
- aws-sdk-core (3.68.1)
25
- aws-eventstream (~> 1.0, >= 1.0.2)
26
- aws-partitions (~> 1.0)
23
+ async-pool (0.2.0)
24
+ async (~> 1.8)
25
+ aws-eventstream (1.1.0)
26
+ aws-partitions (1.296.0)
27
+ aws-sdk-core (3.94.0)
28
+ aws-eventstream (~> 1, >= 1.0.2)
29
+ aws-partitions (~> 1, >= 1.239.0)
27
30
  aws-sigv4 (~> 1.1)
28
31
  jmespath (~> 1.0)
29
- aws-sdk-kms (1.24.0)
30
- aws-sdk-core (~> 3, >= 3.61.1)
32
+ aws-sdk-dynamodb (1.45.0)
33
+ aws-sdk-core (~> 3, >= 3.71.0)
34
+ aws-sigv4 (~> 1.1)
35
+ aws-sdk-kms (1.30.0)
36
+ aws-sdk-core (~> 3, >= 3.71.0)
31
37
  aws-sigv4 (~> 1.1)
32
- aws-sdk-s3 (1.50.0)
33
- aws-sdk-core (~> 3, >= 3.61.1)
38
+ aws-sdk-s3 (1.61.2)
39
+ aws-sdk-core (~> 3, >= 3.83.0)
34
40
  aws-sdk-kms (~> 1)
35
41
  aws-sigv4 (~> 1.1)
36
- aws-sigv4 (1.1.0)
42
+ aws-sdk-sqs (1.24.0)
43
+ aws-sdk-core (~> 3, >= 3.71.0)
44
+ aws-sigv4 (~> 1.1)
45
+ aws-sigv4 (1.1.1)
37
46
  aws-eventstream (~> 1.0, >= 1.0.2)
38
- console (1.5.0)
47
+ console (1.8.2)
39
48
  diff-lcs (1.3)
40
49
  jmespath (1.4.0)
41
50
  nio4r (2.5.2)
42
- protocol-hpack (1.4.1)
43
- protocol-http (0.12.3)
44
- protocol-http1 (0.9.0)
45
- protocol-http (~> 0.5)
46
- protocol-http2 (0.9.7)
51
+ protocol-hpack (1.4.2)
52
+ protocol-http (0.18.0)
53
+ protocol-http1 (0.12.0)
54
+ protocol-http (~> 0.18)
55
+ protocol-http2 (0.13.3)
47
56
  protocol-hpack (~> 1.4)
48
- protocol-http (~> 0.2)
49
- rake (10.5.0)
57
+ protocol-http (~> 0.18)
58
+ rake (13.0.1)
50
59
  rspec (3.9.0)
51
60
  rspec-core (~> 3.9.0)
52
61
  rspec-expectations (~> 3.9.0)
53
62
  rspec-mocks (~> 3.9.0)
54
- rspec-core (3.9.0)
55
- rspec-support (~> 3.9.0)
56
- rspec-expectations (3.9.0)
63
+ rspec-core (3.9.1)
64
+ rspec-support (~> 3.9.1)
65
+ rspec-expectations (3.9.1)
57
66
  diff-lcs (>= 1.2.0, < 2.0)
58
67
  rspec-support (~> 3.9.0)
59
- rspec-mocks (3.9.0)
68
+ rspec-mocks (3.9.1)
60
69
  diff-lcs (>= 1.2.0, < 2.0)
61
70
  rspec-support (~> 3.9.0)
62
- rspec-support (3.9.0)
71
+ rspec-support (3.9.2)
63
72
  timers (4.3.0)
64
73
 
65
74
  PLATFORMS
@@ -68,10 +77,12 @@ PLATFORMS
68
77
  DEPENDENCIES
69
78
  async
70
79
  async-aws!
80
+ aws-sdk-dynamodb
71
81
  aws-sdk-s3
82
+ aws-sdk-sqs
72
83
  bundler (~> 2.0)
73
- rake (~> 10.0)
84
+ rake (~> 13.0)
74
85
  rspec (~> 3.0)
75
86
 
76
87
  BUNDLED WITH
77
- 2.0.2
88
+ 2.1.2
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Async::Aws
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/async-aws.svg)](https://badge.fury.io/rb/async-aws)
4
+
3
5
  An experimental HTTP handler for AWS SDK Ruby powered by `socketry/async-http`.
4
6
 
5
7
  ## Installation
@@ -18,6 +20,13 @@ Or install it yourself as:
18
20
 
19
21
  $ gem install async-aws
20
22
 
23
+ ## Configuration
24
+ ```ruby
25
+ Async::Aws.configure(
26
+ connection_limit: 4 # Max number of connections per endpoint (passed to Async::HTTP::Client)
27
+ )
28
+ ```
29
+
21
30
  ## Usage
22
31
 
23
32
  ### Method 1
@@ -28,11 +28,13 @@ Gem::Specification.new do |spec|
28
28
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
29
  spec.require_paths = ["lib"]
30
30
 
31
- spec.add_dependency 'async-http', '> 0.48'
31
+ spec.add_dependency 'async-http', '~> 0.51'
32
32
 
33
33
  spec.add_development_dependency "bundler", "~> 2.0"
34
- spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "rake", "~> 13.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"
38
+ spec.add_development_dependency "aws-sdk-sqs"
37
39
  spec.add_development_dependency "async"
38
40
  end
@@ -1,5 +1,4 @@
1
1
  require 'async/http'
2
- require 'async/http/internet'
3
2
  require 'async/aws/http_handler'
4
3
  require 'async/aws/http_plugin'
5
4
 
@@ -7,12 +6,24 @@ module Async
7
6
  module Aws
8
7
  module_function
9
8
 
10
- def connection=(arg)
11
- @internet = ::Async::HTTP::Internet.new
9
+ def config
10
+ @config ||= {}
12
11
  end
13
12
 
14
- def connection
15
- @internet ||= ::Async::HTTP::Internet.new
13
+ def configure(**kwargs)
14
+ config.merge!(kwargs.slice(:connection_limit))
15
+ end
16
+
17
+ def set(key, value)
18
+ __send__("#{key}=".to_sym, value)
19
+ end
20
+
21
+ def connection_limit=(arg)
22
+ config[:connection_limit] = arg.to_i
23
+ end
24
+
25
+ def connection_limit
26
+ config.fetch(:connection_limit, 1)
16
27
  end
17
28
  end
18
29
  end
@@ -1,15 +1,44 @@
1
1
  module Async
2
2
  module Aws
3
3
  class HttpHandler < ::Seahorse::Client::Handler
4
+ def self.clients
5
+ @clients ||= {}
6
+ end
7
+
8
+ def self.endpoints
9
+ @endpoints ||= {}
10
+ end
11
+
12
+ def self.endpoint_for(url)
13
+ endpoints[url.to_s] ||= Async::HTTP::Endpoint.parse(url.to_s)
14
+ end
15
+
16
+ def self.client_for(endpoint)
17
+ clients[endpoint.hostname] ||= ::Async::HTTP::Client.new(
18
+ endpoint,
19
+ retries: 0,
20
+ connection_limit: Async::Aws.connection_limit
21
+ )
22
+ end
23
+
4
24
  def call(context)
5
25
  req = context.http_request
6
26
  resp = context.http_response
27
+ endpoint = self.class.endpoint_for(req.endpoint)
7
28
 
8
29
  begin
9
- headers = req.headers.reject { |k, v| k == 'host' }
10
- response = Async::Aws.connection.call(
11
- req.http_method, req.endpoint.to_s, headers.to_a, req.body
30
+ client = self.class.client_for(endpoint)
31
+ headers = ::Protocol::HTTP::Headers.new(
32
+ req.headers.reject do |k, v|
33
+ k == 'host' || k == 'content-length'
34
+ end
35
+ )
36
+ buffered_body = Async::HTTP::Body::Buffered.wrap(req.body.read)
37
+ request = ::Protocol::HTTP::Request.new(
38
+ client.scheme, endpoint.authority, req.http_method, endpoint.path,
39
+ nil, headers, buffered_body
12
40
  )
41
+ response = client.call(request)
13
42
  body = response.read
14
43
  resp.signal_headers(response.status.to_i, response.headers.to_h)
15
44
  resp.signal_data(body)
@@ -1,5 +1,5 @@
1
1
  module Async
2
2
  module Aws
3
- VERSION = '0.0.1'
3
+ VERSION = '1.0.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.2
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-20 00:00:00.000000000 Z
11
+ date: 2020-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-http
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">"
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.48'
19
+ version: '0.51'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">"
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.48'
26
+ version: '0.51'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +80,34 @@ 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'
97
+ - !ruby/object:Gem::Dependency
98
+ name: aws-sdk-sqs
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: async
85
113
  requirement: !ruby/object:Gem::Requirement
@@ -142,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
170
  - !ruby/object:Gem::Version
143
171
  version: '0'
144
172
  requirements: []
145
- rubygems_version: 3.0.3
173
+ rubygems_version: 3.1.2
146
174
  signing_key:
147
175
  specification_version: 4
148
176
  summary: Async AWS SDK adapter for `socketry/async` framework