phobos 1.6.0 → 1.6.1

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
  SHA1:
3
- metadata.gz: 05b2968d8c1fc02f229055c4163bd4c4472a9c1c
4
- data.tar.gz: cca82af11ae5d8aa4996a8802bc516eda2fd8b4a
3
+ metadata.gz: 6e7de0ef712ba1636a2c66ceb7fbfa159e479c87
4
+ data.tar.gz: 5bbaa97f07e0f6aa5825b49220daa2f6cac239dd
5
5
  SHA512:
6
- metadata.gz: 61cb3f4940c594967b2c0c20a8ef3e7ac22c811baaea4dd8b2aa482c76aa7c4ae2d93d4a1986b91fc4a6b4b7d6cdae66cc63e23278646b20dbed5346cfa3f31d
7
- data.tar.gz: a5fbf1313da2817be54c5213a64d0e3e9220d621fc1efd9230cc9285c926d8041a72badf4133679065a888891c8f54da04c80e94d62e9f792542c3c76d02ebb6
6
+ metadata.gz: 3ffa62ee7edcd651dabc33fa6f3bfc96cf3ab30076b49254d89e1c6f0443843159022945c483126fa3e0d5ac8674526a350693405448b327681d0752dc281b31
7
+ data.tar.gz: aaf894ba3a7ac6c5c01d1b06ee621995fecd5bd0ed368bc28235bdd2a756b55fcb9d7f8955987429e8ed3ae850dc231c4d43ef6fb08e5c611685caf4929729bb
data/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
7
  ## UNRELEASED
8
8
 
9
+ ## [1.6.1] - 2017-11-16
10
+ ### Fixed
11
+ - `Phobos::Test::Helper` is broken #53
12
+
9
13
  ## [1.6.0] - 2017-11-16
10
14
  ### Added
11
15
  - Support for outputting logs as json #50
data/README.md CHANGED
@@ -455,14 +455,14 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
455
455
 
456
456
  Phobos exports a spec helper that can help you test your consumer. The Phobos lifecycle will conveniently be activated for you with minimal setup required.
457
457
 
458
- * `process_message(handler:, payload:, metadata:, encoding: nil)` - Invokes your handler with payload and metadata, using a dummy listener (encoding is optional).
458
+ * `process_message(handler:, payload:, metadata: {}, encoding: nil)` - Invokes your handler with payload and metadata, using a dummy listener (encoding and metadata are optional).
459
459
 
460
460
  ```ruby
461
461
  require 'spec_helper'
462
462
 
463
463
  describe MyConsumer do
464
464
  let(:payload) { 'foo' }
465
- let(:metadata) { 'foo' }
465
+ let(:metadata) { Hash(foo: 'bar') }
466
466
 
467
467
  it 'consumes my message' do
468
468
  expect(described_class).to receive(:around_consume).with(payload, metadata).once.and_call_original
@@ -57,16 +57,19 @@ module Phobos
57
57
 
58
58
  def process_message(payload)
59
59
  instrument('listener.process_message', @metadata) do |metadata|
60
+ consume_result = nil
60
61
  time_elapsed = measure do
61
62
  handler = @listener.handler_class.new
62
63
  preprocessed_payload = handler.before_consume(payload)
63
64
 
64
65
  @listener.handler_class.around_consume(preprocessed_payload, @metadata) do
65
- handler.consume(preprocessed_payload, @metadata)
66
+ consume_result = handler.consume(preprocessed_payload, @metadata)
66
67
  end
67
68
  end
68
69
 
69
70
  metadata.merge!(time_elapsed: time_elapsed)
71
+
72
+ consume_result
70
73
  end
71
74
  end
72
75
  end
@@ -1,21 +1,29 @@
1
1
  module Phobos
2
2
  module Test
3
3
  module Helper
4
- KafkaMessage = Struct.new(:value)
4
+ TOPIC = 'test-topic'
5
+ GROUP = 'test-group'
5
6
 
6
- def process_message(handler:, payload:, metadata:, force_encoding: nil)
7
+ def process_message(handler:, payload:, metadata: {}, force_encoding: nil)
7
8
  listener = Phobos::Listener.new(
8
9
  handler: handler,
9
- group_id: 'test-group',
10
- topic: 'test-topic',
10
+ group_id: GROUP,
11
+ topic: TOPIC,
11
12
  force_encoding: force_encoding
12
13
  )
13
14
 
15
+ message = Kafka::FetchedMessage.new(
16
+ value: payload,
17
+ key: nil,
18
+ topic: TOPIC,
19
+ partition: 0,
20
+ offset: 13,
21
+ )
22
+
14
23
  Phobos::Actions::ProcessMessage.new(
15
24
  listener: listener,
16
- message: KafkaMessage.new(payload),
17
- metadata: metadata,
18
- encoding: listener.encoding
25
+ message: message,
26
+ listener_metadata: metadata
19
27
  ).execute
20
28
  end
21
29
  end
@@ -1,3 +1,3 @@
1
1
  module Phobos
2
- VERSION = '1.6.0'
2
+ VERSION = '1.6.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phobos
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Túlio Ornelas