deimos-ruby 1.8.1.pre.beta6 → 1.8.2.pre.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -0
- data/Gemfile.lock +1 -1
- data/README.md +43 -3
- data/docs/UPGRADING.md +128 -0
- data/lib/deimos/producer.rb +9 -6
- data/lib/deimos/schema_backends/avro_schema_registry.rb +1 -1
- data/lib/deimos/test_helpers.rb +8 -7
- data/lib/deimos/utils/db_producer.rb +2 -2
- data/lib/deimos/utils/schema_controller_mixin.rb +5 -1
- data/lib/deimos/version.rb +1 -1
- data/spec/consumer_spec.rb +2 -2
- data/spec/producer_spec.rb +27 -0
- data/spec/schemas/com/my-namespace/request/CreateTopic.avsc +11 -0
- data/spec/schemas/com/my-namespace/response/CreateTopic.avsc +11 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/utils/db_producer_spec.rb +4 -0
- data/spec/utils/schema_controller_mixin_spec.rb +16 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b773de54759babb229e8f3bc6b42931dab7695b7197d601ad4ae08015c0b401f
|
4
|
+
data.tar.gz: 4af1aa98ffdfc013c4cac02fa316371ad138ec0d807ed58426a7ad57d6c1e719
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 319d01a4c42c5efe72bd4959fb57548102c3f2b4305f3d94510747fd372d516ebad3e34ff74f9e6744641728efce9eb7a20f2d89c37d6bd90847253698a05238
|
7
|
+
data.tar.gz: 9e6999cca87ca448167a9e61a0bfa5914b36fd74c053f132bd02ab5200be840984546469affccfd07ce77d4d098a2096b13e42febd4ce7059ec882c436580cd8
|
data/CHANGELOG.md
CHANGED
@@ -7,7 +7,39 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## UNRELEASED
|
9
9
|
|
10
|
+
## 1.8.2-beta2 - 2020-09-15
|
11
|
+
|
12
|
+
### Features :star:
|
13
|
+
|
14
|
+
- Add details on using schema backend directly in README.
|
15
|
+
- Default to the provided schema if topic is not provided when
|
16
|
+
encoding to `AvroSchemaRegistry`.
|
17
|
+
- Add mapping syntax for the `schema` call in `SchemaControllerMixin`.
|
18
|
+
|
19
|
+
## 1.8.2-beta1 - 2020-09-09
|
20
|
+
|
21
|
+
### Features :star:
|
22
|
+
|
23
|
+
- Added the ability to specify the topic for `publish`
|
24
|
+
and `publish_list` in a producer
|
25
|
+
|
26
|
+
## 1.8.1-beta9 - 2020-08-27
|
27
|
+
|
28
|
+
### Fixes :wrench:
|
29
|
+
- Moved the TestHelpers hook to `before(:suite)` to allow for
|
30
|
+
overriding e.g. in integration tests.
|
31
|
+
|
32
|
+
## 1.8.1-beta7 - 2020-08-25
|
33
|
+
|
34
|
+
### Fixes :wrench:
|
35
|
+
- Fix for crash when sending pending metrics with DB producer.
|
36
|
+
- Fix for compacting messages if all the keys are already unique
|
37
|
+
(fixes [#75](https://github.com/flipp-oss/deimos/issues/75))
|
38
|
+
|
10
39
|
## 1.8.1-beta6 - 2020-08-13
|
40
|
+
|
41
|
+
### Fixes :wrench:
|
42
|
+
|
11
43
|
- Fix for consuming nil payloads with Ruby 2.3.
|
12
44
|
|
13
45
|
## 1.8.1-beta5 - 2020-08-13
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -11,6 +11,7 @@ a useful toolbox of goodies for Ruby-based Kafka development.
|
|
11
11
|
Built on Phobos and hence Ruby-Kafka.
|
12
12
|
|
13
13
|
<!--ts-->
|
14
|
+
* [Additional Documentation](#additional-documentation)
|
14
15
|
* [Installation](#installation)
|
15
16
|
* [Versioning](#versioning)
|
16
17
|
* [Configuration](#configuration)
|
@@ -29,9 +30,19 @@ Built on Phobos and hence Ruby-Kafka.
|
|
29
30
|
* [Metrics](#metrics)
|
30
31
|
* [Testing](#testing)
|
31
32
|
* [Integration Test Helpers](#integration-test-helpers)
|
33
|
+
* [Utilities](#utilities)
|
32
34
|
* [Contributing](#contributing)
|
33
35
|
<!--te-->
|
34
36
|
|
37
|
+
# Additional Documentation
|
38
|
+
|
39
|
+
Please see the following for further information not covered by this readme:
|
40
|
+
|
41
|
+
* [Architecture Design](docs/ARCHITECTURE.md)
|
42
|
+
* [Configuration Reference](docs/CONFIGURATION.md)
|
43
|
+
* [Database Backend Feature](docs/DATABASE_BACKEND.md)
|
44
|
+
* [Upgrading Deimos](docs/UPGRADING.md)
|
45
|
+
|
35
46
|
# Installation
|
36
47
|
|
37
48
|
Add this line to your application's Gemfile:
|
@@ -108,6 +119,7 @@ class MyProducer < Deimos::Producer
|
|
108
119
|
'some-key2' => an_object.bar
|
109
120
|
}
|
110
121
|
# You can also publish an array with self.publish_list(payloads)
|
122
|
+
# You may specify the topic here with self.publish(payload, topic: 'my-topic')
|
111
123
|
self.publish(payload)
|
112
124
|
end
|
113
125
|
|
@@ -481,6 +493,12 @@ class WhateverController < ApplicationController
|
|
481
493
|
# will look for: my.namespace.requests.Index.avsc
|
482
494
|
# my.namespace.responses.Index.avsc
|
483
495
|
|
496
|
+
# Can use mapping to change the schema but keep the namespaces,
|
497
|
+
# i.e. use the same schema name across the two namespaces
|
498
|
+
schemas create: 'CreateTopic'
|
499
|
+
# will look for: my.namespace.requests.CreateTopic.avsc
|
500
|
+
# my.namespace.responses.CreateTopic.avsc
|
501
|
+
|
484
502
|
# If all routes use the default, you can add them all at once
|
485
503
|
schemas :index, :show, :update
|
486
504
|
|
@@ -921,6 +939,17 @@ Deimos::TestHelpers.schemas_compatible?(schema1, schema2)
|
|
921
939
|
|
922
940
|
### Integration Test Helpers
|
923
941
|
|
942
|
+
When running integration tests, you'll want to override the default test helper settings:
|
943
|
+
|
944
|
+
```ruby
|
945
|
+
config.before(:each, :my_integration_metadata) do
|
946
|
+
Deimos.configure do
|
947
|
+
producers.backend :kafka
|
948
|
+
schema.backend :avro_schema_registry
|
949
|
+
end
|
950
|
+
end
|
951
|
+
```
|
952
|
+
|
924
953
|
You can use the `InlineConsumer` class to help with integration testing,
|
925
954
|
with a full external Kafka running.
|
926
955
|
|
@@ -977,13 +1006,24 @@ Deimos::Utils::InlineConsumer.get_messages_for(
|
|
977
1006
|
)
|
978
1007
|
```
|
979
1008
|
|
1009
|
+
## Utilities
|
1010
|
+
|
1011
|
+
You can use your configured schema backend directly if you want to
|
1012
|
+
encode and decode payloads outside of the context of sending messages.
|
1013
|
+
|
1014
|
+
```ruby
|
1015
|
+
backend = Deimos.schema_backend(schema: 'MySchema', namespace: 'com.my-namespace')
|
1016
|
+
encoded = backend.encode(my_payload)
|
1017
|
+
decoded = backend.decode(my_encoded_payload)
|
1018
|
+
coerced = backend.coerce(my_payload) # coerce to correct types
|
1019
|
+
backend.validate(my_payload) # throws an error if not valid
|
1020
|
+
fields = backend.schema_fields # list of fields defined in the schema
|
1021
|
+
```
|
1022
|
+
|
980
1023
|
## Contributing
|
981
1024
|
|
982
1025
|
Bug reports and pull requests are welcome on GitHub at https://github.com/flipp-oss/deimos .
|
983
1026
|
|
984
|
-
We have more information on the [internal architecture](docs/ARCHITECTURE.md) of Deimos
|
985
|
-
for contributors!
|
986
|
-
|
987
1027
|
### Linting
|
988
1028
|
|
989
1029
|
Deimos uses Rubocop to lint the code. Please run Rubocop on your code
|
data/docs/UPGRADING.md
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
# Upgrading Deimos
|
2
|
+
|
3
|
+
## Upgrading from < 1.5.0 to >= 1.5.0
|
4
|
+
|
5
|
+
If you are using Confluent's schema registry to Avro-encode your
|
6
|
+
messages, you will need to manually include the `avro_turf` gem
|
7
|
+
in your Gemfile now.
|
8
|
+
|
9
|
+
This update changes how to interact with Deimos's schema classes.
|
10
|
+
Although these are meant to be internal, they are still "public"
|
11
|
+
and can be used by calling code.
|
12
|
+
|
13
|
+
Before 1.5.0:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
encoder = Deimos::AvroDataEncoder.new(schema: 'MySchema',
|
17
|
+
namespace: 'com.my-namespace')
|
18
|
+
encoder.encode(my_payload)
|
19
|
+
|
20
|
+
decoder = Deimos::AvroDataDecoder.new(schema: 'MySchema',
|
21
|
+
namespace: 'com.my-namespace')
|
22
|
+
decoder.decode(my_payload)
|
23
|
+
```
|
24
|
+
|
25
|
+
After 1.5.0:
|
26
|
+
```ruby
|
27
|
+
backend = Deimos.schema_backend(schema: 'MySchema', namespace: 'com.my-namespace')
|
28
|
+
backend.encode(my_payload)
|
29
|
+
backend.decode(my_payload)
|
30
|
+
```
|
31
|
+
|
32
|
+
The two classes are different and if you are using them to e.g.
|
33
|
+
inspect Avro schema fields, please look at the source code for the following:
|
34
|
+
* `Deimos::SchemaBackends::Base`
|
35
|
+
* `Deimos::SchemaBackends::AvroBase`
|
36
|
+
* `Deimos::SchemaBackends::AvroSchemaRegistry`
|
37
|
+
|
38
|
+
Deprecated `Deimos::TestHelpers.sent_messages` in favor of
|
39
|
+
`Deimos::Backends::Test.sent_messages`.
|
40
|
+
|
41
|
+
## Upgrading from < 1.4.0 to >= 1.4.0
|
42
|
+
|
43
|
+
Previously, configuration was handled as follows:
|
44
|
+
* Kafka configuration, including listeners, lived in `phobos.yml`
|
45
|
+
* Additional Deimos configuration would live in an initializer, e.g. `kafka.rb`
|
46
|
+
* Producer and consumer configuration lived in each individual producer and consumer
|
47
|
+
|
48
|
+
As of 1.4.0, all configuration is centralized in one initializer
|
49
|
+
file, using default configuration.
|
50
|
+
|
51
|
+
Before 1.4.0:
|
52
|
+
```yaml
|
53
|
+
# config/phobos.yml
|
54
|
+
logger:
|
55
|
+
file: log/phobos.log
|
56
|
+
level: debug
|
57
|
+
ruby_kafka:
|
58
|
+
level: debug
|
59
|
+
|
60
|
+
kafka:
|
61
|
+
client_id: phobos
|
62
|
+
connect_timeout: 15
|
63
|
+
socket_timeout: 15
|
64
|
+
|
65
|
+
producer:
|
66
|
+
ack_timeout: 5
|
67
|
+
required_acks: :all
|
68
|
+
...
|
69
|
+
|
70
|
+
listeners:
|
71
|
+
- handler: ConsumerTest::MyConsumer
|
72
|
+
topic: my_consume_topic
|
73
|
+
group_id: my_group_id
|
74
|
+
- handler: ConsumerTest::MyBatchConsumer
|
75
|
+
topic: my_batch_consume_topic
|
76
|
+
group_id: my_batch_group_id
|
77
|
+
delivery: inline_batch
|
78
|
+
```
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
# kafka.rb
|
82
|
+
Deimos.configure do |config|
|
83
|
+
config.reraise_consumer_errors = true
|
84
|
+
config.logger = Rails.logger
|
85
|
+
...
|
86
|
+
end
|
87
|
+
|
88
|
+
# my_consumer.rb
|
89
|
+
class ConsumerTest::MyConsumer < Deimos::Producer
|
90
|
+
namespace 'com.my-namespace'
|
91
|
+
schema 'MySchema'
|
92
|
+
topic 'MyTopic'
|
93
|
+
key_config field: :id
|
94
|
+
end
|
95
|
+
```
|
96
|
+
|
97
|
+
After 1.4.0:
|
98
|
+
```ruby
|
99
|
+
kafka.rb
|
100
|
+
Deimos.configure do
|
101
|
+
logger Rails.logger
|
102
|
+
kafka do
|
103
|
+
client_id 'phobos'
|
104
|
+
connect_timeout 15
|
105
|
+
socket_timeout 15
|
106
|
+
end
|
107
|
+
producers.ack_timeout 5
|
108
|
+
producers.required_acks :all
|
109
|
+
...
|
110
|
+
consumer do
|
111
|
+
class_name 'ConsumerTest::MyConsumer'
|
112
|
+
topic 'my_consume_topic'
|
113
|
+
group_id 'my_group_id'
|
114
|
+
namespace 'com.my-namespace'
|
115
|
+
schema 'MySchema'
|
116
|
+
topic 'MyTopic'
|
117
|
+
key_config field: :id
|
118
|
+
end
|
119
|
+
...
|
120
|
+
end
|
121
|
+
```
|
122
|
+
|
123
|
+
Note that the old configuration way *will* work if you set
|
124
|
+
`config.phobos_config_file = "config/phobos.yml"`. You will
|
125
|
+
get a number of deprecation notices, however. You can also still
|
126
|
+
set the topic, namespace, etc. on the producer/consumer class,
|
127
|
+
but it's much more convenient to centralize these configs
|
128
|
+
in one place to see what your app does.
|
data/lib/deimos/producer.rb
CHANGED
@@ -87,8 +87,9 @@ module Deimos
|
|
87
87
|
|
88
88
|
# Publish the payload to the topic.
|
89
89
|
# @param payload [Hash] with an optional payload_key hash key.
|
90
|
-
|
91
|
-
|
90
|
+
# @param topic [String] if specifying the topic
|
91
|
+
def publish(payload, topic: self.topic)
|
92
|
+
publish_list([payload], topic: topic)
|
92
93
|
end
|
93
94
|
|
94
95
|
# Publish a list of messages.
|
@@ -97,7 +98,8 @@ module Deimos
|
|
97
98
|
# whether to publish synchronously.
|
98
99
|
# @param force_send [Boolean] if true, ignore the configured backend
|
99
100
|
# and send immediately to Kafka.
|
100
|
-
|
101
|
+
# @param topic [String] if specifying the topic
|
102
|
+
def publish_list(payloads, sync: nil, force_send: false, topic: self.topic)
|
101
103
|
return if Deimos.config.kafka.seed_brokers.blank? ||
|
102
104
|
Deimos.config.producers.disabled ||
|
103
105
|
Deimos.producers_disabled?(self)
|
@@ -110,7 +112,7 @@ module Deimos
|
|
110
112
|
payloads: payloads
|
111
113
|
) do
|
112
114
|
messages = Array(payloads).map { |p| Deimos::Message.new(p, self) }
|
113
|
-
messages.each(
|
115
|
+
messages.each { |m| _process_message(m, topic) }
|
114
116
|
messages.in_groups_of(MAX_BATCH_SIZE, false) do |batch|
|
115
117
|
self.produce_batch(backend_class, batch)
|
116
118
|
end
|
@@ -163,7 +165,8 @@ module Deimos
|
|
163
165
|
private
|
164
166
|
|
165
167
|
# @param message [Message]
|
166
|
-
|
168
|
+
# @param topic [String]
|
169
|
+
def _process_message(message, topic)
|
167
170
|
# this violates the Law of Demeter but it has to happen in a very
|
168
171
|
# specific order and requires a bunch of methods on the producer
|
169
172
|
# to work correctly.
|
@@ -175,7 +178,7 @@ module Deimos
|
|
175
178
|
message.payload = nil if message.payload.blank?
|
176
179
|
message.coerce_fields(encoder)
|
177
180
|
message.encoded_key = _encode_key(message.key)
|
178
|
-
message.topic =
|
181
|
+
message.topic = topic
|
179
182
|
message.encoded_payload = if message.payload.nil?
|
180
183
|
nil
|
181
184
|
else
|
@@ -15,7 +15,7 @@ module Deimos
|
|
15
15
|
|
16
16
|
# @override
|
17
17
|
def encode_payload(payload, schema: nil, topic: nil)
|
18
|
-
avro_turf_messaging.encode(payload, schema_name: schema, subject: topic)
|
18
|
+
avro_turf_messaging.encode(payload, schema_name: schema, subject: topic || schema)
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
data/lib/deimos/test_helpers.rb
CHANGED
@@ -30,18 +30,19 @@ module Deimos
|
|
30
30
|
d_config.consumers.reraise_errors = true
|
31
31
|
d_config.kafka.seed_brokers ||= ['test_broker']
|
32
32
|
d_config.schema.backend = Deimos.schema_backend_class.mock_backend
|
33
|
+
d_config.producers.backend = :test
|
33
34
|
end
|
34
35
|
end
|
35
|
-
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
config.before(:each) do
|
38
|
+
client = double('client').as_null_object
|
39
|
+
allow(client).to receive(:time) do |*_args, &block|
|
40
|
+
block.call
|
41
|
+
end
|
42
|
+
Deimos::Backends::Test.sent_messages.clear
|
41
43
|
end
|
42
|
-
Deimos.configure { |c| c.producers.backend = :test }
|
43
|
-
Deimos::Backends::Test.sent_messages.clear
|
44
44
|
end
|
45
|
+
|
45
46
|
end
|
46
47
|
|
47
48
|
# @deprecated
|
@@ -161,7 +161,7 @@ module Deimos
|
|
161
161
|
# the oldest message, or the last time we processed, whichever comes
|
162
162
|
# last.
|
163
163
|
if message_record
|
164
|
-
record_earliest =
|
164
|
+
record_earliest = message_record.earliest
|
165
165
|
# SQLite gives a string here
|
166
166
|
if record_earliest.is_a?(String)
|
167
167
|
record_earliest = Time.zone.parse(record_earliest)
|
@@ -231,7 +231,7 @@ module Deimos
|
|
231
231
|
return batch if config.compact_topics != :all &&
|
232
232
|
!config.compact_topics.include?(topic)
|
233
233
|
|
234
|
-
batch.reverse.uniq
|
234
|
+
batch.reverse.uniq(&:key).reverse!
|
235
235
|
end
|
236
236
|
end
|
237
237
|
end
|
@@ -28,14 +28,18 @@ module Deimos
|
|
28
28
|
|
29
29
|
# Indicate which schemas should be assigned to actions.
|
30
30
|
# @param actions [Symbol]
|
31
|
+
# @param kwactions [String]
|
31
32
|
# @param request [String]
|
32
33
|
# @param response [String]
|
33
|
-
def schemas(*actions, request: nil, response: nil)
|
34
|
+
def schemas(*actions, request: nil, response: nil, **kwactions)
|
34
35
|
actions.each do |action|
|
35
36
|
request ||= action.to_s.titleize
|
36
37
|
response ||= action.to_s.titleize
|
37
38
|
schema_mapping[action.to_s] = { request: request, response: response }
|
38
39
|
end
|
40
|
+
kwactions.each do |key, val|
|
41
|
+
schema_mapping[key.to_s] = { request: val, response: val }
|
42
|
+
end
|
39
43
|
end
|
40
44
|
|
41
45
|
# @return [Hash<Symbol, String>]
|
data/lib/deimos/version.rb
CHANGED
data/spec/consumer_spec.rb
CHANGED
@@ -34,8 +34,8 @@ module ConsumerTest
|
|
34
34
|
|
35
35
|
it 'should consume a nil message' do
|
36
36
|
test_consume_message(MyConsumer, nil) do |payload, _metadata|
|
37
|
-
|
38
|
-
|
37
|
+
expect(payload).to be_nil
|
38
|
+
end
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'should consume a message idempotently' do
|
data/spec/producer_spec.rb
CHANGED
@@ -102,6 +102,33 @@ module ProducerTest
|
|
102
102
|
expect('my-topic').not_to have_sent('test_id' => 'foo2', 'some_int' => 123)
|
103
103
|
end
|
104
104
|
|
105
|
+
it 'should allow setting the topic from publish_list' do
|
106
|
+
expect(described_class).to receive(:produce_batch).once.with(
|
107
|
+
Deimos::Backends::Test,
|
108
|
+
[
|
109
|
+
Deimos::Message.new({ 'test_id' => 'foo', 'some_int' => 123 },
|
110
|
+
MyProducer,
|
111
|
+
topic: 'a-new-topic',
|
112
|
+
partition_key: 'foo',
|
113
|
+
key: 'foo'),
|
114
|
+
Deimos::Message.new({ 'test_id' => 'bar', 'some_int' => 124 },
|
115
|
+
MyProducer,
|
116
|
+
topic: 'a-new-topic',
|
117
|
+
partition_key: 'bar',
|
118
|
+
key: 'bar')
|
119
|
+
]
|
120
|
+
).and_call_original
|
121
|
+
|
122
|
+
MyProducer.publish_list(
|
123
|
+
[{ 'test_id' => 'foo', 'some_int' => 123 },
|
124
|
+
{ 'test_id' => 'bar', 'some_int' => 124 }],
|
125
|
+
topic: 'a-new-topic'
|
126
|
+
)
|
127
|
+
expect('a-new-topic').to have_sent('test_id' => 'foo', 'some_int' => 123)
|
128
|
+
expect('my-topic').not_to have_sent('test_id' => 'foo', 'some_int' => 123)
|
129
|
+
expect('my-topic').not_to have_sent('test_id' => 'foo2', 'some_int' => 123)
|
130
|
+
end
|
131
|
+
|
105
132
|
it 'should add a message ID' do
|
106
133
|
payload = { 'test_id' => 'foo',
|
107
134
|
'some_int' => 123,
|
data/spec/spec_helper.rb
CHANGED
@@ -183,6 +183,7 @@ RSpec.configure do |config|
|
|
183
183
|
config.before(:each) do
|
184
184
|
Deimos.config.reset!
|
185
185
|
Deimos.configure do |deimos_config|
|
186
|
+
deimos_config.producers.backend = :test
|
186
187
|
deimos_config.phobos_config_file = File.join(File.dirname(__FILE__), 'phobos.yml')
|
187
188
|
deimos_config.schema.path = File.join(File.expand_path(__dir__), 'schemas')
|
188
189
|
deimos_config.consumers.reraise_errors = true
|
@@ -155,6 +155,10 @@ each_db_config(Deimos::Utils::DbProducer) do
|
|
155
155
|
Deimos.configure { |c| c.db_producer.compact_topics = [] }
|
156
156
|
end
|
157
157
|
|
158
|
+
it 'should compact messages when all messages are unique' do
|
159
|
+
Deimos.configure { |c| c.db_producer.compact_topics = %w(my-topic my-topic2) }
|
160
|
+
expect(producer.compact_messages(deduped_batch)).to eq(deduped_batch)
|
161
|
+
end
|
158
162
|
end
|
159
163
|
end
|
160
164
|
|
@@ -17,6 +17,7 @@ RSpec.describe Deimos::Utils::SchemaControllerMixin, type: :controller do
|
|
17
17
|
request_namespace 'com.my-namespace.request'
|
18
18
|
response_namespace 'com.my-namespace.response'
|
19
19
|
schemas :index, :show
|
20
|
+
schemas create: 'CreateTopic'
|
20
21
|
schemas :update, request: 'UpdateRequest', response: 'UpdateResponse'
|
21
22
|
|
22
23
|
# :nodoc:
|
@@ -29,6 +30,11 @@ RSpec.describe Deimos::Utils::SchemaControllerMixin, type: :controller do
|
|
29
30
|
render_schema({ 'response_id' => payload[:request_id] + ' dad' })
|
30
31
|
end
|
31
32
|
|
33
|
+
# :nodoc:
|
34
|
+
def create
|
35
|
+
render_schema({ 'response_id' => payload[:request_id] + ' bro' })
|
36
|
+
end
|
37
|
+
|
32
38
|
# :nodoc:
|
33
39
|
def update
|
34
40
|
render_schema({ 'update_response_id' => payload[:update_request_id] + ' sis' })
|
@@ -65,4 +71,14 @@ RSpec.describe Deimos::Utils::SchemaControllerMixin, type: :controller do
|
|
65
71
|
expect(response_backend.decode(response.body)).to eq({ 'update_response_id' => 'hi sis' })
|
66
72
|
end
|
67
73
|
|
74
|
+
it 'should render the correct response for create' do
|
75
|
+
request_backend = Deimos.schema_backend(schema: 'CreateTopic',
|
76
|
+
namespace: 'com.my-namespace.request')
|
77
|
+
response_backend = Deimos.schema_backend(schema: 'CreateTopic',
|
78
|
+
namespace: 'com.my-namespace.response')
|
79
|
+
request.content_type = 'avro/binary'
|
80
|
+
post :create, params: { id: 1 }, body: request_backend.encode({ 'request_id' => 'hi' })
|
81
|
+
expect(response_backend.decode(response.body)).to eq({ 'response_id' => 'hi bro' })
|
82
|
+
end
|
83
|
+
|
68
84
|
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: 1.8.
|
4
|
+
version: 1.8.2.pre.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Orner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avro_turf
|
@@ -349,6 +349,7 @@ files:
|
|
349
349
|
- docs/CONFIGURATION.md
|
350
350
|
- docs/DATABASE_BACKEND.md
|
351
351
|
- docs/PULL_REQUEST_TEMPLATE.md
|
352
|
+
- docs/UPGRADING.md
|
352
353
|
- lib/deimos.rb
|
353
354
|
- lib/deimos/active_record_consume/batch_consumption.rb
|
354
355
|
- lib/deimos/active_record_consume/batch_slicer.rb
|
@@ -453,8 +454,10 @@ files:
|
|
453
454
|
- spec/schemas/com/my-namespace/Wibble.avsc
|
454
455
|
- spec/schemas/com/my-namespace/Widget.avsc
|
455
456
|
- spec/schemas/com/my-namespace/WidgetTheSecond.avsc
|
457
|
+
- spec/schemas/com/my-namespace/request/CreateTopic.avsc
|
456
458
|
- spec/schemas/com/my-namespace/request/Index.avsc
|
457
459
|
- spec/schemas/com/my-namespace/request/UpdateRequest.avsc
|
460
|
+
- spec/schemas/com/my-namespace/response/CreateTopic.avsc
|
458
461
|
- spec/schemas/com/my-namespace/response/Index.avsc
|
459
462
|
- spec/schemas/com/my-namespace/response/UpdateResponse.avsc
|
460
463
|
- spec/spec_helper.rb
|
@@ -487,7 +490,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
487
490
|
- !ruby/object:Gem::Version
|
488
491
|
version: 1.3.1
|
489
492
|
requirements: []
|
490
|
-
rubygems_version: 3.1.
|
493
|
+
rubygems_version: 3.1.2
|
491
494
|
signing_key:
|
492
495
|
specification_version: 4
|
493
496
|
summary: Kafka libraries for Ruby.
|
@@ -534,8 +537,10 @@ test_files:
|
|
534
537
|
- spec/schemas/com/my-namespace/Wibble.avsc
|
535
538
|
- spec/schemas/com/my-namespace/Widget.avsc
|
536
539
|
- spec/schemas/com/my-namespace/WidgetTheSecond.avsc
|
540
|
+
- spec/schemas/com/my-namespace/request/CreateTopic.avsc
|
537
541
|
- spec/schemas/com/my-namespace/request/Index.avsc
|
538
542
|
- spec/schemas/com/my-namespace/request/UpdateRequest.avsc
|
543
|
+
- spec/schemas/com/my-namespace/response/CreateTopic.avsc
|
539
544
|
- spec/schemas/com/my-namespace/response/Index.avsc
|
540
545
|
- spec/schemas/com/my-namespace/response/UpdateResponse.avsc
|
541
546
|
- spec/spec_helper.rb
|