magic_pipe 0.3.0 → 0.4.0

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
- SHA1:
3
- metadata.gz: a3eadd291f2aa10633773f3cd5bf74a032300941
4
- data.tar.gz: 3f78a0d8475045c972cdbcb20b39331e2290cd8d
2
+ SHA256:
3
+ metadata.gz: 1e62bd485afca6636d7eaf6f1012626e56ab2487bc5a14c0907b16ee1b31719d
4
+ data.tar.gz: 52f3fd7a732204f997db9d9f94287ad5f6874ae652a98cd030a0ffba2653afd6
5
5
  SHA512:
6
- metadata.gz: fcb5e475d09bb7cdea135a7850a70f0d5168015a77f5a60153bfddf66c110a00ccf25051a2c4a4e770183265f4e232f39d321c645321936510b425be9fa6955b
7
- data.tar.gz: bfb8dc0ac117ca58a78af84c94869e1e017206ff573980b94e544075a81b6d5cd1a9c4360d0936f6998fdae3baa4148b30ba0400a12e07e1e476d905b351b2ca
6
+ metadata.gz: e010cb398432c0bd5282bdce573aeb4208a8001c01a69e63028f5b0dbe72bbf2b058c530c470d9ca91a33b13fcd8306467725a2826227bedcbc5aa61b4a28437
7
+ data.tar.gz: 1322dbfd131696b6a80497e1701354943d2e497cab23842cad51d108afc2f380c3854dc537940dec20bbd6983457be47e5f0831b3f06571dd6cce7e25e4afcdb
@@ -1,9 +1,9 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.4.3
5
- - 2.3.6
6
- - 2.2.9
4
+ - 2.5.3
5
+ - 2.4.5
6
+ - 2.3.8
7
7
  script:
8
8
  - bundle exec rspec
9
9
  notifications:
@@ -1,5 +1,9 @@
1
1
  # MagicPipe Changelog
2
2
 
3
+ ## v0.4.0
4
+
5
+ Bug fix: Ensure that the `Https` transport raises an exception when the HTTP POST request fails.
6
+
3
7
  ## v0.3.0
4
8
 
5
9
  * 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)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- magic_pipe (0.3.0)
4
+ magic_pipe (0.4.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -25,9 +25,9 @@ GEM
25
25
  diff-lcs (1.3)
26
26
  ethon (0.11.0)
27
27
  ffi (>= 1.3.0)
28
- faraday (0.14.0)
28
+ faraday (0.15.3)
29
29
  multipart-post (>= 1.2, < 3)
30
- ffi (1.9.18)
30
+ ffi (1.9.25)
31
31
  hashdiff (0.3.7)
32
32
  jmespath (1.3.1)
33
33
  method_source (0.9.0)
@@ -89,4 +89,4 @@ DEPENDENCIES
89
89
  webmock (~> 3.3)
90
90
 
91
91
  BUNDLED WITH
92
- 1.16.1
92
+ 1.16.4
@@ -11,4 +11,16 @@ module MagicPipe
11
11
  end
12
12
  attr_reader :message
13
13
  end
14
+
15
+ module Transports
16
+ class SubmitFailedError < MagicPipe::Error
17
+ def initialize(transport_klass)
18
+ @message = "#{transport_klass} couldn't submit message"
19
+ end
20
+ attr_reader :message
21
+ end
22
+
23
+ class NotImplementedError < SubmitFailedError
24
+ end
25
+ end
14
26
  end
@@ -27,7 +27,7 @@ module MagicPipe
27
27
  )
28
28
 
29
29
  payload = codec.new(envelope).encode
30
- client.transport.submit(payload, metadata)
30
+ client.transport.submit!(payload, metadata)
31
31
 
32
32
  track_success(client.metrics, topic)
33
33
  rescue => e
@@ -10,7 +10,7 @@ module MagicPipe
10
10
  metadata = build_metadata
11
11
  envelope = build_message(metadata)
12
12
  payload = @codec.new(envelope).encode
13
- @transport.submit(payload, metadata)
13
+ @transport.submit!(payload, metadata)
14
14
  track_success(@metrics, @topic)
15
15
  rescue => e
16
16
  track_failure(@metrics, @topic)
@@ -9,8 +9,8 @@ module MagicPipe
9
9
 
10
10
  attr_reader :metrics, :logger
11
11
 
12
- def submit(payload, metadata)
13
- raise NotImplementedError
12
+ def submit!(payload, metadata)
13
+ raise MagicPipe::Transports::NotImplementedError
14
14
  end
15
15
  end
16
16
  end
@@ -6,7 +6,7 @@ module MagicPipe
6
6
  def initialize(*)
7
7
  end
8
8
 
9
- def submit(payload, metadata)
9
+ def submit!(payload, metadata)
10
10
  $magic_pipe_out = {
11
11
  payload: payload,
12
12
  metadata: metadata
@@ -20,10 +20,10 @@ module MagicPipe
20
20
  # TODO: should this raise an error on failure?
21
21
  # So that it can be retried?
22
22
  #
23
- def submit(payload, metadata)
23
+ def submit!(payload, metadata)
24
24
  username, password = basic_auth(metadata[:topic])
25
25
  @conn.basic_auth(username, password || "x")
26
- @conn.post do |r|
26
+ resp = @conn.post do |r|
27
27
  path = dynamic_path(metadata[:topic])
28
28
  r.url(path) if path
29
29
 
@@ -32,6 +32,10 @@ module MagicPipe
32
32
  r.headers["X-MagicPipe-Topic"] = metadata[:topic]
33
33
  r.headers["X-MagicPipe-Producer"] = metadata[:producer]
34
34
  end
35
+
36
+ unless resp.success?
37
+ raise SubmitFailedError, self.class
38
+ end
35
39
  end
36
40
 
37
41
 
@@ -7,7 +7,7 @@ module MagicPipe
7
7
  super(config, metrics)
8
8
  end
9
9
 
10
- def submit(payload, _metadata)
10
+ def submit!(payload, _metadata)
11
11
  @logger.info "[Trasport#submit]: ↩️\n#{payload}\n"
12
12
  end
13
13
  end
@@ -9,10 +9,10 @@ module MagicPipe
9
9
  end
10
10
 
11
11
 
12
- def submit(payload, metadata)
12
+ def submit!(payload, metadata)
13
13
  @transports.map do |transport|
14
14
  begin
15
- transport.submit(payload, metadata)
15
+ transport.submit!(payload, metadata)
16
16
  rescue => e
17
17
  log_error(e, transport)
18
18
  end
@@ -15,7 +15,10 @@ module MagicPipe
15
15
  end
16
16
 
17
17
 
18
- def submit(payload, metadata)
18
+ # The AWS SQS client will raise an error if it can't
19
+ # submit the message.
20
+ #
21
+ def submit!(payload, metadata)
19
22
  send_message(payload, metadata)
20
23
  end
21
24
 
@@ -1,3 +1,3 @@
1
1
  module MagicPipe
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
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.3.0
4
+ version: 0.4.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-05-24 00:00:00.000000000 Z
11
+ date: 2018-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -248,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
248
  version: '0'
249
249
  requirements: []
250
250
  rubyforge_project:
251
- rubygems_version: 2.6.14
251
+ rubygems_version: 2.7.7
252
252
  signing_key:
253
253
  specification_version: 4
254
254
  summary: A Magic Pipe to send data in arbitrary formats to configurable backends,