table_sync 6.5.0 → 6.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +141 -102
- data/lib/table_sync/instrument_adapter/active_support.rb +3 -3
- data/lib/table_sync/publishing/batch.rb +1 -1
- data/lib/table_sync/publishing/data/objects.rb +7 -6
- data/lib/table_sync/publishing/data/raw.rb +4 -3
- data/lib/table_sync/publishing/message/base.rb +7 -4
- data/lib/table_sync/publishing/message/raw.rb +7 -4
- data/lib/table_sync/publishing/message/single.rb +1 -1
- data/lib/table_sync/publishing/params/base.rb +3 -3
- data/lib/table_sync/publishing/raw.rb +2 -2
- data/lib/table_sync/publishing/single.rb +4 -4
- data/lib/table_sync/receiving/config_decorator.rb +7 -7
- data/lib/table_sync/receiving/dsl.rb +1 -1
- data/lib/table_sync/receiving/handler.rb +20 -20
- data/lib/table_sync/receiving/model/active_record.rb +7 -7
- data/lib/table_sync/receiving/model/sequel.rb +6 -6
- data/lib/table_sync/setup/active_record.rb +1 -1
- data/lib/table_sync/setup/base.rb +1 -1
- data/lib/table_sync/setup/sequel.rb +1 -1
- data/lib/table_sync/utils/proc_array.rb +4 -4
- data/lib/table_sync/version.rb +1 -1
- data/lib/table_sync.rb +1 -1
- data/table_sync.gemspec +2 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4f4fa78f3fda22bfde2334eccf5973a8d21de3c8e928b380a7e5b7b31d5bf12
|
4
|
+
data.tar.gz: d6b827922a20061e2516f5e2abf7adac7572723ac6e74613d9171b619330726f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f47de0a0cf08bd4a3775890850604ea15aace10cc989677bc9e56102007536104656c558609f93354f35d205fc00ac15868f7771bed71d18476618a8c854fe4
|
7
|
+
data.tar.gz: 3d34b8203a510a18dbb91447c74018bad9804917caf19d492b33f4c05163bfbc7d89863581ee19aee9e3a0328d722edf30a62fd63137e927f5c8421789db6379
|
data/.github/workflows/ci.yml
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
# Changelog
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## [6.6.0] - 2024-12-06
|
5
|
+
### Added
|
6
|
+
- Add custom version attributes
|
7
|
+
- Set table_name and schema_name as required for TableSync::Publishing::Raw
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
- `rabbit_messaging` gem version is locked on `~> 1.1.0` in order to provide a way to keep "up-to-date"
|
11
|
+
the actual rabbit_messaging gem version on our projects with table_sync update;
|
12
|
+
|
13
|
+
### Removed
|
14
|
+
- Remove ruby 3.0 from ci workflow
|
15
|
+
|
4
16
|
## [6.5.0] - 2024-03-19
|
5
17
|
### Added
|
6
18
|
- Add ruby 3.3 to ci workflow
|
data/Gemfile.lock
CHANGED
@@ -1,104 +1,132 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
table_sync (6.
|
4
|
+
table_sync (6.6.0)
|
5
5
|
memery
|
6
|
-
rabbit_messaging (
|
6
|
+
rabbit_messaging (>= 1.1.0)
|
7
7
|
rails
|
8
8
|
self_data
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
actioncable (7.
|
14
|
-
actionpack (= 7.
|
15
|
-
activesupport (= 7.
|
13
|
+
actioncable (7.1.5.1)
|
14
|
+
actionpack (= 7.1.5.1)
|
15
|
+
activesupport (= 7.1.5.1)
|
16
16
|
nio4r (~> 2.0)
|
17
17
|
websocket-driver (>= 0.6.1)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
zeitwerk (~> 2.6)
|
19
|
+
actionmailbox (7.1.5.1)
|
20
|
+
actionpack (= 7.1.5.1)
|
21
|
+
activejob (= 7.1.5.1)
|
22
|
+
activerecord (= 7.1.5.1)
|
23
|
+
activestorage (= 7.1.5.1)
|
24
|
+
activesupport (= 7.1.5.1)
|
24
25
|
mail (>= 2.7.1)
|
25
26
|
net-imap
|
26
27
|
net-pop
|
27
28
|
net-smtp
|
28
|
-
actionmailer (7.
|
29
|
-
actionpack (= 7.
|
30
|
-
actionview (= 7.
|
31
|
-
activejob (= 7.
|
32
|
-
activesupport (= 7.
|
29
|
+
actionmailer (7.1.5.1)
|
30
|
+
actionpack (= 7.1.5.1)
|
31
|
+
actionview (= 7.1.5.1)
|
32
|
+
activejob (= 7.1.5.1)
|
33
|
+
activesupport (= 7.1.5.1)
|
33
34
|
mail (~> 2.5, >= 2.5.4)
|
34
35
|
net-imap
|
35
36
|
net-pop
|
36
37
|
net-smtp
|
37
|
-
rails-dom-testing (~> 2.
|
38
|
-
actionpack (7.
|
39
|
-
actionview (= 7.
|
40
|
-
activesupport (= 7.
|
41
|
-
|
38
|
+
rails-dom-testing (~> 2.2)
|
39
|
+
actionpack (7.1.5.1)
|
40
|
+
actionview (= 7.1.5.1)
|
41
|
+
activesupport (= 7.1.5.1)
|
42
|
+
nokogiri (>= 1.8.5)
|
43
|
+
racc
|
44
|
+
rack (>= 2.2.4)
|
45
|
+
rack-session (>= 1.0.1)
|
42
46
|
rack-test (>= 0.6.3)
|
43
|
-
rails-dom-testing (~> 2.
|
44
|
-
rails-html-sanitizer (~> 1.
|
45
|
-
actiontext (7.
|
46
|
-
actionpack (= 7.
|
47
|
-
activerecord (= 7.
|
48
|
-
activestorage (= 7.
|
49
|
-
activesupport (= 7.
|
47
|
+
rails-dom-testing (~> 2.2)
|
48
|
+
rails-html-sanitizer (~> 1.6)
|
49
|
+
actiontext (7.1.5.1)
|
50
|
+
actionpack (= 7.1.5.1)
|
51
|
+
activerecord (= 7.1.5.1)
|
52
|
+
activestorage (= 7.1.5.1)
|
53
|
+
activesupport (= 7.1.5.1)
|
50
54
|
globalid (>= 0.6.0)
|
51
55
|
nokogiri (>= 1.8.5)
|
52
|
-
actionview (7.
|
53
|
-
activesupport (= 7.
|
56
|
+
actionview (7.1.5.1)
|
57
|
+
activesupport (= 7.1.5.1)
|
54
58
|
builder (~> 3.1)
|
55
|
-
erubi (~> 1.
|
56
|
-
rails-dom-testing (~> 2.
|
57
|
-
rails-html-sanitizer (~> 1.
|
58
|
-
activejob (7.
|
59
|
-
activesupport (= 7.
|
59
|
+
erubi (~> 1.11)
|
60
|
+
rails-dom-testing (~> 2.2)
|
61
|
+
rails-html-sanitizer (~> 1.6)
|
62
|
+
activejob (7.1.5.1)
|
63
|
+
activesupport (= 7.1.5.1)
|
60
64
|
globalid (>= 0.3.6)
|
61
|
-
activemodel (7.
|
62
|
-
activesupport (= 7.
|
63
|
-
activerecord (7.
|
64
|
-
activemodel (= 7.
|
65
|
-
activesupport (= 7.
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
65
|
+
activemodel (7.1.5.1)
|
66
|
+
activesupport (= 7.1.5.1)
|
67
|
+
activerecord (7.1.5.1)
|
68
|
+
activemodel (= 7.1.5.1)
|
69
|
+
activesupport (= 7.1.5.1)
|
70
|
+
timeout (>= 0.4.0)
|
71
|
+
activestorage (7.1.5.1)
|
72
|
+
actionpack (= 7.1.5.1)
|
73
|
+
activejob (= 7.1.5.1)
|
74
|
+
activerecord (= 7.1.5.1)
|
75
|
+
activesupport (= 7.1.5.1)
|
71
76
|
marcel (~> 1.0)
|
72
|
-
|
73
|
-
|
77
|
+
activesupport (7.1.5.1)
|
78
|
+
base64
|
79
|
+
benchmark (>= 0.3)
|
80
|
+
bigdecimal
|
74
81
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
82
|
+
connection_pool (>= 2.2.5)
|
83
|
+
drb
|
75
84
|
i18n (>= 1.6, < 2)
|
85
|
+
logger (>= 1.4.2)
|
76
86
|
minitest (>= 5.1)
|
87
|
+
mutex_m
|
88
|
+
securerandom (>= 0.3)
|
77
89
|
tzinfo (~> 2.0)
|
78
90
|
amq-protocol (2.3.2)
|
79
91
|
ast (2.4.2)
|
80
|
-
|
92
|
+
base64 (0.2.0)
|
93
|
+
benchmark (0.4.0)
|
94
|
+
bigdecimal (3.1.8)
|
95
|
+
builder (3.3.0)
|
81
96
|
bundler-audit (0.9.1)
|
82
97
|
bundler (>= 1.2.0, < 3)
|
83
98
|
thor (~> 1.0)
|
84
|
-
bunny (2.
|
99
|
+
bunny (2.23.0)
|
85
100
|
amq-protocol (~> 2.3, >= 2.3.1)
|
86
101
|
sorted_set (~> 1, >= 1.0.2)
|
87
102
|
coderay (1.1.3)
|
88
|
-
concurrent-ruby (1.
|
103
|
+
concurrent-ruby (1.3.4)
|
104
|
+
connection_pool (2.4.1)
|
89
105
|
crass (1.0.6)
|
90
|
-
date (3.
|
106
|
+
date (3.4.1)
|
91
107
|
diff-lcs (1.5.0)
|
92
108
|
docile (1.4.0)
|
93
|
-
|
109
|
+
drb (2.2.1)
|
110
|
+
erubi (1.13.0)
|
94
111
|
globalid (1.2.1)
|
95
112
|
activesupport (>= 6.1)
|
96
|
-
i18n (1.14.
|
113
|
+
i18n (1.14.6)
|
97
114
|
concurrent-ruby (~> 1.0)
|
115
|
+
io-console (0.8.0)
|
116
|
+
irb (1.14.2)
|
117
|
+
rdoc (>= 4.0.0)
|
118
|
+
reline (>= 0.4.2)
|
98
119
|
json (2.6.3)
|
99
|
-
|
120
|
+
kicks (3.1.1)
|
121
|
+
bunny (~> 2.19)
|
122
|
+
concurrent-ruby (~> 1.0)
|
123
|
+
rake (>= 12.3, < 14.0)
|
124
|
+
serverengine (~> 2.1)
|
125
|
+
thor
|
126
|
+
lamian (1.10.0)
|
100
127
|
rails (>= 4.2)
|
101
|
-
|
128
|
+
logger (1.6.3)
|
129
|
+
loofah (2.23.1)
|
102
130
|
crass (~> 1.0.2)
|
103
131
|
nokogiri (>= 1.12.0)
|
104
132
|
mail (2.8.1)
|
@@ -109,21 +137,22 @@ GEM
|
|
109
137
|
marcel (1.0.4)
|
110
138
|
memery (1.5.0)
|
111
139
|
ruby2_keywords (~> 0.0.2)
|
112
|
-
method_source (1.
|
140
|
+
method_source (1.1.0)
|
113
141
|
mini_mime (1.1.5)
|
114
|
-
mini_portile2 (2.8.
|
115
|
-
minitest (5.
|
116
|
-
|
142
|
+
mini_portile2 (2.8.8)
|
143
|
+
minitest (5.25.4)
|
144
|
+
mutex_m (0.3.0)
|
145
|
+
net-imap (0.5.2)
|
117
146
|
date
|
118
147
|
net-protocol
|
119
148
|
net-pop (0.1.2)
|
120
149
|
net-protocol
|
121
|
-
net-protocol (0.2.
|
150
|
+
net-protocol (0.2.2)
|
122
151
|
timeout
|
123
|
-
net-smtp (0.
|
152
|
+
net-smtp (0.5.0)
|
124
153
|
net-protocol
|
125
|
-
nio4r (2.
|
126
|
-
nokogiri (1.
|
154
|
+
nio4r (2.7.4)
|
155
|
+
nokogiri (1.17.2)
|
127
156
|
mini_portile2 (~> 2.8.2)
|
128
157
|
racc (~> 1.4)
|
129
158
|
parallel (1.23.0)
|
@@ -134,49 +163,61 @@ GEM
|
|
134
163
|
pry (0.14.2)
|
135
164
|
coderay (~> 1.1)
|
136
165
|
method_source (~> 1.0)
|
137
|
-
|
166
|
+
psych (5.2.1)
|
167
|
+
date
|
168
|
+
stringio
|
169
|
+
rabbit_messaging (1.1.0)
|
138
170
|
bunny (~> 2.0)
|
171
|
+
kicks (~> 3)
|
139
172
|
lamian
|
140
|
-
rails (>=
|
141
|
-
sneakers (~> 2.0)
|
173
|
+
rails (>= 6.1)
|
142
174
|
tainbox
|
143
|
-
racc (1.
|
144
|
-
rack (
|
175
|
+
racc (1.8.1)
|
176
|
+
rack (3.1.8)
|
177
|
+
rack-session (2.0.0)
|
178
|
+
rack (>= 3.0.0)
|
145
179
|
rack-test (2.1.0)
|
146
180
|
rack (>= 1.3)
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
181
|
+
rackup (2.2.1)
|
182
|
+
rack (>= 3)
|
183
|
+
rails (7.1.5.1)
|
184
|
+
actioncable (= 7.1.5.1)
|
185
|
+
actionmailbox (= 7.1.5.1)
|
186
|
+
actionmailer (= 7.1.5.1)
|
187
|
+
actionpack (= 7.1.5.1)
|
188
|
+
actiontext (= 7.1.5.1)
|
189
|
+
actionview (= 7.1.5.1)
|
190
|
+
activejob (= 7.1.5.1)
|
191
|
+
activemodel (= 7.1.5.1)
|
192
|
+
activerecord (= 7.1.5.1)
|
193
|
+
activestorage (= 7.1.5.1)
|
194
|
+
activesupport (= 7.1.5.1)
|
159
195
|
bundler (>= 1.15.0)
|
160
|
-
railties (= 7.
|
196
|
+
railties (= 7.1.5.1)
|
161
197
|
rails-dom-testing (2.2.0)
|
162
198
|
activesupport (>= 5.0.0)
|
163
199
|
minitest
|
164
200
|
nokogiri (>= 1.6)
|
165
|
-
rails-html-sanitizer (1.6.
|
201
|
+
rails-html-sanitizer (1.6.2)
|
166
202
|
loofah (~> 2.21)
|
167
|
-
nokogiri (
|
168
|
-
railties (7.
|
169
|
-
actionpack (= 7.
|
170
|
-
activesupport (= 7.
|
171
|
-
|
203
|
+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
204
|
+
railties (7.1.5.1)
|
205
|
+
actionpack (= 7.1.5.1)
|
206
|
+
activesupport (= 7.1.5.1)
|
207
|
+
irb
|
208
|
+
rackup (>= 1.0.0)
|
172
209
|
rake (>= 12.2)
|
173
|
-
thor (~> 1.0)
|
174
|
-
zeitwerk (~> 2.
|
210
|
+
thor (~> 1.0, >= 1.2.2)
|
211
|
+
zeitwerk (~> 2.6)
|
175
212
|
rainbow (3.1.1)
|
176
|
-
rake (13.
|
213
|
+
rake (13.2.1)
|
177
214
|
rbtree (0.4.6)
|
215
|
+
rdoc (6.9.1)
|
216
|
+
psych (>= 4.0.0)
|
178
217
|
regexp_parser (2.8.1)
|
179
|
-
|
218
|
+
reline (0.6.0)
|
219
|
+
io-console (~> 0.5)
|
220
|
+
rexml (3.3.9)
|
180
221
|
rspec (3.12.0)
|
181
222
|
rspec-core (~> 3.12.0)
|
182
223
|
rspec-expectations (~> 3.12.0)
|
@@ -227,11 +268,14 @@ GEM
|
|
227
268
|
rubocop (~> 1.0)
|
228
269
|
ruby-progressbar (1.13.0)
|
229
270
|
ruby2_keywords (0.0.5)
|
271
|
+
securerandom (0.4.1)
|
230
272
|
self_data (1.3.0)
|
231
273
|
sequel (5.71.0)
|
232
|
-
serverengine (2.0
|
274
|
+
serverengine (2.4.0)
|
275
|
+
base64 (~> 0.1)
|
276
|
+
logger (~> 1.4)
|
233
277
|
sigdump (~> 0.2.2)
|
234
|
-
set (1.
|
278
|
+
set (1.1.1)
|
235
279
|
sigdump (0.2.5)
|
236
280
|
simplecov (0.22.0)
|
237
281
|
docile (~> 1.1)
|
@@ -240,27 +284,22 @@ GEM
|
|
240
284
|
simplecov-html (0.12.3)
|
241
285
|
simplecov-lcov (0.8.0)
|
242
286
|
simplecov_json_formatter (0.1.4)
|
243
|
-
sneakers (2.11.0)
|
244
|
-
bunny (~> 2.12)
|
245
|
-
concurrent-ruby (~> 1.0)
|
246
|
-
rake
|
247
|
-
serverengine (~> 2.0.5)
|
248
|
-
thor
|
249
287
|
sorted_set (1.0.3)
|
250
288
|
rbtree
|
251
289
|
set (~> 1.0)
|
290
|
+
stringio (3.1.2)
|
252
291
|
tainbox (2.1.2)
|
253
292
|
activesupport
|
254
|
-
thor (1.
|
293
|
+
thor (1.3.2)
|
255
294
|
timecop (0.9.7)
|
256
|
-
timeout (0.4.
|
295
|
+
timeout (0.4.3)
|
257
296
|
tzinfo (2.0.6)
|
258
297
|
concurrent-ruby (~> 1.0)
|
259
298
|
unicode-display_width (2.4.2)
|
260
299
|
websocket-driver (0.7.6)
|
261
300
|
websocket-extensions (>= 0.1.0)
|
262
301
|
websocket-extensions (0.1.5)
|
263
|
-
zeitwerk (2.6.
|
302
|
+
zeitwerk (2.6.18)
|
264
303
|
|
265
304
|
PLATFORMS
|
266
305
|
ruby
|
@@ -6,11 +6,11 @@ module TableSync::InstrumentAdapter
|
|
6
6
|
|
7
7
|
def notify(table:, schema:, event:, direction:, count: 1)
|
8
8
|
::ActiveSupport::Notifications.instrument "tablesync.#{direction}.#{event}",
|
9
|
-
count
|
9
|
+
count:,
|
10
10
|
table: table.to_s,
|
11
11
|
schema: schema.to_s,
|
12
|
-
event
|
13
|
-
direction:
|
12
|
+
event:,
|
13
|
+
direction:
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -2,18 +2,19 @@
|
|
2
2
|
|
3
3
|
module TableSync::Publishing::Data
|
4
4
|
class Objects
|
5
|
-
attr_reader :objects, :event
|
5
|
+
attr_reader :objects, :event, :custom_version
|
6
6
|
|
7
|
-
def initialize(objects:, event:)
|
8
|
-
@objects
|
9
|
-
@event
|
7
|
+
def initialize(objects:, event:, custom_version:)
|
8
|
+
@objects = objects
|
9
|
+
@event = TableSync::Event.new(event)
|
10
|
+
@custom_version = custom_version
|
10
11
|
end
|
11
12
|
|
12
13
|
def construct
|
13
14
|
{
|
14
|
-
model
|
15
|
+
model:,
|
15
16
|
attributes: attributes_for_sync,
|
16
|
-
version: version,
|
17
|
+
version: custom_version || version,
|
17
18
|
event: event.resolve,
|
18
19
|
metadata: event.metadata,
|
19
20
|
}
|
@@ -2,19 +2,20 @@
|
|
2
2
|
|
3
3
|
module TableSync::Publishing::Data
|
4
4
|
class Raw
|
5
|
-
attr_reader :model_name, :attributes_for_sync, :event
|
5
|
+
attr_reader :model_name, :attributes_for_sync, :event, :custom_version
|
6
6
|
|
7
|
-
def initialize(model_name:, attributes_for_sync:, event:)
|
7
|
+
def initialize(model_name:, attributes_for_sync:, event:, custom_version:)
|
8
8
|
@model_name = model_name
|
9
9
|
@attributes_for_sync = attributes_for_sync
|
10
10
|
@event = TableSync::Event.new(event)
|
11
|
+
@custom_version = custom_version
|
11
12
|
end
|
12
13
|
|
13
14
|
def construct
|
14
15
|
{
|
15
16
|
model: model_name,
|
16
17
|
attributes: wrapped_attributes_for_sync,
|
17
|
-
version: version,
|
18
|
+
version: custom_version || version,
|
18
19
|
event: event.resolve,
|
19
20
|
metadata: event.metadata,
|
20
21
|
}
|
@@ -6,6 +6,7 @@ module TableSync::Publishing::Message
|
|
6
6
|
|
7
7
|
attr_reader :objects
|
8
8
|
|
9
|
+
attribute :custom_version
|
9
10
|
attribute :object_class
|
10
11
|
attribute :original_attributes
|
11
12
|
attribute :event
|
@@ -32,19 +33,21 @@ module TableSync::Publishing::Message
|
|
32
33
|
|
33
34
|
def find_or_init_objects
|
34
35
|
TableSync::Publishing::Helpers::Objects.new(
|
35
|
-
object_class
|
36
|
+
object_class:, original_attributes:, event:,
|
36
37
|
).construct_list
|
37
38
|
end
|
38
39
|
|
39
40
|
# MESSAGE PARAMS
|
40
41
|
|
41
42
|
def message_params
|
42
|
-
params.merge(data:
|
43
|
+
params.merge(data:)
|
43
44
|
end
|
44
45
|
|
45
46
|
def data
|
46
47
|
TableSync::Publishing::Data::Objects.new(
|
47
|
-
objects
|
48
|
+
objects:,
|
49
|
+
event:,
|
50
|
+
custom_version:,
|
48
51
|
).construct
|
49
52
|
end
|
50
53
|
|
@@ -60,7 +63,7 @@ module TableSync::Publishing::Message
|
|
60
63
|
TableSync::Instrument.notify(
|
61
64
|
table: model_naming.table,
|
62
65
|
schema: model_naming.schema,
|
63
|
-
event
|
66
|
+
event:,
|
64
67
|
direction: :publish,
|
65
68
|
count: objects.count,
|
66
69
|
)
|
@@ -11,7 +11,7 @@ module TableSync::Publishing::Message
|
|
11
11
|
|
12
12
|
attribute :routing_key
|
13
13
|
attribute :headers
|
14
|
-
|
14
|
+
attribute :custom_version
|
15
15
|
attribute :event
|
16
16
|
|
17
17
|
def publish
|
@@ -26,7 +26,7 @@ module TableSync::Publishing::Message
|
|
26
26
|
TableSync::Instrument.notify(
|
27
27
|
table: table_name,
|
28
28
|
schema: schema_name,
|
29
|
-
event
|
29
|
+
event:,
|
30
30
|
count: original_attributes.count,
|
31
31
|
direction: :publish,
|
32
32
|
)
|
@@ -35,12 +35,15 @@ module TableSync::Publishing::Message
|
|
35
35
|
# MESSAGE PARAMS
|
36
36
|
|
37
37
|
def message_params
|
38
|
-
params.merge(data:
|
38
|
+
params.merge(data:)
|
39
39
|
end
|
40
40
|
|
41
41
|
def data
|
42
42
|
TableSync::Publishing::Data::Raw.new(
|
43
|
-
model_name
|
43
|
+
model_name:,
|
44
|
+
attributes_for_sync: original_attributes,
|
45
|
+
event:,
|
46
|
+
custom_version:,
|
44
47
|
).construct
|
45
48
|
end
|
46
49
|
|
@@ -8,13 +8,13 @@ class TableSync::Publishing::Raw
|
|
8
8
|
attribute :table_name
|
9
9
|
attribute :schema_name
|
10
10
|
attribute :original_attributes
|
11
|
-
|
11
|
+
attribute :custom_version
|
12
12
|
attribute :routing_key
|
13
13
|
attribute :headers
|
14
14
|
|
15
15
|
attribute :event, default: :update
|
16
16
|
|
17
|
-
require_attributes :model_name, :original_attributes
|
17
|
+
require_attributes :model_name, :original_attributes, :table_name, :schema_name
|
18
18
|
|
19
19
|
def publish_now
|
20
20
|
message.publish
|
@@ -7,7 +7,7 @@ class TableSync::Publishing::Single
|
|
7
7
|
attribute :object_class
|
8
8
|
attribute :original_attributes
|
9
9
|
attribute :debounce_time
|
10
|
-
|
10
|
+
attribute :custom_version
|
11
11
|
attribute :event, Symbol, default: :update
|
12
12
|
|
13
13
|
# expect job to have perform_at method
|
@@ -31,10 +31,10 @@ class TableSync::Publishing::Single
|
|
31
31
|
|
32
32
|
memoize def debounce
|
33
33
|
TableSync::Publishing::Helpers::Debounce.new(
|
34
|
-
object_class
|
34
|
+
object_class:,
|
35
35
|
needle: message.object.needle,
|
36
|
-
debounce_time
|
37
|
-
event
|
36
|
+
debounce_time:,
|
37
|
+
event:,
|
38
38
|
)
|
39
39
|
end
|
40
40
|
|
@@ -10,18 +10,18 @@ module TableSync::Receiving
|
|
10
10
|
@config = config
|
11
11
|
|
12
12
|
@default_params = {
|
13
|
-
event
|
14
|
-
model
|
15
|
-
version
|
16
|
-
project_id
|
17
|
-
raw_data
|
13
|
+
event:,
|
14
|
+
model:,
|
15
|
+
version:,
|
16
|
+
project_id:,
|
17
|
+
raw_data:,
|
18
18
|
}
|
19
19
|
end
|
20
20
|
# rubocop:enable Metrics/ParameterLists
|
21
21
|
|
22
|
-
def method_missing(name, **additional_params, &
|
22
|
+
def method_missing(name, **additional_params, &)
|
23
23
|
value = @config.send(name)
|
24
|
-
value.is_a?(Proc) ? value.call(@default_params.merge(additional_params), &
|
24
|
+
value.is_a?(Proc) ? value.call(@default_params.merge(additional_params), &) : value
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -16,7 +16,7 @@ module TableSync::Receiving
|
|
16
16
|
|
17
17
|
TableSync::Utils::InterfaceChecker.new(model).implements(:receiving_model)
|
18
18
|
|
19
|
-
config = ::TableSync::Receiving::Config.new(model
|
19
|
+
config = ::TableSync::Receiving::Config.new(model:, events:)
|
20
20
|
|
21
21
|
config.instance_exec(&block) if block
|
22
22
|
|
@@ -16,22 +16,22 @@ class TableSync::Receiving::Handler < Rabbit::EventHandler
|
|
16
16
|
|
17
17
|
next if data.empty?
|
18
18
|
|
19
|
-
version_key = config.version_key(data:
|
19
|
+
version_key = config.version_key(data:)
|
20
20
|
data.each { |row| row[version_key] = version }
|
21
21
|
|
22
|
-
target_keys = config.target_keys(data:
|
22
|
+
target_keys = config.target_keys(data:)
|
23
23
|
|
24
|
-
validate_data(data, target_keys:
|
24
|
+
validate_data(data, target_keys:)
|
25
25
|
|
26
26
|
data.sort_by! { |row| row.values_at(*target_keys).map { |value| sort_key(value) } }
|
27
27
|
|
28
|
-
params = { data
|
28
|
+
params = { data:, target_keys:, version_key: }
|
29
29
|
|
30
30
|
if event == :update
|
31
|
-
params[:default_values] = config.default_values(data:
|
31
|
+
params[:default_values] = config.default_values(data:)
|
32
32
|
end
|
33
33
|
|
34
|
-
config.wrap_receiving(event
|
34
|
+
config.wrap_receiving(event:, **params) do
|
35
35
|
perform(config, params)
|
36
36
|
end
|
37
37
|
end
|
@@ -64,12 +64,12 @@ class TableSync::Receiving::Handler < Rabbit::EventHandler
|
|
64
64
|
configs = configs.sort_by { |config| "#{config.model.schema}.#{config.model.table}" }
|
65
65
|
configs.map do |config|
|
66
66
|
::TableSync::Receiving::ConfigDecorator.new(
|
67
|
-
config
|
67
|
+
config:,
|
68
68
|
# next parameters will be send to each proc-options from config
|
69
|
-
event
|
70
|
-
model
|
71
|
-
version
|
72
|
-
project_id
|
69
|
+
event:,
|
70
|
+
model:,
|
71
|
+
version:,
|
72
|
+
project_id:,
|
73
73
|
raw_data: data,
|
74
74
|
)
|
75
75
|
end
|
@@ -78,22 +78,22 @@ class TableSync::Receiving::Handler < Rabbit::EventHandler
|
|
78
78
|
|
79
79
|
def processed_data(config)
|
80
80
|
data.filter_map do |row|
|
81
|
-
next if config.skip(row:
|
81
|
+
next if config.skip(row:)
|
82
82
|
|
83
83
|
row = row.dup
|
84
84
|
|
85
|
-
config.mapping_overrides(row:
|
85
|
+
config.mapping_overrides(row:).each do |before, after|
|
86
86
|
row[after] = row.delete(before)
|
87
87
|
end
|
88
88
|
|
89
|
-
config.except(row:
|
89
|
+
config.except(row:).each { |x| row.delete(x) }
|
90
90
|
|
91
|
-
row.merge!(config.additional_data(row:
|
91
|
+
row.merge!(config.additional_data(row:))
|
92
92
|
|
93
|
-
only = config.only(row:
|
93
|
+
only = config.only(row:)
|
94
94
|
row, rest = row.partition { |key, _| key.in?(only) }.map(&:to_h)
|
95
95
|
|
96
|
-
rest_key = config.rest_key(row
|
96
|
+
rest_key = config.rest_key(row:, rest:)
|
97
97
|
(row[rest_key] ||= {}).merge!(rest) if rest_key
|
98
98
|
|
99
99
|
row
|
@@ -139,13 +139,13 @@ class TableSync::Receiving::Handler < Rabbit::EventHandler
|
|
139
139
|
|
140
140
|
model.after_commit do
|
141
141
|
TableSync::Instrument.notify table: model.table, schema: model.schema,
|
142
|
-
count: results.count, event
|
142
|
+
count: results.count, event:, direction: :receive
|
143
143
|
end
|
144
144
|
|
145
145
|
if event == :update
|
146
|
-
model.after_commit { config.after_commit_on_update(**params.merge(results:
|
146
|
+
model.after_commit { config.after_commit_on_update(**params.merge(results:)) }
|
147
147
|
else
|
148
|
-
model.after_commit { config.after_commit_on_destroy(**params.merge(results:
|
148
|
+
model.after_commit { config.after_commit_on_destroy(**params.merge(results:)) }
|
149
149
|
end
|
150
150
|
end
|
151
151
|
end
|
@@ -26,7 +26,7 @@ module TableSync::Receiving::Model
|
|
26
26
|
self.inheritance_column = nil
|
27
27
|
end
|
28
28
|
|
29
|
-
model_naming = ::TableSync::NamingResolver::ActiveRecord.new(table_name:
|
29
|
+
model_naming = ::TableSync::NamingResolver::ActiveRecord.new(table_name:)
|
30
30
|
|
31
31
|
@table = model_naming.table.to_sym
|
32
32
|
@schema = model_naming.schema.to_sym
|
@@ -66,7 +66,7 @@ module TableSync::Receiving::Model
|
|
66
66
|
row = raw_model.lock("FOR NO KEY UPDATE").where(conditions)
|
67
67
|
|
68
68
|
if row.to_a.size > 1
|
69
|
-
raise TableSync::UpsertError.new(data: datum, target_keys
|
69
|
+
raise TableSync::UpsertError.new(data: datum, target_keys:, result: row)
|
70
70
|
end
|
71
71
|
|
72
72
|
row = row.first
|
@@ -99,18 +99,18 @@ module TableSync::Receiving::Model
|
|
99
99
|
result = query.destroy_all.map { |x| row_to_hash(x) }
|
100
100
|
|
101
101
|
if result.size > data.size
|
102
|
-
raise TableSync::DestroyError.new(data
|
102
|
+
raise TableSync::DestroyError.new(data:, target_keys:, result:)
|
103
103
|
end
|
104
104
|
|
105
105
|
result
|
106
106
|
end
|
107
107
|
|
108
|
-
def transaction(&
|
109
|
-
::ActiveRecord::Base.transaction(&
|
108
|
+
def transaction(&)
|
109
|
+
::ActiveRecord::Base.transaction(&)
|
110
110
|
end
|
111
111
|
|
112
|
-
def after_commit(&
|
113
|
-
db.add_transaction_record(AfterCommitWrap.new(&
|
112
|
+
def after_commit(&)
|
113
|
+
db.add_transaction_record(AfterCommitWrap.new(&))
|
114
114
|
end
|
115
115
|
|
116
116
|
private
|
@@ -8,7 +8,7 @@ module TableSync::Receiving::Model
|
|
8
8
|
@raw_model = Class.new(::Sequel::Model(table_name)).tap(&:unrestrict_primary_key)
|
9
9
|
|
10
10
|
model_naming = ::TableSync::NamingResolver::Sequel.new(
|
11
|
-
table_name
|
11
|
+
table_name:,
|
12
12
|
db: @raw_model.db,
|
13
13
|
)
|
14
14
|
|
@@ -46,18 +46,18 @@ module TableSync::Receiving::Model
|
|
46
46
|
result = dataset.returning.where(::Sequel.|(*sanitized_data)).delete
|
47
47
|
|
48
48
|
if result.size > data.size
|
49
|
-
raise TableSync::DestroyError.new(data
|
49
|
+
raise TableSync::DestroyError.new(data:, target_keys:, result:)
|
50
50
|
end
|
51
51
|
|
52
52
|
result
|
53
53
|
end
|
54
54
|
|
55
|
-
def transaction(&
|
56
|
-
db.transaction(&
|
55
|
+
def transaction(&)
|
56
|
+
db.transaction(&)
|
57
57
|
end
|
58
58
|
|
59
|
-
def after_commit(&
|
60
|
-
db.after_commit(&
|
59
|
+
def after_commit(&)
|
60
|
+
db.after_commit(&)
|
61
61
|
end
|
62
62
|
|
63
63
|
private
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class TableSync::Utils::ProcArray < Proc
|
4
|
-
def initialize(&
|
4
|
+
def initialize(&)
|
5
5
|
@array = []
|
6
|
-
super(&
|
6
|
+
super(&)
|
7
7
|
end
|
8
8
|
|
9
9
|
def push(&block)
|
@@ -11,7 +11,7 @@ class TableSync::Utils::ProcArray < Proc
|
|
11
11
|
self
|
12
12
|
end
|
13
13
|
|
14
|
-
def call(*args, &
|
15
|
-
super(@array, args, &
|
14
|
+
def call(*args, &)
|
15
|
+
super(@array, args, &)
|
16
16
|
end
|
17
17
|
end
|
data/lib/table_sync/version.rb
CHANGED
data/lib/table_sync.rb
CHANGED
data/table_sync.gemspec
CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
require "table_sync/version"
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.required_ruby_version = ">= 3.
|
8
|
+
spec.required_ruby_version = ">= 3.1.0"
|
9
9
|
|
10
10
|
spec.name = "table_sync"
|
11
11
|
spec.version = TableSync::VERSION
|
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
end
|
28
28
|
|
29
29
|
spec.add_runtime_dependency "memery"
|
30
|
-
spec.add_runtime_dependency "rabbit_messaging", "
|
30
|
+
spec.add_runtime_dependency "rabbit_messaging", ">= 1.1.0"
|
31
31
|
spec.add_runtime_dependency "rails"
|
32
32
|
spec.add_runtime_dependency "self_data"
|
33
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: table_sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Umbrellio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: memery
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: rabbit_messaging
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.1.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 1.1.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
143
143
|
requirements:
|
144
144
|
- - ">="
|
145
145
|
- !ruby/object:Gem::Version
|
146
|
-
version: 3.
|
146
|
+
version: 3.1.0
|
147
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
148
|
requirements:
|
149
149
|
- - ">="
|