deimos-ruby 2.0.13 → 2.0.14

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
2
  SHA256:
3
- metadata.gz: 0c18442a9ba85a0b6de4c3cdaee151727d7e7ba9ca70de8129b08a91ad1a100c
4
- data.tar.gz: 7db213f9a31a8775f6f23fd10098d284df59f5dbf4b040d0719b9fa10f5af6e6
3
+ metadata.gz: e8597163d34a0b2afd7ef60bbc2eda8f08c4e441292181dc7d15215ad4b2ebd7
4
+ data.tar.gz: 364899fa4738dd1df44f98cecc67bdc503f1a679a26274f78b49bd8b29c1ee02
5
5
  SHA512:
6
- metadata.gz: 532e1eed51b376e568c1e7e9b424a65a29a7e339e8db91e3f3761328ff826e3ad45a8c12bddbb4155707610df3ab36bf90e1acfe6411b6829be6fe8e45453e75
7
- data.tar.gz: 29ca80e081b8c0699ee8b132c31d7ab27eb91f63dca808a03f8c7e3905a70a7f520964abc0631995b033c7bfc72d3581dd7d5dacd93d234b970ebbc92bd99837
6
+ metadata.gz: 54eff5f5b0f375816b3a25516f602985b00440fe522d5495346fcb873d37fb1a822666ad04623c74002a15c15c3a70ba851099096d72eaba8ab9840a460ddbc2
7
+ data.tar.gz: 9901785951d244c09fc81ca6601c6700149b2f03f8246f167fe594fce778c035a1f81a1a468045930cf94e5787cecffcefdf069132cfe57686ec0172c8a28f5c
data/CHANGELOG.md CHANGED
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## UNRELEASED
9
9
 
10
+ ## 2.0.14 - 2025-05-26
11
+
12
+ - Fix: Log actual payloads by default (was logging "null" for the payload).
13
+
10
14
  ## 2.0.13 - 2025-05-26
11
15
 
12
16
  - Fix: Outbox producer would crash if no Deimos producer was defined for the topic.
@@ -42,7 +42,7 @@ module Deimos
42
42
  if m.respond_to?(:payload)
43
43
  m.payload
44
44
  elsif m[:label]
45
- m.dig(:label, :raw_payload)
45
+ m.dig(:label, :original_payload)
46
46
  else
47
47
  m[:payload]
48
48
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Deimos
4
- VERSION = '2.0.13'
4
+ VERSION = '2.0.14'
5
5
  end
@@ -272,6 +272,50 @@ module ProducerTest
272
272
  }, '456', '4561')
273
273
  end
274
274
 
275
+ describe 'payload logging' do
276
+ context 'with default / full' do
277
+ it 'should log full payload' do
278
+ allow(Karafka.logger).to receive(:info)
279
+ MyProducerWithID.publish_list(
280
+ [
281
+ { 'test_id' => 'foo', 'some_int' => 123, :payload_key => 'key' },
282
+ { 'test_id' => 'foo2', 'some_int' => 123, :payload_key => 'key2' },
283
+ ]
284
+ )
285
+ expect(Karafka.logger).to have_received(:info).with(match_message({
286
+ 'message' => 'Publishing Messages:',
287
+ 'payloads' => [
288
+ {
289
+ 'payload' => { 'test_id' => 'foo', 'some_int' => 123 },
290
+ 'key' => 'key'
291
+ },
292
+ {
293
+ 'payload' => { 'test_id' => 'foo2', 'some_int' => 123 },
294
+ 'key' => 'key2'
295
+ }
296
+ ]
297
+ }))
298
+ end
299
+ end
300
+
301
+ context 'with count' do
302
+ it 'should log only count' do
303
+ Deimos.karafka_config_for(topic: 'my-topic-with-id').payload_log :count
304
+ allow(Karafka.logger).to receive(:info)
305
+ MyProducerWithID.publish_list(
306
+ [
307
+ { 'test_id' => 'foo', 'some_int' => 123, :payload_key => 'key' },
308
+ { 'test_id' => 'foo2', 'some_int' => 123, :payload_key => 'key' }
309
+ ]
310
+ )
311
+ expect(Karafka.logger).to have_received(:info).with(match_message({
312
+ 'message' => 'Publishing Messages:',
313
+ 'payloads_count' => 2
314
+ }))
315
+ end
316
+ end
317
+ end
318
+
275
319
  context 'with Schema Class payloads' do
276
320
  it 'should fail on invalid message with error handler' do
277
321
  expect(Deimos::ProducerMiddleware).to receive(:call).and_raise('OH NOES')
data/spec/spec_helper.rb CHANGED
@@ -343,3 +343,18 @@ RSpec.shared_context('with publish_backend') do
343
343
  end
344
344
  end
345
345
  end
346
+
347
+ RSpec::Matchers.define :match_message do |msg|
348
+ match do |actual|
349
+ begin
350
+ parsed = JSON.parse(actual)
351
+ parsed['payloads']&.each do |p|
352
+ p['payload'].delete('timestamp')
353
+ p['payload'].delete('message_id')
354
+ end
355
+ expect(parsed).to match(a_hash_including(msg))
356
+ rescue JSON::ParserError
357
+ false
358
+ end
359
+ end
360
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deimos-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.13
4
+ version: 2.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Orner