magic_pipe 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -4
- data/lib/magic_pipe/config.rb +1 -2
- data/lib/magic_pipe/transports/https.rb +10 -7
- data/lib/magic_pipe/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3eadd291f2aa10633773f3cd5bf74a032300941
|
4
|
+
data.tar.gz: 3f78a0d8475045c972cdbcb20b39331e2290cd8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcb5e475d09bb7cdea135a7850a70f0d5168015a77f5a60153bfddf66c110a00ccf25051a2c4a4e770183265f4e232f39d321c645321936510b425be9fa6955b
|
7
|
+
data.tar.gz: bfb8dc0ac117ca58a78af84c94869e1e017206ff573980b94e544075a81b6d5cd1a9c4360d0936f6998fdae3baa4148b30ba0400a12e07e1e476d905b351b2ca
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# MagicPipe Changelog
|
2
2
|
|
3
|
+
## v0.3.0
|
4
|
+
|
5
|
+
* Allow to set the `basic_auth` config as a proc which gets the topic name passed. (thanks @Crunch09, https://github.com/tompave/magic_pipe/pull/1)
|
6
|
+
|
7
|
+
Example:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
basic_auth: ->(topic) {
|
11
|
+
username = ENV["TOPIC_#{topic.singularize.upcase}_USER"]
|
12
|
+
password = ENV["SECRET_PASSWORD"]
|
13
|
+
"#{username}:#{password}"
|
14
|
+
}
|
15
|
+
```
|
16
|
+
|
17
|
+
It should always return a string in the format `USERNAME:PASSWORD`. Instead
|
18
|
+
of using a proc this string can be set directly:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
basic_auth: "foo:bar"
|
22
|
+
```
|
23
|
+
|
24
|
+
In favor of this `basic_auth_user` and `basic_auth_password` have been removed.
|
25
|
+
|
3
26
|
## v0.2.0
|
4
27
|
|
5
28
|
Enhancing the HTTPS transport:
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -141,7 +141,7 @@ $magic_pipe = MagicPipe.build do |mp|
|
|
141
141
|
}
|
142
142
|
mp.https_transport_options = {
|
143
143
|
url: "https://my.receiver.service/foo",
|
144
|
-
|
144
|
+
basic_auth: "bar:foo",
|
145
145
|
}
|
146
146
|
mp.sqs_transport_options = {
|
147
147
|
queue: "my_data_stream"
|
@@ -217,8 +217,7 @@ $magic_pipe = MagicPipe.build do |mp|
|
|
217
217
|
url: "https://my.receiver.service/messages",
|
218
218
|
dynamic_path_builder: -> (topic) { topic }
|
219
219
|
|
220
|
-
|
221
|
-
basic_auth_password: "bar",
|
220
|
+
basic_auth: "foo:bar",
|
222
221
|
|
223
222
|
timeout: 2,
|
224
223
|
open_timeout: 3,
|
@@ -230,7 +229,7 @@ The `dynamic_path_builder` setting should be a callable that will receive the to
|
|
230
229
|
|
231
230
|
```ruby
|
232
231
|
faraday_connection.post do |r|
|
233
|
-
r.url dynamic_path_builder.call(
|
232
|
+
r.url dynamic_path_builder.call(current_topic)
|
234
233
|
end
|
235
234
|
```
|
236
235
|
|
data/lib/magic_pipe/config.rb
CHANGED
@@ -21,6 +21,8 @@ module MagicPipe
|
|
21
21
|
# So that it can be retried?
|
22
22
|
#
|
23
23
|
def submit(payload, metadata)
|
24
|
+
username, password = basic_auth(metadata[:topic])
|
25
|
+
@conn.basic_auth(username, password || "x")
|
24
26
|
@conn.post do |r|
|
25
27
|
path = dynamic_path(metadata[:topic])
|
26
28
|
r.url(path) if path
|
@@ -45,12 +47,14 @@ module MagicPipe
|
|
45
47
|
@options.fetch(:url)
|
46
48
|
end
|
47
49
|
|
48
|
-
def
|
49
|
-
@options.fetch(:
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
def basic_auth(topic)
|
51
|
+
user_auth = @options.fetch(:basic_auth)
|
52
|
+
credentials = if user_auth.respond_to?(:call)
|
53
|
+
user_auth.call(topic)
|
54
|
+
else
|
55
|
+
user_auth
|
56
|
+
end
|
57
|
+
credentials.split(':')
|
54
58
|
end
|
55
59
|
|
56
60
|
def timeout
|
@@ -78,7 +82,6 @@ module MagicPipe
|
|
78
82
|
def build_connection
|
79
83
|
Faraday.new(url) do |f|
|
80
84
|
f.request :retry, max: 2, interval: 0.1, backoff_factor: 2
|
81
|
-
f.request :basic_auth, basic_auth_user, basic_auth_password
|
82
85
|
|
83
86
|
f.headers['Content-Type'] = content_type
|
84
87
|
f.headers['User-Agent'] = user_agent
|
data/lib/magic_pipe/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magic_pipe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tommaso Pavese
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -254,4 +254,3 @@ specification_version: 4
|
|
254
254
|
summary: A Magic Pipe to send data in arbitrary formats to configurable backends,
|
255
255
|
with topics.
|
256
256
|
test_files: []
|
257
|
-
has_rdoc:
|