table_sync 6.5.1 → 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 +96 -89
- 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 +5 -5
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,44 +1,44 @@
|
|
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 (>= 0
|
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.1.
|
14
|
-
actionpack (= 7.1.
|
15
|
-
activesupport (= 7.1.
|
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
18
|
zeitwerk (~> 2.6)
|
19
|
-
actionmailbox (7.1.
|
20
|
-
actionpack (= 7.1.
|
21
|
-
activejob (= 7.1.
|
22
|
-
activerecord (= 7.1.
|
23
|
-
activestorage (= 7.1.
|
24
|
-
activesupport (= 7.1.
|
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)
|
25
25
|
mail (>= 2.7.1)
|
26
26
|
net-imap
|
27
27
|
net-pop
|
28
28
|
net-smtp
|
29
|
-
actionmailer (7.1.
|
30
|
-
actionpack (= 7.1.
|
31
|
-
actionview (= 7.1.
|
32
|
-
activejob (= 7.1.
|
33
|
-
activesupport (= 7.1.
|
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)
|
34
34
|
mail (~> 2.5, >= 2.5.4)
|
35
35
|
net-imap
|
36
36
|
net-pop
|
37
37
|
net-smtp
|
38
38
|
rails-dom-testing (~> 2.2)
|
39
|
-
actionpack (7.1.
|
40
|
-
actionview (= 7.1.
|
41
|
-
activesupport (= 7.1.
|
39
|
+
actionpack (7.1.5.1)
|
40
|
+
actionview (= 7.1.5.1)
|
41
|
+
activesupport (= 7.1.5.1)
|
42
42
|
nokogiri (>= 1.8.5)
|
43
43
|
racc
|
44
44
|
rack (>= 2.2.4)
|
@@ -46,60 +46,64 @@ GEM
|
|
46
46
|
rack-test (>= 0.6.3)
|
47
47
|
rails-dom-testing (~> 2.2)
|
48
48
|
rails-html-sanitizer (~> 1.6)
|
49
|
-
actiontext (7.1.
|
50
|
-
actionpack (= 7.1.
|
51
|
-
activerecord (= 7.1.
|
52
|
-
activestorage (= 7.1.
|
53
|
-
activesupport (= 7.1.
|
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)
|
54
54
|
globalid (>= 0.6.0)
|
55
55
|
nokogiri (>= 1.8.5)
|
56
|
-
actionview (7.1.
|
57
|
-
activesupport (= 7.1.
|
56
|
+
actionview (7.1.5.1)
|
57
|
+
activesupport (= 7.1.5.1)
|
58
58
|
builder (~> 3.1)
|
59
59
|
erubi (~> 1.11)
|
60
60
|
rails-dom-testing (~> 2.2)
|
61
61
|
rails-html-sanitizer (~> 1.6)
|
62
|
-
activejob (7.1.
|
63
|
-
activesupport (= 7.1.
|
62
|
+
activejob (7.1.5.1)
|
63
|
+
activesupport (= 7.1.5.1)
|
64
64
|
globalid (>= 0.3.6)
|
65
|
-
activemodel (7.1.
|
66
|
-
activesupport (= 7.1.
|
67
|
-
activerecord (7.1.
|
68
|
-
activemodel (= 7.1.
|
69
|
-
activesupport (= 7.1.
|
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
70
|
timeout (>= 0.4.0)
|
71
|
-
activestorage (7.1.
|
72
|
-
actionpack (= 7.1.
|
73
|
-
activejob (= 7.1.
|
74
|
-
activerecord (= 7.1.
|
75
|
-
activesupport (= 7.1.
|
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)
|
76
76
|
marcel (~> 1.0)
|
77
|
-
activesupport (7.1.
|
77
|
+
activesupport (7.1.5.1)
|
78
78
|
base64
|
79
|
+
benchmark (>= 0.3)
|
79
80
|
bigdecimal
|
80
81
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
81
82
|
connection_pool (>= 2.2.5)
|
82
83
|
drb
|
83
84
|
i18n (>= 1.6, < 2)
|
85
|
+
logger (>= 1.4.2)
|
84
86
|
minitest (>= 5.1)
|
85
87
|
mutex_m
|
88
|
+
securerandom (>= 0.3)
|
86
89
|
tzinfo (~> 2.0)
|
87
90
|
amq-protocol (2.3.2)
|
88
91
|
ast (2.4.2)
|
89
92
|
base64 (0.2.0)
|
93
|
+
benchmark (0.4.0)
|
90
94
|
bigdecimal (3.1.8)
|
91
95
|
builder (3.3.0)
|
92
96
|
bundler-audit (0.9.1)
|
93
97
|
bundler (>= 1.2.0, < 3)
|
94
98
|
thor (~> 1.0)
|
95
|
-
bunny (2.
|
99
|
+
bunny (2.23.0)
|
96
100
|
amq-protocol (~> 2.3, >= 2.3.1)
|
97
101
|
sorted_set (~> 1, >= 1.0.2)
|
98
102
|
coderay (1.1.3)
|
99
103
|
concurrent-ruby (1.3.4)
|
100
104
|
connection_pool (2.4.1)
|
101
105
|
crass (1.0.6)
|
102
|
-
date (3.
|
106
|
+
date (3.4.1)
|
103
107
|
diff-lcs (1.5.0)
|
104
108
|
docile (1.4.0)
|
105
109
|
drb (2.2.1)
|
@@ -108,14 +112,21 @@ GEM
|
|
108
112
|
activesupport (>= 6.1)
|
109
113
|
i18n (1.14.6)
|
110
114
|
concurrent-ruby (~> 1.0)
|
111
|
-
io-console (0.
|
112
|
-
irb (1.14.
|
115
|
+
io-console (0.8.0)
|
116
|
+
irb (1.14.2)
|
113
117
|
rdoc (>= 4.0.0)
|
114
118
|
reline (>= 0.4.2)
|
115
119
|
json (2.6.3)
|
116
|
-
|
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)
|
117
127
|
rails (>= 4.2)
|
118
|
-
|
128
|
+
logger (1.6.3)
|
129
|
+
loofah (2.23.1)
|
119
130
|
crass (~> 1.0.2)
|
120
131
|
nokogiri (>= 1.12.0)
|
121
132
|
mail (2.8.1)
|
@@ -128,10 +139,10 @@ GEM
|
|
128
139
|
ruby2_keywords (~> 0.0.2)
|
129
140
|
method_source (1.1.0)
|
130
141
|
mini_mime (1.1.5)
|
131
|
-
mini_portile2 (2.8.
|
132
|
-
minitest (5.25.
|
133
|
-
mutex_m (0.
|
134
|
-
net-imap (0.
|
142
|
+
mini_portile2 (2.8.8)
|
143
|
+
minitest (5.25.4)
|
144
|
+
mutex_m (0.3.0)
|
145
|
+
net-imap (0.5.2)
|
135
146
|
date
|
136
147
|
net-protocol
|
137
148
|
net-pop (0.1.2)
|
@@ -140,8 +151,8 @@ GEM
|
|
140
151
|
timeout
|
141
152
|
net-smtp (0.5.0)
|
142
153
|
net-protocol
|
143
|
-
nio4r (2.7.
|
144
|
-
nokogiri (1.
|
154
|
+
nio4r (2.7.4)
|
155
|
+
nokogiri (1.17.2)
|
145
156
|
mini_portile2 (~> 2.8.2)
|
146
157
|
racc (~> 1.4)
|
147
158
|
parallel (1.23.0)
|
@@ -152,13 +163,14 @@ GEM
|
|
152
163
|
pry (0.14.2)
|
153
164
|
coderay (~> 1.1)
|
154
165
|
method_source (~> 1.0)
|
155
|
-
psych (5.1
|
166
|
+
psych (5.2.1)
|
167
|
+
date
|
156
168
|
stringio
|
157
|
-
rabbit_messaging (
|
169
|
+
rabbit_messaging (1.1.0)
|
158
170
|
bunny (~> 2.0)
|
171
|
+
kicks (~> 3)
|
159
172
|
lamian
|
160
|
-
rails (>=
|
161
|
-
sneakers (~> 2.0)
|
173
|
+
rails (>= 6.1)
|
162
174
|
tainbox
|
163
175
|
racc (1.8.1)
|
164
176
|
rack (3.1.8)
|
@@ -166,33 +178,32 @@ GEM
|
|
166
178
|
rack (>= 3.0.0)
|
167
179
|
rack-test (2.1.0)
|
168
180
|
rack (>= 1.3)
|
169
|
-
rackup (2.1
|
181
|
+
rackup (2.2.1)
|
170
182
|
rack (>= 3)
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
activesupport (= 7.1.4.1)
|
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)
|
184
195
|
bundler (>= 1.15.0)
|
185
|
-
railties (= 7.1.
|
196
|
+
railties (= 7.1.5.1)
|
186
197
|
rails-dom-testing (2.2.0)
|
187
198
|
activesupport (>= 5.0.0)
|
188
199
|
minitest
|
189
200
|
nokogiri (>= 1.6)
|
190
|
-
rails-html-sanitizer (1.6.
|
201
|
+
rails-html-sanitizer (1.6.2)
|
191
202
|
loofah (~> 2.21)
|
192
|
-
nokogiri (
|
193
|
-
railties (7.1.
|
194
|
-
actionpack (= 7.1.
|
195
|
-
activesupport (= 7.1.
|
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)
|
196
207
|
irb
|
197
208
|
rackup (>= 1.0.0)
|
198
209
|
rake (>= 12.2)
|
@@ -201,12 +212,12 @@ GEM
|
|
201
212
|
rainbow (3.1.1)
|
202
213
|
rake (13.2.1)
|
203
214
|
rbtree (0.4.6)
|
204
|
-
rdoc (6.
|
215
|
+
rdoc (6.9.1)
|
205
216
|
psych (>= 4.0.0)
|
206
217
|
regexp_parser (2.8.1)
|
207
|
-
reline (0.
|
218
|
+
reline (0.6.0)
|
208
219
|
io-console (~> 0.5)
|
209
|
-
rexml (3.3.
|
220
|
+
rexml (3.3.9)
|
210
221
|
rspec (3.12.0)
|
211
222
|
rspec-core (~> 3.12.0)
|
212
223
|
rspec-expectations (~> 3.12.0)
|
@@ -257,11 +268,14 @@ GEM
|
|
257
268
|
rubocop (~> 1.0)
|
258
269
|
ruby-progressbar (1.13.0)
|
259
270
|
ruby2_keywords (0.0.5)
|
271
|
+
securerandom (0.4.1)
|
260
272
|
self_data (1.3.0)
|
261
273
|
sequel (5.71.0)
|
262
|
-
serverengine (2.0
|
274
|
+
serverengine (2.4.0)
|
275
|
+
base64 (~> 0.1)
|
276
|
+
logger (~> 1.4)
|
263
277
|
sigdump (~> 0.2.2)
|
264
|
-
set (1.
|
278
|
+
set (1.1.1)
|
265
279
|
sigdump (0.2.5)
|
266
280
|
simplecov (0.22.0)
|
267
281
|
docile (~> 1.1)
|
@@ -270,25 +284,18 @@ GEM
|
|
270
284
|
simplecov-html (0.12.3)
|
271
285
|
simplecov-lcov (0.8.0)
|
272
286
|
simplecov_json_formatter (0.1.4)
|
273
|
-
sneakers (2.11.0)
|
274
|
-
bunny (~> 2.12)
|
275
|
-
concurrent-ruby (~> 1.0)
|
276
|
-
rake
|
277
|
-
serverengine (~> 2.0.5)
|
278
|
-
thor
|
279
287
|
sorted_set (1.0.3)
|
280
288
|
rbtree
|
281
289
|
set (~> 1.0)
|
282
|
-
stringio (3.1.
|
290
|
+
stringio (3.1.2)
|
283
291
|
tainbox (2.1.2)
|
284
292
|
activesupport
|
285
293
|
thor (1.3.2)
|
286
294
|
timecop (0.9.7)
|
287
|
-
timeout (0.4.
|
295
|
+
timeout (0.4.3)
|
288
296
|
tzinfo (2.0.6)
|
289
297
|
concurrent-ruby (~> 1.0)
|
290
298
|
unicode-display_width (2.4.2)
|
291
|
-
webrick (1.8.2)
|
292
299
|
websocket-driver (0.7.6)
|
293
300
|
websocket-extensions (>= 0.1.0)
|
294
301
|
websocket-extensions (0.1.5)
|
@@ -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", ">= 0
|
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
|
@@ -30,14 +30,14 @@ dependencies:
|
|
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
|
- - ">="
|