async-aws 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +84 -0
- data/LICENSE.txt +21 -0
- data/README.md +51 -0
- data/Rakefile +6 -0
- data/async-aws.gemspec +39 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/async-aws.rb +1 -0
- data/lib/async/aws.rb +31 -0
- data/lib/async/aws/all.rb +8 -0
- data/lib/async/aws/http_client.rb +102 -0
- data/lib/async/aws/http_handler.rb +72 -0
- data/lib/async/aws/http_plugin.rb +9 -0
- data/lib/async/aws/version.rb +5 -0
- metadata +164 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d4b4634f5e07b319d4e20f927f524e59fea4236693fc38a57d914cba8e616fc8
|
4
|
+
data.tar.gz: 57868e373bbe1137a4f5a0fd38f6727f72eb895ce1a732910e3d5debec1e18b0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9acbd7be0847428db25bdc766c184d2c10eb9bd5c6facb72b266389bdcc7d276bf07e99da04cfd959d6522ce1aecf247707061d3b8b1b8f537aacd38b093f01e
|
7
|
+
data.tar.gz: 72f1485b45e5d2b8cd8be02f5ad96dc7161fd8b94e0e4989a95fcd8786e7fc63dd460533ebb1cc88dc2923ca52320dac6ae5030c643b28cb845b3aababecd5dd
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at julien@unitylab.io. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
async-aws (0.3.0)
|
5
|
+
async-http (~> 0.48)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
async (1.23.0)
|
11
|
+
console (~> 1.0)
|
12
|
+
nio4r (~> 2.3)
|
13
|
+
timers (~> 4.1)
|
14
|
+
async-http (0.50.0)
|
15
|
+
async (~> 1.23)
|
16
|
+
async-io (~> 1.27.0)
|
17
|
+
async-pool (~> 0.2)
|
18
|
+
protocol-http (~> 0.13.0)
|
19
|
+
protocol-http1 (~> 0.10.0)
|
20
|
+
protocol-http2 (~> 0.10.0)
|
21
|
+
async-io (1.27.1)
|
22
|
+
async (~> 1.14)
|
23
|
+
async-pool (0.2.0)
|
24
|
+
async (~> 1.8)
|
25
|
+
aws-eventstream (1.0.3)
|
26
|
+
aws-partitions (1.223.0)
|
27
|
+
aws-sdk-core (3.68.1)
|
28
|
+
aws-eventstream (~> 1.0, >= 1.0.2)
|
29
|
+
aws-partitions (~> 1.0)
|
30
|
+
aws-sigv4 (~> 1.1)
|
31
|
+
jmespath (~> 1.0)
|
32
|
+
aws-sdk-dynamodb (1.36.0)
|
33
|
+
aws-sdk-core (~> 3, >= 3.61.1)
|
34
|
+
aws-sigv4 (~> 1.1)
|
35
|
+
aws-sdk-kms (1.24.0)
|
36
|
+
aws-sdk-core (~> 3, >= 3.61.1)
|
37
|
+
aws-sigv4 (~> 1.1)
|
38
|
+
aws-sdk-s3 (1.50.0)
|
39
|
+
aws-sdk-core (~> 3, >= 3.61.1)
|
40
|
+
aws-sdk-kms (~> 1)
|
41
|
+
aws-sigv4 (~> 1.1)
|
42
|
+
aws-sigv4 (1.1.0)
|
43
|
+
aws-eventstream (~> 1.0, >= 1.0.2)
|
44
|
+
console (1.5.0)
|
45
|
+
diff-lcs (1.3)
|
46
|
+
jmespath (1.4.0)
|
47
|
+
nio4r (2.5.2)
|
48
|
+
protocol-hpack (1.4.1)
|
49
|
+
protocol-http (0.13.0)
|
50
|
+
protocol-http1 (0.10.0)
|
51
|
+
protocol-http (~> 0.13)
|
52
|
+
protocol-http2 (0.10.4)
|
53
|
+
protocol-hpack (~> 1.4)
|
54
|
+
protocol-http (~> 0.2)
|
55
|
+
rake (10.5.0)
|
56
|
+
rspec (3.9.0)
|
57
|
+
rspec-core (~> 3.9.0)
|
58
|
+
rspec-expectations (~> 3.9.0)
|
59
|
+
rspec-mocks (~> 3.9.0)
|
60
|
+
rspec-core (3.9.0)
|
61
|
+
rspec-support (~> 3.9.0)
|
62
|
+
rspec-expectations (3.9.0)
|
63
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
64
|
+
rspec-support (~> 3.9.0)
|
65
|
+
rspec-mocks (3.9.0)
|
66
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
67
|
+
rspec-support (~> 3.9.0)
|
68
|
+
rspec-support (3.9.0)
|
69
|
+
timers (4.3.0)
|
70
|
+
|
71
|
+
PLATFORMS
|
72
|
+
ruby
|
73
|
+
|
74
|
+
DEPENDENCIES
|
75
|
+
async
|
76
|
+
async-aws!
|
77
|
+
aws-sdk-dynamodb
|
78
|
+
aws-sdk-s3
|
79
|
+
bundler (~> 2.0)
|
80
|
+
rake (~> 10.0)
|
81
|
+
rspec (~> 3.0)
|
82
|
+
|
83
|
+
BUNDLED WITH
|
84
|
+
2.1.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Julien D.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Async::Aws
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/async-aws.svg)](https://badge.fury.io/rb/async-aws)
|
4
|
+
|
5
|
+
An experimental HTTP handler for AWS SDK Ruby powered by `socketry/async-http`.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'async-aws'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install async-aws
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
### Method 1
|
26
|
+
Simply require `async/aws/all` after requiring all your `aws-sdk-*` gem. It will automatically add `Async::Aws::HttpPlugin` to all `aws-sdk-*` clients.
|
27
|
+
|
28
|
+
### Method 2
|
29
|
+
Add `Async::Aws::HttpPlugin` to your `Aws::*::Client` classes.
|
30
|
+
Example:
|
31
|
+
```ruby
|
32
|
+
Aws::S3::Client.add_plugin(Async::Aws::HttpPlugin)
|
33
|
+
```
|
34
|
+
|
35
|
+
## Development
|
36
|
+
|
37
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
38
|
+
|
39
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/runslash/async-aws-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
44
|
+
|
45
|
+
## License
|
46
|
+
|
47
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
48
|
+
|
49
|
+
## Code of Conduct
|
50
|
+
|
51
|
+
Everyone interacting in the Async::Aws project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/runslash/async-aws-ruby/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/async-aws.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "async/aws/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "async-aws"
|
7
|
+
spec.version = Async::Aws::VERSION
|
8
|
+
spec.authors = ["Julien D."]
|
9
|
+
spec.email = ["julien@unitylab.io"]
|
10
|
+
|
11
|
+
spec.summary = %q{Async AWS SDK adapter for `socketry/async` framework}
|
12
|
+
spec.description = %q{An Async AWS SDK adapter for `socketry/async` framework}
|
13
|
+
spec.homepage = 'https://github.com/runslash/async-aws-ruby'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.metadata["allowed_push_host"] = 'https://rubygems.org'
|
17
|
+
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
spec.metadata["source_code_uri"] = 'https://github.com/runslash/async-aws-ruby'
|
20
|
+
spec.metadata["changelog_uri"] = 'https://github.com/runslash/async-aws-ruby'
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
end
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
spec.add_dependency 'async-http', '~> 0.48'
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
36
|
+
spec.add_development_dependency "aws-sdk-s3"
|
37
|
+
spec.add_development_dependency "aws-sdk-dynamodb"
|
38
|
+
spec.add_development_dependency "async"
|
39
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require 'aws-sdk-s3'
|
5
|
+
require 'async/aws/all'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/async-aws.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'async/aws'
|
data/lib/async/aws.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'async/http'
|
2
|
+
require 'async/http/internet'
|
3
|
+
require 'async/aws/http_client'
|
4
|
+
require 'async/aws/http_handler'
|
5
|
+
require 'async/aws/http_plugin'
|
6
|
+
|
7
|
+
module Async
|
8
|
+
module Aws
|
9
|
+
module_function
|
10
|
+
|
11
|
+
def keep_alive_timeout=(arg)
|
12
|
+
@keep_alive_timeout = arg.to_i
|
13
|
+
end
|
14
|
+
|
15
|
+
def keep_alive_timeout
|
16
|
+
@keep_alive_timeout || 2
|
17
|
+
end
|
18
|
+
|
19
|
+
def connection_pool_size=(arg)
|
20
|
+
@connection_pool_size = arg.to_i
|
21
|
+
end
|
22
|
+
|
23
|
+
def connection_pool_size
|
24
|
+
@connection_pool_size || 1
|
25
|
+
end
|
26
|
+
|
27
|
+
def configure(&block)
|
28
|
+
instance_exec(&block)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'async/io/endpoint'
|
4
|
+
require 'async/io/stream'
|
5
|
+
require 'protocol/http/body/streamable'
|
6
|
+
require 'protocol/http/methods'
|
7
|
+
|
8
|
+
module Async
|
9
|
+
module Aws
|
10
|
+
class HttpClient < ::Protocol::HTTP::Methods
|
11
|
+
attr_accessor :keep_alive_timeout
|
12
|
+
attr_reader :scheme
|
13
|
+
|
14
|
+
ConnectionSpec = Struct.new(:connection, :used_at)
|
15
|
+
|
16
|
+
# Provides a robust interface to a server.
|
17
|
+
# * If there are no connections, it will create one.
|
18
|
+
# * If there are already connections, it will reuse it.
|
19
|
+
# * If a request fails, it will retry it up to N times if it was idempotent.
|
20
|
+
# The client object will never become unusable. It internally manages persistent connections (or non-persistent connections if that's required).
|
21
|
+
# @param endpoint [Endpoint] the endpoint to connnect to.
|
22
|
+
# @param protocol [Protocol::HTTP1 | Protocol::HTTP2 | Protocol::HTTPS] the protocol to use.
|
23
|
+
# @param scheme [String] The default scheme to set to requests.
|
24
|
+
# @param authority [String] The default authority to set to requests.
|
25
|
+
def initialize(endpoint, pool_size: 2, keep_alive_timeout: 5)
|
26
|
+
@endpoint = endpoint
|
27
|
+
@protocol = endpoint.protocol
|
28
|
+
@scheme = endpoint.scheme
|
29
|
+
@authority = endpoint.authority
|
30
|
+
@keep_alive_timeout = keep_alive_timeout
|
31
|
+
@clock_gettime_constant = \
|
32
|
+
if defined?(Process::CLOCK_MONOTONIC)
|
33
|
+
Process::CLOCK_MONOTONIC
|
34
|
+
else
|
35
|
+
Process::CLOCK_REALTIME
|
36
|
+
end
|
37
|
+
@pool = make_pool(pool_size)
|
38
|
+
end
|
39
|
+
|
40
|
+
def close
|
41
|
+
until @pool.empty?
|
42
|
+
connection_spec = @pool.dequeue
|
43
|
+
connection_spec.connection.close
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def call(request)
|
48
|
+
request.scheme ||= self.scheme
|
49
|
+
request.authority ||= self.authority
|
50
|
+
|
51
|
+
attempt = 0
|
52
|
+
|
53
|
+
# We may retry the request if it is possible to do so. https://tools.ietf.org/html/draft-nottingham-httpbis-retry-01 is a good guide for how retrying requests should work.
|
54
|
+
begin
|
55
|
+
attempt += 1
|
56
|
+
|
57
|
+
# As we cache pool, it's possible these pool go bad (e.g. closed by remote host). In this case, we need to try again. It's up to the caller to impose a timeout on this. If this is the last attempt, we force a new connection.
|
58
|
+
connection_spec = @pool.dequeue
|
59
|
+
if connection_spec.used_at + keep_alive_timeout <= current_time
|
60
|
+
connection_spec.connection.close
|
61
|
+
connection_spec = create_connection_spec
|
62
|
+
end
|
63
|
+
|
64
|
+
# send request
|
65
|
+
response = request.call(connection_spec.connection)
|
66
|
+
|
67
|
+
# The connection won't be released until the body is completely read/released.
|
68
|
+
::Protocol::HTTP::Body::Streamable.wrap(response) do
|
69
|
+
connection_spec.used_at = current_time
|
70
|
+
@pool << connection_spec
|
71
|
+
end
|
72
|
+
|
73
|
+
return response
|
74
|
+
rescue => e
|
75
|
+
@pool << connection_spec if connection_spec
|
76
|
+
raise e
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def current_time
|
83
|
+
Process.clock_gettime(@clock_gettime_constant)
|
84
|
+
end
|
85
|
+
|
86
|
+
def create_connection_spec
|
87
|
+
ConnectionSpec.new(
|
88
|
+
@protocol.client(@endpoint.connect),
|
89
|
+
current_time
|
90
|
+
)
|
91
|
+
end
|
92
|
+
|
93
|
+
def make_pool(size)
|
94
|
+
Async::Queue.new.tap do |queue|
|
95
|
+
size.times do
|
96
|
+
queue << create_connection_spec
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Async
|
2
|
+
module Aws
|
3
|
+
class HttpHandler < ::Seahorse::Client::Handler
|
4
|
+
def self.clients
|
5
|
+
@clients ||= {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.with_configuration(**kwargs)
|
9
|
+
Class.new(self).tap do |klass|
|
10
|
+
klass.connection_pool_size = kwargs.fetch(
|
11
|
+
:connection_pool_size, Async::Aws.connection_pool_size
|
12
|
+
)
|
13
|
+
klass.keep_alive_timeout = kwargs.fetch(
|
14
|
+
:keep_alive_timeout, Async::Aws.keep_alive_timeout
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.connection_pool_size
|
20
|
+
@connection_pool_size ||= Async::Aws.connection_pool_size
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.connection_pool_size=(value)
|
24
|
+
@connection_pool_size = value.to_i
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.keep_alive_timeout
|
28
|
+
@keep_alive_timeout ||= Async::Aws.keep_alive_timeout
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.keep_alive_timeout=(value)
|
32
|
+
@keep_alive_timeout = value.to_i
|
33
|
+
end
|
34
|
+
|
35
|
+
def call(context)
|
36
|
+
req = context.http_request
|
37
|
+
resp = context.http_response
|
38
|
+
endpoint = Async::HTTP::Endpoint.parse(req.endpoint.to_s)
|
39
|
+
|
40
|
+
begin
|
41
|
+
client = client_for(endpoint)
|
42
|
+
headers_arr = req.headers.reject do |k, v|
|
43
|
+
k == 'host' || k == 'content-length'
|
44
|
+
end
|
45
|
+
buffered_body = Async::HTTP::Body::Buffered.wrap(req.body)
|
46
|
+
request = ::Protocol::HTTP::Request.new(
|
47
|
+
client.scheme, endpoint.authority, req.http_method, endpoint.path,
|
48
|
+
nil, headers_arr, buffered_body
|
49
|
+
)
|
50
|
+
response = client.call(request)
|
51
|
+
body = response.read
|
52
|
+
resp.signal_headers(response.status.to_i, response.headers.to_h)
|
53
|
+
resp.signal_data(body)
|
54
|
+
resp.signal_done
|
55
|
+
rescue => error
|
56
|
+
# not retried
|
57
|
+
resp.signal_error(error)
|
58
|
+
end
|
59
|
+
|
60
|
+
Seahorse::Client::Response.new(context: context)
|
61
|
+
end
|
62
|
+
|
63
|
+
def client_for(endpoint)
|
64
|
+
self.class.clients[endpoint.hostname] ||= ::Async::Aws::HttpClient.new(
|
65
|
+
endpoint,
|
66
|
+
pool_size: self.class.connection_pool_size,
|
67
|
+
keep_alive_timeout: self.class.keep_alive_timeout
|
68
|
+
)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
metadata
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: async-aws
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Julien D.
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-01-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: async-http
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.48'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.48'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: aws-sdk-s3
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
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: async
|
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'
|
111
|
+
description: An Async AWS SDK adapter for `socketry/async` framework
|
112
|
+
email:
|
113
|
+
- julien@unitylab.io
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
|
+
- ".travis.yml"
|
121
|
+
- CODE_OF_CONDUCT.md
|
122
|
+
- Gemfile
|
123
|
+
- Gemfile.lock
|
124
|
+
- LICENSE.txt
|
125
|
+
- README.md
|
126
|
+
- Rakefile
|
127
|
+
- async-aws.gemspec
|
128
|
+
- bin/console
|
129
|
+
- bin/setup
|
130
|
+
- lib/async-aws.rb
|
131
|
+
- lib/async/aws.rb
|
132
|
+
- lib/async/aws/all.rb
|
133
|
+
- lib/async/aws/http_client.rb
|
134
|
+
- lib/async/aws/http_handler.rb
|
135
|
+
- lib/async/aws/http_plugin.rb
|
136
|
+
- lib/async/aws/version.rb
|
137
|
+
homepage: https://github.com/runslash/async-aws-ruby
|
138
|
+
licenses:
|
139
|
+
- MIT
|
140
|
+
metadata:
|
141
|
+
allowed_push_host: https://rubygems.org
|
142
|
+
homepage_uri: https://github.com/runslash/async-aws-ruby
|
143
|
+
source_code_uri: https://github.com/runslash/async-aws-ruby
|
144
|
+
changelog_uri: https://github.com/runslash/async-aws-ruby
|
145
|
+
post_install_message:
|
146
|
+
rdoc_options: []
|
147
|
+
require_paths:
|
148
|
+
- lib
|
149
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
requirements: []
|
160
|
+
rubygems_version: 3.1.2
|
161
|
+
signing_key:
|
162
|
+
specification_version: 4
|
163
|
+
summary: Async AWS SDK adapter for `socketry/async` framework
|
164
|
+
test_files: []
|