deimos-ruby 2.4.0.pre.beta14 → 2.4.0.pre.beta15
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c687daed3ba5ea1044626b15befc8aa72c492f2ba518f2f0621fecee6bcf98c0
|
|
4
|
+
data.tar.gz: ba0c6b59cb5770f009da8b2042b579772bfaaaa5ffd2f7668b98651f66854ba0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: edf64af1b741cc5bd4091a17269374c3533e508f370047c3d47f8ef8af6777e705e4fa27711da9296ac5673d95ff34e7580d02d2857642477a1b5372738da834
|
|
7
|
+
data.tar.gz: 02c7ab988f28d0d45b7e358248537a449d89845b0d7de85cf2f1c4f500145afad14ae1cf3cf8eb91bf8e91936fc19516578dd132570d705a99a905cf63cd51df
|
|
@@ -15,38 +15,38 @@ module Deimos
|
|
|
15
15
|
|
|
16
16
|
# @override
|
|
17
17
|
def decode_payload(payload, schema:)
|
|
18
|
-
self.
|
|
18
|
+
self.schema_registry.decode(payload)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
# @override
|
|
22
22
|
def encode_payload(payload, schema: nil, subject: nil)
|
|
23
23
|
msg = payload.is_a?(Hash) ? proto_schema.msgclass.new(**payload) : payload
|
|
24
|
-
encoder = subject&.ends_with?('-key') ? self.
|
|
24
|
+
encoder = subject&.ends_with?('-key') ? self.key_schema_registry : self.schema_registry
|
|
25
25
|
encoder.encode(msg, subject: subject)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
# @override
|
|
29
29
|
def encode_proto_key(key, topic: nil, field: nil)
|
|
30
30
|
schema_text = SchemaRegistry::Output::JsonSchema.output(proto_schema.to_proto, path: field)
|
|
31
|
-
self.
|
|
31
|
+
self.key_schema_registry.encode(key, subject: "#{topic}-key", schema_text: schema_text)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
# @override
|
|
35
35
|
def decode_proto_key(payload)
|
|
36
|
-
self.
|
|
36
|
+
self.key_schema_registry.decode(payload)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
# @return [SchemaRegistry::Client]
|
|
40
|
-
def
|
|
40
|
+
def schema_registry
|
|
41
41
|
@schema_registry ||= SchemaRegistry::Client.new(
|
|
42
|
-
registry_url: Deimos.config.schema.registry_url,
|
|
43
|
-
user: Deimos.config.schema.user,
|
|
44
|
-
password: Deimos.config.schema.password,
|
|
42
|
+
registry_url: @registry_info&.url || Deimos.config.schema.registry_url,
|
|
43
|
+
user: @registry_info&.user || Deimos.config.schema.user,
|
|
44
|
+
password: @registry_info&.password || Deimos.config.schema.password,
|
|
45
45
|
logger: Karafka.logger
|
|
46
46
|
)
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
def
|
|
49
|
+
def key_schema_registry
|
|
50
50
|
@key_schema_registry ||= SchemaRegistry::Client.new(
|
|
51
51
|
registry_url: @registry_info&.url || Deimos.config.schema.registry_url,
|
|
52
52
|
user: @registry_info&.user || Deimos.config.schema.user,
|
data/lib/deimos/version.rb
CHANGED
|
@@ -23,8 +23,8 @@ RSpec.describe Deimos::SchemaBackends::ProtoSchemaRegistry do
|
|
|
23
23
|
let(:backend) { described_class.new(schema: 'sample.v1.SampleMessage') }
|
|
24
24
|
|
|
25
25
|
before(:each) do
|
|
26
|
-
allow(
|
|
27
|
-
|
|
26
|
+
allow(backend).to receive_messages(schema_registry: schema_registry,
|
|
27
|
+
key_schema_registry: key_schema_registry)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
describe 'payload encoding and decoding' do
|
|
@@ -124,8 +124,8 @@ RSpec.describe Deimos::SchemaBackends::ProtoSchemaRegistry do
|
|
|
124
124
|
|
|
125
125
|
before(:each) do
|
|
126
126
|
# For key_backend tests, mock both schema_registry instances
|
|
127
|
-
allow(
|
|
128
|
-
|
|
127
|
+
allow(key_backend).to receive_messages(schema_registry: schema_registry_for_test,
|
|
128
|
+
key_schema_registry: key_schema_registry_for_test)
|
|
129
129
|
end
|
|
130
130
|
|
|
131
131
|
it 'should encode a protobuf key message using the key schema' do
|