deimos-ruby 2.0.16 → 2.0.17

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: fda90b7f018f9ef696c574248a0bbeabfff39b0d9d6b50fbb0f674e0a46adb83
4
- data.tar.gz: ef3134f7e7e30d4caa44537089350a5ce85c9b8db13ed065f69a2723d7a2b943
3
+ metadata.gz: a6b4516c780cd6c4acfe46092cf4ff7342a3db20b5d259f6fee59e85c2dd6c01
4
+ data.tar.gz: 02347f3bb35d9cd1c0435f097d453c6f7d90bccee6892d637954c862155164fd
5
5
  SHA512:
6
- metadata.gz: 31622734e2657cdf5643594a97b5b56d04bd5bdbf9a56aea73c264f8300ecb9993d09491532f636dd71d208b1dd22af3e2cba0fd91c31d682b7b01efc980c9cc
7
- data.tar.gz: a4b370d783983c5062a892c408981ebeb28472199be9700c43a5d5871b74f3f90885b9ee8bc8dd9307a7162d512ad69dca2f48311e98a278f28b5d703f07f5dc
6
+ metadata.gz: 8b1c2de2fa812f2385b07f3e9fde5135e734571f5bb34d96dd31536ebaf7576c3acdccc7df03098632d549e264d8ef1a5d8f2589995287dda4628dbd535a1840
7
+ data.tar.gz: 600268d4111cb77b2f4c06a6e07ee95d7e7e4387c298a6099c4498f247a64a443426d639c09b1e30455e3f74ebca7a3790ca5b54abcf34d3ab8918811f58a765
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.17 - 2025-07-03
11
+
12
+ - Feature: Allow producers to specify `:message` and `:key` in the `publish` methods.
13
+
10
14
  ## 2.0.16 - 2025-05-30
11
15
 
12
16
  - Fix: Send `publish` metric even if the producer was not a Deimos producer.
data/README.md CHANGED
@@ -259,13 +259,22 @@ If you publish a payload `{ "test_id" => "123", "some_int" => 123 }`, this
259
259
  will be turned into a key that looks like `{ "test_id" => "123"}` and schema-encoded
260
260
  before being sent to Kafka.
261
261
 
262
- If you are using `plain` or `schema` as your config, you will need to have a
263
- special `payload_key` key to your payload hash. This will be extracted and
262
+ If you are using `plain` or `schema` as your config, you can specify the key in two ways:
263
+
264
+ * Add a special `payload_key` key to your payload hash. This will be extracted and
264
265
  used as the key (for `plain`, it will be used directly, while for `schema`
265
266
  it will be encoded first against the schema). So your payload would look like
266
267
  `{ "test_id" => "123", "some_int" => 123, payload_key: "some_other_key"}`.
267
268
  Remember that if you're using `schema`, the `payload_key` must be a *hash*,
268
269
  not a plain value.
270
+ * Specify `:message` and `:key` values when producing messages. This can be helpful when using [schema classes](#generated-schema-classes):
271
+
272
+ ```ruby
273
+ MyProducer.publish({
274
+ message: MySchema.new("test_id" => "123", "some_int" => 123),
275
+ key: MySchemaKey.new("test_id" => "123")
276
+ })
277
+ ```
269
278
 
270
279
  ## Instrumentation
271
280
 
@@ -111,12 +111,17 @@ module Deimos
111
111
  backend = determine_backend_class(sync, force_send)
112
112
 
113
113
  messages = Array(payloads).map do |p|
114
- {
114
+ m = {
115
115
  payload: p&.to_h,
116
116
  headers: headers,
117
117
  topic: topic,
118
118
  partition_key: self.partition_key(p)
119
119
  }
120
+ if m.dig(:payload, :key).present? && m.dig(:payload, :message).present?
121
+ m[:key] = m[:payload][:key].to_h
122
+ m[:payload] = m[:payload][:message].to_h
123
+ end
124
+ m
120
125
  end
121
126
  self.produce(messages, backend: backend)
122
127
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Deimos
4
- VERSION = '2.0.16'
4
+ VERSION = '2.0.17'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deimos-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.16
4
+ version: 2.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Orner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-30 00:00:00.000000000 Z
11
+ date: 2025-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro_turf