deimos-ruby 1.12.1 → 1.12.2

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
  SHA256:
3
- metadata.gz: 456ac47b0f41a41e874a109a005d50650ffc36ae0ca9e924f5e06a0c1b7599ef
4
- data.tar.gz: 14f3e9591b4a32ea503bd063416d13cdd3625bcd220bbe6f61675f1fb911afe6
3
+ metadata.gz: 9c72b3a590ce0e9edddb0b987349aa585bce3047c9f33538a4d3855ecb99c26b
4
+ data.tar.gz: 878bb0045cfb95e62f9052fe329e966d3407552363f68f92b03121a232e0901c
5
5
  SHA512:
6
- metadata.gz: a5f0f9e5d2e0e68c42102166490a929602ef0327c84d42f987200c5c7c941135b7120ca18827707d056a57e9e9ee6e923a7bba91df84f5b7873f1b24e96597f6
7
- data.tar.gz: ad75c79468a87c1a68658099ce9234730926cc049897febd797b2bedbfea316b5ff5b51a8fe215afbd087cf90ca93f2c292b9733128e5470f09cf3e3120d7cce
6
+ metadata.gz: 535ac729a04c8cd12b0494b7e6bc8418a7e3b5d24d8c8a58e77f364cd4f0f9d4409b0bc242ee9a5e57c5c151dc251fabeca540fcad23d681b8c1a9df0bae00a6
7
+ data.tar.gz: c3526e5b16ce4f9af46caae85595b7b9ab0782690f794988ad165185caa9a175c613259dcf4696d0b4659e9dac282e63bb6f5ff0ce6660213bf9f07afcf41204
data/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## UNRELEASED
9
9
 
10
+ # 1.12.2 - 2021-12-10
11
+
12
+ ### Features :star:
13
+
14
+ - Added `Deimos.encode` and `Deimos.decode` for non-topic-related encoding and decoding.
15
+
10
16
  # 1.12.1 - 2021-11-02
11
17
 
12
18
  - ### Fixes :wrench:
data/README.md CHANGED
@@ -1164,6 +1164,13 @@ backend.validate(my_payload) # throws an error if not valid
1164
1164
  fields = backend.schema_fields # list of fields defined in the schema
1165
1165
  ```
1166
1166
 
1167
+ You can also do an even faster encode/decode:
1168
+
1169
+ ```ruby
1170
+ encoded = Deimos.encode(schema: 'MySchema', namespace: 'com.my-namespace', payload: my_payload)
1171
+ decoded = Deimos.decode(schema: 'MySchema', namespace: 'com.my-namespace', payload: my_encoded_payload)
1172
+ ```
1173
+
1167
1174
  ## Contributing
1168
1175
 
1169
1176
  Bug reports and pull requests are welcome on GitHub at https://github.com/flipp-oss/deimos .
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Deimos
4
- VERSION = '1.12.1'
4
+ VERSION = '1.12.2'
5
5
  end
data/lib/deimos.rb CHANGED
@@ -62,6 +62,26 @@ module Deimos
62
62
  schema_backend_class.new(schema: schema, namespace: namespace)
63
63
  end
64
64
 
65
+ # @param schema [String]
66
+ # @param namespace [String]
67
+ # @param payload [Hash]
68
+ # @param subject [String]
69
+ # @return [String]
70
+ def encode(schema:, namespace:, payload:, subject: nil)
71
+ self.schema_backend(schema: schema, namespace: namespace).
72
+ encode(payload, topic: subject || "#{namespace}.#{schema}" )
73
+ end
74
+
75
+ # @param schema [String]
76
+ # @param namespace [String]
77
+ # @param payload [String]
78
+ # @param subject [String]
79
+ # @return [Hash,nil]
80
+ def decode(schema:, namespace:, payload:, subject: nil)
81
+ self.schema_backend(schema: schema, namespace: namespace).
82
+ decode(payload, topic: subject || "#{namespace}.#{schema}" )
83
+ end
84
+
65
85
  # Start the DB producers to send Kafka messages.
66
86
  # @param thread_count [Integer] the number of threads to start.
67
87
  def start_db_backend!(thread_count: 1)
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: 1.12.1
4
+ version: 1.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Orner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-02 00:00:00.000000000 Z
11
+ date: 2021-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro_turf