async-http-faraday 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -4
- data/Gemfile +2 -1
- data/async-http-faraday.gemspec +2 -1
- data/examples/topics.rb +32 -0
- data/lib/async/http/faraday/adapter.rb +3 -3
- data/lib/async/http/faraday/version.rb +1 -1
- metadata +16 -16
- data/Rakefile +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c109996bf4e1ac263d36167d2f090404defde07adf3be7471f175f5bdd279d22
|
4
|
+
data.tar.gz: 7cdaaad412d469ac673dc85cf149ffdf7fcd593b859a2c891c23bde36c065e6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40b5496840bec8a74b60adfb807e84c1f863b1dd6719c6406018617d57c4c9313b45e492e88a2e2d224c15abf7c19b7fd5c0a7ed75280622193850942b0f86c0
|
7
|
+
data.tar.gz: 1d326fe89303b9e64ba5824d72d29bf063e5124a314238dce919c1ff75fb3f56926a633c00d2ce0d6f6fd5b656596febdb4e4670789593b8d9fd1e44395801b3
|
data/.travis.yml
CHANGED
@@ -2,18 +2,18 @@ language: ruby
|
|
2
2
|
dist: trusty
|
3
3
|
cache: bundler
|
4
4
|
|
5
|
+
script: bundle exec rspec
|
6
|
+
|
5
7
|
matrix:
|
6
8
|
include:
|
7
|
-
- rvm: 2.3
|
8
|
-
- rvm: 2.4
|
9
9
|
- rvm: 2.5
|
10
10
|
- rvm: 2.6
|
11
11
|
- rvm: 2.7
|
12
12
|
- rvm: jruby-head
|
13
13
|
env: JRUBY_OPTS="--debug -X+O"
|
14
|
+
- rvm: truffleruby
|
14
15
|
- rvm: ruby-head
|
15
|
-
- rvm: rbx-3
|
16
16
|
allow_failures:
|
17
17
|
- rvm: ruby-head
|
18
|
+
- rvm: truffleruby
|
18
19
|
- rvm: jruby-head
|
19
|
-
- rvm: rbx-3
|
data/Gemfile
CHANGED
data/async-http-faraday.gemspec
CHANGED
@@ -21,8 +21,9 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_development_dependency "async-rspec", "~> 1.2"
|
23
23
|
|
24
|
+
spec.add_development_dependency "bake-bundler"
|
25
|
+
|
24
26
|
spec.add_development_dependency "covered"
|
25
27
|
spec.add_development_dependency "bundler"
|
26
28
|
spec.add_development_dependency "rspec", "~> 3.6"
|
27
|
-
spec.add_development_dependency "rake"
|
28
29
|
end
|
data/examples/topics.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
|
4
|
+
|
5
|
+
require 'async'
|
6
|
+
require 'faraday'
|
7
|
+
require 'async/http/faraday'
|
8
|
+
|
9
|
+
# Async.logger.debug!
|
10
|
+
|
11
|
+
module TestAsync
|
12
|
+
URL = 'https://www.google.com/search'
|
13
|
+
TOPICS = %W{ruby python lisp javascript cobol}
|
14
|
+
|
15
|
+
def self.fetch_topics_async
|
16
|
+
TOPICS.map do |topic|
|
17
|
+
Async do
|
18
|
+
Faraday.get("#{URL}?q=#{topic}")
|
19
|
+
end
|
20
|
+
end.map(&:wait)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
Faraday.default_adapter = :async_http
|
25
|
+
|
26
|
+
Async do
|
27
|
+
pp TestAsync.fetch_topics_async
|
28
|
+
ensure
|
29
|
+
# This line is fairly essential if you intend to exit from the async block.
|
30
|
+
Faraday.default_connection.close
|
31
|
+
end
|
32
|
+
|
@@ -64,7 +64,7 @@ module Async
|
|
64
64
|
end
|
65
65
|
|
66
66
|
return @app.call(env)
|
67
|
-
rescue Errno::ETIMEDOUT => e
|
67
|
+
rescue Errno::ETIMEDOUT, Async::TimeoutError => e
|
68
68
|
raise ::Faraday::TimeoutError, e
|
69
69
|
rescue OpenSSL::SSL::SSLError => e
|
70
70
|
raise ::Faraday::SSLError, e
|
@@ -77,9 +77,9 @@ module Async
|
|
77
77
|
|
78
78
|
private
|
79
79
|
|
80
|
-
def with_timeout
|
80
|
+
def with_timeout(task: Async::Task.current)
|
81
81
|
if @timeout
|
82
|
-
|
82
|
+
task.with_timeout(@timeout, ::Faraday::TimeoutError) do
|
83
83
|
yield
|
84
84
|
end
|
85
85
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-http-faraday
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async-http
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: bake-bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: covered
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -81,33 +81,33 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '3.6'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '3.6'
|
111
111
|
description:
|
112
112
|
email:
|
113
113
|
- samuel.williams@oriontransfer.co.nz
|
@@ -121,8 +121,8 @@ files:
|
|
121
121
|
- ".travis.yml"
|
122
122
|
- Gemfile
|
123
123
|
- README.md
|
124
|
-
- Rakefile
|
125
124
|
- async-http-faraday.gemspec
|
125
|
+
- examples/topics.rb
|
126
126
|
- lib/async/http/faraday.rb
|
127
127
|
- lib/async/http/faraday/adapter.rb
|
128
128
|
- lib/async/http/faraday/version.rb
|
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
requirements: []
|
147
|
-
rubygems_version: 3.
|
147
|
+
rubygems_version: 3.1.2
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: Provides an adaptor between async-http and faraday.
|
data/Rakefile
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require "rspec/core/rake_task"
|
3
|
-
|
4
|
-
RSpec::Core::RakeTask.new(:test)
|
5
|
-
|
6
|
-
task :default => :test
|
7
|
-
|
8
|
-
task :server do
|
9
|
-
require 'async/reactor'
|
10
|
-
require 'async/http/server'
|
11
|
-
|
12
|
-
app = lambda do |env|
|
13
|
-
[200, {}, ["Hello World"]]
|
14
|
-
end
|
15
|
-
|
16
|
-
server = Async::HTTP::Server.new([
|
17
|
-
Async::IO::Endpoint.tcp('127.0.0.1', 9294, reuse_port: true)
|
18
|
-
], app)
|
19
|
-
|
20
|
-
Async::Reactor.run do
|
21
|
-
server.run
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
task :client do
|
26
|
-
require 'async/reactor'
|
27
|
-
require 'async/http/client'
|
28
|
-
|
29
|
-
client = Async::HTTP::Client.new([
|
30
|
-
Async::IO::Endpoint.tcp('127.0.0.1', 9294, reuse_port: true)
|
31
|
-
])
|
32
|
-
|
33
|
-
Async::Reactor.run do
|
34
|
-
response = client.get("/")
|
35
|
-
|
36
|
-
puts response.inspect
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
task :wrk do
|
41
|
-
require 'async/reactor'
|
42
|
-
require 'async/http/server'
|
43
|
-
|
44
|
-
app = lambda do |env|
|
45
|
-
[200, {}, ["Hello World"]]
|
46
|
-
end
|
47
|
-
|
48
|
-
server = Async::HTTP::Server.new([
|
49
|
-
Async::IO::Endpoint.tcp('127.0.0.1', 9294, reuse_port: true)
|
50
|
-
], app)
|
51
|
-
|
52
|
-
process_count = Etc.nprocessors
|
53
|
-
|
54
|
-
pids = process_count.times.collect do
|
55
|
-
fork do
|
56
|
-
Async::Reactor.run do
|
57
|
-
server.run
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
url = "http://127.0.0.1:9294/"
|
63
|
-
|
64
|
-
connections = process_count
|
65
|
-
system("wrk", "-c", connections.to_s, "-d", "2", "-t", connections.to_s, url)
|
66
|
-
|
67
|
-
pids.each do |pid|
|
68
|
-
Process.kill(:KILL, pid)
|
69
|
-
Process.wait pid
|
70
|
-
end
|
71
|
-
end
|