deimos-ruby 1.16.1 → 1.16.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +15 -0
- data/lib/deimos/active_record_producer.rb +7 -0
- data/lib/deimos/version.rb +1 -1
- data/spec/active_record_producer_spec.rb +24 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59c0f6801979649cc677cc485cfc1435d1ef235769784a864eabbc3e35e55573
|
4
|
+
data.tar.gz: 85d9adfa94010a7594a94e8770ee15922a893ecb53ccb600e7911ae9615ff574
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c663849c130074d566875b278b4e6af667c814e1860a24ac531cc163e819aaac399381578a1d93130b9121402ec1f500108155ee20f37be6999df3d496869376
|
7
|
+
data.tar.gz: 6ba7849db0b98b80684381056be5aeb1f6d206ee65e742c8e33c1cdc9cb0f0f150d8f61f868f18e29837ac2e3279d1b2737c244c79201cbec9038da1c7128264
|
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
|
+
# 1.16.2 - 2022-09-07
|
11
|
+
|
12
|
+
- Added support of post_process method in ActiveRecordProducer
|
13
|
+
|
10
14
|
# 1.16.1 - 2022-08-03
|
11
15
|
|
12
16
|
- Fix issues with `enum` schema classes (e.g. equality not working, `to_s` not working)
|
data/README.md
CHANGED
@@ -785,6 +785,21 @@ have one process running at a time. If a particular poll takes longer than
|
|
785
785
|
the poll interval (i.e. interval is set at 1 minute but it takes 75 seconds)
|
786
786
|
the next poll will begin immediately following the first one completing.
|
787
787
|
|
788
|
+
To Post-Process records that are sent to Kafka:
|
789
|
+
|
790
|
+
You need to define one additional method in your producer class to post-process the messages sent to Kafka.
|
791
|
+
|
792
|
+
```ruby
|
793
|
+
class MyProducer < Deimos::ActiveRecordProducer
|
794
|
+
...
|
795
|
+
def post_process(batch)
|
796
|
+
# If you need to do some extra actions with
|
797
|
+
# the collection of elements you just sent to Kafka
|
798
|
+
# write some code here
|
799
|
+
end
|
800
|
+
end
|
801
|
+
```
|
802
|
+
|
788
803
|
## Running consumers
|
789
804
|
|
790
805
|
Deimos includes a rake task. Once it's in your gemfile, just run
|
@@ -44,6 +44,7 @@ module Deimos
|
|
44
44
|
generate_payload(attrs, record).with_indifferent_access
|
45
45
|
end
|
46
46
|
self.publish_list(messages, force_send: force_send)
|
47
|
+
self.post_process(records)
|
47
48
|
end
|
48
49
|
|
49
50
|
# Generate the payload, given a list of attributes or a record..
|
@@ -85,6 +86,12 @@ module Deimos
|
|
85
86
|
time_to
|
86
87
|
)
|
87
88
|
end
|
89
|
+
|
90
|
+
# Post process records after publishing
|
91
|
+
# @param records [Array<ActiveRecord::Base>]
|
92
|
+
def post_process(_records)
|
93
|
+
end
|
94
|
+
|
88
95
|
end
|
89
96
|
end
|
90
97
|
end
|
data/lib/deimos/version.rb
CHANGED
@@ -45,6 +45,24 @@ describe Deimos::ActiveRecordProducer do
|
|
45
45
|
record_class Widget
|
46
46
|
end
|
47
47
|
stub_const('MyProducerWithUniqueID', producer_class)
|
48
|
+
|
49
|
+
producer_class = Class.new(Deimos::ActiveRecordProducer) do
|
50
|
+
schema 'MySchemaWithUniqueId'
|
51
|
+
namespace 'com.my-namespace'
|
52
|
+
topic 'my-topic-with-unique-id'
|
53
|
+
key_config field: :id
|
54
|
+
record_class Widget
|
55
|
+
|
56
|
+
# :nodoc:
|
57
|
+
def self.post_process(batch)
|
58
|
+
batch.each do |message|
|
59
|
+
message.test_id = 'post_processed'
|
60
|
+
message.save!
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
stub_const('MyProducerWithPostProcess', producer_class)
|
48
66
|
end
|
49
67
|
|
50
68
|
describe 'produce' do
|
@@ -85,6 +103,12 @@ describe Deimos::ActiveRecordProducer do
|
|
85
103
|
)
|
86
104
|
end
|
87
105
|
|
106
|
+
it 'should post process the batch of records in #send_events' do
|
107
|
+
widget = Widget.create!(test_id: 'abc3', some_int: 4)
|
108
|
+
MyProducerWithPostProcess.send_events([widget])
|
109
|
+
expect(widget.reload.test_id).to eq('post_processed')
|
110
|
+
end
|
111
|
+
|
88
112
|
end
|
89
113
|
end
|
90
114
|
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.16.
|
4
|
+
version: 1.16.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: 2022-
|
11
|
+
date: 2022-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avro_turf
|