faraday-em_http 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8982a4cb78e29659a4903e779305b1d8b949991b60bd5fc9c39f3d9caaa4bcc3
4
- data.tar.gz: 65343a1e259389675dc9ef4c5b50772e7a87ad8bbaa601b7433f8697154e9a78
3
+ metadata.gz: bb65fc68b58f91230367a9acabc7a32aebac2e44d8093028fde43558982744d5
4
+ data.tar.gz: 739a5c48c024278fdff36f801a9f22d8bbabac857b11c1b81658551ee274a01e
5
5
  SHA512:
6
- metadata.gz: da88bf5433fef291af85674490b017c8f6356030304a37e6156c2409d776b9e0712a05fe13656029bf400bef0404239d6132a964bdc85a2097321b4051a96494
7
- data.tar.gz: ff7dc9115defddc26448b5dce034c56e7abf33375987a4083dd7bdb1f5fab6d0dc1d0e4b24884681cb1d03207717e83692ca2f0d106f5f16656211748750c1f7
6
+ metadata.gz: 3e4bbc4fc8c1038b1be1ea49e23acc2897bbe027c281608a9880e4d3ffd766032920df06affb512efaa16fa75e6a68e4290bbdcab6d79e5e8cb39f95df89afc9
7
+ data.tar.gz: 8ec7a7a2ba1b0d2339e56ec40d548634dfff2153d76324deae2c3947e5e77960ee9fa9113421c5fb97f573372d881b02a5fc5dbf177f5c59994e754fd2dd8717
data/README.md CHANGED
@@ -9,7 +9,6 @@ Every adapter is defined into its own gem. This gem defines the adapter for Em::
9
9
  Add these lines to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'em-http-request', '>= 1.1'
13
12
  gem 'faraday-em_http'
14
13
  ```
15
14
 
@@ -19,20 +18,53 @@ And then execute:
19
18
 
20
19
  Or install them yourself as:
21
20
 
22
- $ gem install em-http-request -v '>= 1.1'
23
21
  $ gem install faraday-em_http
24
22
 
25
23
  ## Usage
26
24
 
27
- Configure your Faraday connection to use this adapter like this:
25
+ This adapter can be used to make parallel requests using EventMachine.
26
+
27
+ The major difference between this and [Faraday Em::Synchrony adapter](https://github.com/lostisland/faraday-em_synchrony) is that it does not use fibers.
28
+
29
+ **Error handling and responses have a slightly different behaviour and structure in some cases. Please run thorough testing scenarios, including connection failures and SSL failures**
30
+
31
+
32
+ ### Base request
28
33
 
29
34
  ```ruby
30
- connection = Faraday.new(url, conn_options) do |conn|
31
- conn.adapter(:em_http)
35
+ require 'faraday/em_http'
36
+
37
+ conn = Faraday.new(...) do |f|
38
+ # no custom options available
39
+ f.adapter :em_http
32
40
  end
33
41
  ```
34
42
 
35
- For more information on how to setup your Faraday connection and adapters usage, please refer to the [Faraday Website][faraday-website].
43
+ ### Parallel Requests
44
+
45
+ ```ruby
46
+ require 'faraday/em_http'
47
+
48
+ urls = Array.new(5) { 'http://127.0.0.1:3000' }
49
+
50
+ conn = Faraday::Connection.new do |builder|
51
+ builder.adapter :em_http
52
+ end
53
+
54
+ begin
55
+ conn.in_parallel do
56
+ puts "Parallel manager: #{conn.parallel_manager}"
57
+
58
+ @responses = urls.map do |url|
59
+ conn.get(url)
60
+ end
61
+ end
62
+ end
63
+
64
+ # Gather responses outside of block
65
+ puts @responses.map(&:status).join(', ')
66
+ puts @responses.map(&:status).compact.count
67
+ ```
36
68
 
37
69
  ## Development
38
70
 
@@ -1,5 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'em-http'
4
+
5
+ begin
6
+ require 'openssl'
7
+ rescue LoadError
8
+ warn 'Warning: no such file to load -- openssl. ' \
9
+ 'Make sure it is installed if you want HTTPS support'
10
+ else
11
+ require 'em-http/version'
12
+ if EventMachine::HttpRequest::VERSION < '1.1.6'
13
+ require 'faraday/adapter/em_http_ssl_patch'
14
+ end
15
+ end
16
+
3
17
  module Faraday
4
18
  class Adapter
5
19
  # EventMachine adapter. This adapter is useful for either asynchronous
@@ -90,22 +104,6 @@ module Faraday
90
104
 
91
105
  include Options
92
106
 
93
- dependency do
94
- require 'em-http'
95
-
96
- begin
97
- require 'openssl'
98
- rescue LoadError
99
- warn 'Warning: no such file to load -- openssl. ' \
100
- 'Make sure it is installed if you want HTTPS support'
101
- else
102
- require 'em-http/version'
103
- if EventMachine::HttpRequest::VERSION < '1.1.6'
104
- require 'faraday/adapter/em_http_ssl_patch'
105
- end
106
- end
107
- end
108
-
109
107
  self.supports_parallel = true
110
108
 
111
109
  # @return [Manager]
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Faraday
4
4
  module EmHttp
5
- VERSION = '1.0.0'
5
+ VERSION = '2.0.0'
6
6
  end
7
7
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'faraday'
3
4
  require_relative 'adapter/em_http'
4
5
  require_relative 'em_http/version'
5
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday-em_http
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "@iMacTia"
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-25 00:00:00.000000000 Z
11
+ date: 2024-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: em-http-request
@@ -17,7 +17,7 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.1'
20
- type: :development
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
34
- type: :development
33
+ version: '2.0'
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
40
+ version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -122,48 +122,6 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '3.4'
125
- - !ruby/object:Gem::Dependency
126
- name: rubocop
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: 0.91.1
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: 0.91.1
139
- - !ruby/object:Gem::Dependency
140
- name: rubocop-packaging
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '0.5'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '0.5'
153
- - !ruby/object:Gem::Dependency
154
- name: rubocop-performance
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: '1.0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
165
- - !ruby/object:Gem::Version
166
- version: '1.0'
167
125
  description: Faraday adapter for Em::Http
168
126
  email:
169
127
  - giuffrida.mattia@gmail.com
@@ -199,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
157
  - !ruby/object:Gem::Version
200
158
  version: '0'
201
159
  requirements: []
202
- rubygems_version: 3.1.6
160
+ rubygems_version: 3.3.26
203
161
  signing_key:
204
162
  specification_version: 4
205
163
  summary: Faraday adapter for Em::Http