table_sync 2.0.0 → 4.1.0

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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.rubocop.yml +26 -1
  4. data/.travis.yml +6 -6
  5. data/CHANGELOG.md +74 -0
  6. data/Gemfile.lock +262 -0
  7. data/LICENSE.md +1 -1
  8. data/README.md +4 -1
  9. data/docs/message_protocol.md +24 -0
  10. data/docs/notifications.md +45 -0
  11. data/docs/publishing.md +147 -0
  12. data/docs/receiving.md +341 -0
  13. data/lib/table_sync.rb +23 -33
  14. data/lib/table_sync/errors.rb +60 -22
  15. data/lib/table_sync/instrument.rb +2 -2
  16. data/lib/table_sync/publishing.rb +11 -0
  17. data/lib/table_sync/{base_publisher.rb → publishing/base_publisher.rb} +1 -1
  18. data/lib/table_sync/{batch_publisher.rb → publishing/batch_publisher.rb} +12 -13
  19. data/lib/table_sync/{orm_adapter → publishing/orm_adapter}/active_record.rb +4 -8
  20. data/lib/table_sync/{orm_adapter → publishing/orm_adapter}/sequel.rb +3 -7
  21. data/lib/table_sync/{publisher.rb → publishing/publisher.rb} +4 -4
  22. data/lib/table_sync/receiving.rb +14 -0
  23. data/lib/table_sync/receiving/config.rb +218 -0
  24. data/lib/table_sync/receiving/config_decorator.rb +27 -0
  25. data/lib/table_sync/receiving/dsl.rb +28 -0
  26. data/lib/table_sync/receiving/handler.rb +132 -0
  27. data/lib/table_sync/{model → receiving/model}/active_record.rb +44 -37
  28. data/lib/table_sync/receiving/model/sequel.rb +83 -0
  29. data/lib/table_sync/utils.rb +9 -0
  30. data/lib/table_sync/utils/interface_checker.rb +103 -0
  31. data/lib/table_sync/utils/proc_array.rb +17 -0
  32. data/lib/table_sync/utils/proc_keywords_resolver.rb +46 -0
  33. data/lib/table_sync/version.rb +1 -1
  34. data/table_sync.gemspec +5 -4
  35. metadata +51 -33
  36. data/docs/synopsis.md +0 -318
  37. data/lib/table_sync/config.rb +0 -105
  38. data/lib/table_sync/config/callback_registry.rb +0 -53
  39. data/lib/table_sync/config_decorator.rb +0 -38
  40. data/lib/table_sync/dsl.rb +0 -25
  41. data/lib/table_sync/event_actions.rb +0 -96
  42. data/lib/table_sync/event_actions/data_wrapper.rb +0 -7
  43. data/lib/table_sync/event_actions/data_wrapper/base.rb +0 -23
  44. data/lib/table_sync/event_actions/data_wrapper/destroy.rb +0 -19
  45. data/lib/table_sync/event_actions/data_wrapper/update.rb +0 -21
  46. data/lib/table_sync/model/sequel.rb +0 -88
  47. data/lib/table_sync/receiving_handler.rb +0 -76
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 839b04ca1021ff94b95f937236437c624efd6bcb63c129b23ec1d60b33ee841a
4
- data.tar.gz: 536a8c08cf0860716afc5c67b3fb7915db971b9fd4af8d94de0fd092fe7d093f
3
+ metadata.gz: d6b452885641883758a131ec14f3a9aa2f8508bb1c3a540b8e78c727a8d86a88
4
+ data.tar.gz: efd055d98480febde524af5af5db5cfefde1b534a5fa40d7b8cb696ac11432ba
5
5
  SHA512:
6
- metadata.gz: 11aa7c9d34b15a3798f9ab80704b873629be9ddadcf8fdd9ae61b74621dac19eecedede6fa5b360875253ce2f2cbf36b674d61fa1e76fd0cab107adf40a5323f
7
- data.tar.gz: 358848e41f3ff97c5ce59d9e4bb0e578a26cd346afddf2fc22c0ff1dcc29204c18905b632ead7f2155b0ed6105e346f5e6dcef4e91ec7e32d4daa45bc89e8fbe
6
+ metadata.gz: bd98bc390f5d04625d98c9c5fac179a9b588830210502727288b74c46f4badf4a177afbcbe02b67bd33cdd7ba8ed7d3fea593e3893e5519f5d2c40c01f3a454e
7
+ data.tar.gz: 230f6a412f0d2d55750a4d1edb75b5c9605730de1c6352d5e5d1e8b4375ed16081fe296f70ace3dff65b54d5b85bc1a18a153119d8a6f7c1994289d5170ddc80
data/.gitignore CHANGED
@@ -9,5 +9,4 @@
9
9
  /spec/reports/
10
10
  /tmp/
11
11
  .ruby-version
12
- Gemfile.lock
13
12
  *.gem
@@ -2,7 +2,7 @@ inherit_gem:
2
2
  rubocop-config-umbrellio: lib/rubocop.yml
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.3
5
+ TargetRubyVersion: 2.5
6
6
  Include:
7
7
  - bin/*
8
8
  - lib/**/*.rb
@@ -10,3 +10,28 @@ AllCops:
10
10
  - Gemfile
11
11
  - Rakefile
12
12
  - table_sync.gemspec
13
+
14
+ Style/Alias:
15
+ Enabled: true
16
+ EnforcedStyle: prefer_alias_method
17
+
18
+ RSpec/ExampleLength:
19
+ Enabled: false
20
+
21
+ Lint/UnusedBlockArgument:
22
+ AllowUnusedKeywordArguments: true
23
+
24
+ Lint/UnusedMethodArgument:
25
+ AllowUnusedKeywordArguments: true
26
+
27
+ Style/AccessorGrouping:
28
+ Enabled: false
29
+
30
+ Style/NumericPredicate:
31
+ Enabled: false
32
+
33
+ Lint/MissingSuper:
34
+ Enabled: false
35
+
36
+ Style/MissingRespondToMissing:
37
+ Enabled: false
@@ -1,13 +1,13 @@
1
1
  language: ruby
2
2
 
3
+ rvm:
4
+ - 2.5
5
+ - 2.6
6
+ - 2.7
7
+ - ruby-head
8
+
3
9
  matrix:
4
10
  fast_finish: true
5
- include:
6
- - rvm: 2.3
7
- - rvm: 2.4
8
- - rvm: 2.5
9
- - rvm: 2.6
10
- - rvm: ruby-head
11
11
  allow_failures:
12
12
  - rvm: ruby-head
13
13
 
@@ -1,6 +1,80 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [4.1.0] - 2020-11-02
5
+ ### Changed
6
+ - move `TableSync::Instrument.notify` from models to the handler
7
+ - fire `TableSync::Instrument.notify` after commit insted of in transaction
8
+
9
+ ## [4.0.0] - 2020-10-23
10
+ ### Returned
11
+ - config inheritance
12
+
13
+ ### Removed
14
+ - TableSync::Plugins
15
+
16
+ ## [3.0.0] - 2020-09-05
17
+ ### Added
18
+ - option `except`
19
+ - `to_model` in receive method
20
+ - TableSync::Utils::InterfaceChecker
21
+
22
+ ### Changed
23
+ - .rubocop.yml
24
+ - documentation
25
+ - modules hierarchy (split receiving and publishing)
26
+ `TableSync::Publisher` -> `TableSync::Publishing::Publisher`
27
+ `TableSync::BatchPublisher` -> `TableSync::Publishing::BatchPublisher`
28
+ `TableSync::ReceivingHandler` -> `TableSync::Receiving::Handler`
29
+ - made data batches processing as native
30
+ - implemented callbacks as options
31
+ - implemented `wrap_receiving` as option
32
+ - type checking in options
33
+ - `before_commit on: event, &block` -> `before_update(&block)` or `before_destroy(&block)`
34
+ - `after_commit on: event, &block` -> `after_commit_on_update(&block)` or `after_commit_on_destroy(&block)`
35
+ - changed parameters in some options:
36
+ add `raw_data`
37
+ `current_row` -> `row`
38
+ ...
39
+ see documents for details
40
+
41
+ ### Removed
42
+ - TableSync::Config::CallbackRegistry
43
+ - TableSync::EventActions
44
+ - TableSync::EventActions::DataWrapper
45
+ - config option `on_destroy`
46
+ - config option `partitions`
47
+ - config option `first_sync_time_key`
48
+
49
+ ## [2.3.0] - 2020-07-22
50
+ ### Added
51
+ - ruby 2.7 in Travis
52
+ - Gemfile.lock
53
+
54
+ ### Changed
55
+ - some fixes to get rid of warnings for ruby 2.7 (implicit conversion of hashes into kwargs will be dropped)
56
+ - TableSync.sync now explicitly expects klass and kwargs (it converts them into hash)
57
+ - TableSync::Instrument.notify now explicitly expects kwargs and delegates them further as kwargs
58
+
59
+ ### Removed
60
+ - ruby 2.3, 2.4 from Travis
61
+
62
+ ## [2.2.0] - 2020-04-12
63
+ ### Added
64
+ - Introduce Plugin ecosystem (**TableSync::Plugins**);
65
+
66
+ ## [2.1.1] - 2020-04-10
67
+ ### Fixed
68
+ - Updated docs for batch_publishing to fully reflect changes in 2.1.0
69
+
70
+ ## [2.1.0] - 2020-04-09
71
+ ### Added
72
+ - **TableSync::BatchPublisher**: custom headers;
73
+ - **TableSync::BatchPublisher**: custom events;
74
+
75
+ ### Changed
76
+ - Slight changes to specs
77
+
4
78
  ## [2.0.0] - 2020-04-06
5
79
  ### Changed
6
80
  - Sequel publishing hooks: checking for `:destroy` events inside `:if`/`:unless` predicates
@@ -0,0 +1,262 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ table_sync (4.1.0)
5
+ memery
6
+ rabbit_messaging (~> 0.3)
7
+ rails
8
+ self_data
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ actioncable (6.0.3.4)
14
+ actionpack (= 6.0.3.4)
15
+ nio4r (~> 2.0)
16
+ websocket-driver (>= 0.6.1)
17
+ actionmailbox (6.0.3.4)
18
+ actionpack (= 6.0.3.4)
19
+ activejob (= 6.0.3.4)
20
+ activerecord (= 6.0.3.4)
21
+ activestorage (= 6.0.3.4)
22
+ activesupport (= 6.0.3.4)
23
+ mail (>= 2.7.1)
24
+ actionmailer (6.0.3.4)
25
+ actionpack (= 6.0.3.4)
26
+ actionview (= 6.0.3.4)
27
+ activejob (= 6.0.3.4)
28
+ mail (~> 2.5, >= 2.5.4)
29
+ rails-dom-testing (~> 2.0)
30
+ actionpack (6.0.3.4)
31
+ actionview (= 6.0.3.4)
32
+ activesupport (= 6.0.3.4)
33
+ rack (~> 2.0, >= 2.0.8)
34
+ rack-test (>= 0.6.3)
35
+ rails-dom-testing (~> 2.0)
36
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
37
+ actiontext (6.0.3.4)
38
+ actionpack (= 6.0.3.4)
39
+ activerecord (= 6.0.3.4)
40
+ activestorage (= 6.0.3.4)
41
+ activesupport (= 6.0.3.4)
42
+ nokogiri (>= 1.8.5)
43
+ actionview (6.0.3.4)
44
+ activesupport (= 6.0.3.4)
45
+ builder (~> 3.1)
46
+ erubi (~> 1.4)
47
+ rails-dom-testing (~> 2.0)
48
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
49
+ activejob (6.0.3.4)
50
+ activesupport (= 6.0.3.4)
51
+ globalid (>= 0.3.6)
52
+ activemodel (6.0.3.4)
53
+ activesupport (= 6.0.3.4)
54
+ activerecord (6.0.3.4)
55
+ activemodel (= 6.0.3.4)
56
+ activesupport (= 6.0.3.4)
57
+ activestorage (6.0.3.4)
58
+ actionpack (= 6.0.3.4)
59
+ activejob (= 6.0.3.4)
60
+ activerecord (= 6.0.3.4)
61
+ marcel (~> 0.3.1)
62
+ activesupport (6.0.3.4)
63
+ concurrent-ruby (~> 1.0, >= 1.0.2)
64
+ i18n (>= 0.7, < 2)
65
+ minitest (~> 5.1)
66
+ tzinfo (~> 1.1)
67
+ zeitwerk (~> 2.2, >= 2.2.2)
68
+ amq-protocol (2.3.2)
69
+ ast (2.4.1)
70
+ builder (3.2.4)
71
+ bundler-audit (0.7.0.1)
72
+ bundler (>= 1.2.0, < 3)
73
+ thor (>= 0.18, < 2)
74
+ bunny (2.17.0)
75
+ amq-protocol (~> 2.3, >= 2.3.1)
76
+ coderay (1.1.3)
77
+ concurrent-ruby (1.1.7)
78
+ coveralls (0.8.23)
79
+ json (>= 1.8, < 3)
80
+ simplecov (~> 0.16.1)
81
+ term-ansicolor (~> 1.3)
82
+ thor (>= 0.19.4, < 2.0)
83
+ tins (~> 1.6)
84
+ crass (1.0.6)
85
+ diff-lcs (1.4.4)
86
+ docile (1.3.2)
87
+ erubi (1.9.0)
88
+ exception_notification (4.4.3)
89
+ actionmailer (>= 4.0, < 7)
90
+ activesupport (>= 4.0, < 7)
91
+ globalid (0.4.2)
92
+ activesupport (>= 4.2.0)
93
+ i18n (1.8.5)
94
+ concurrent-ruby (~> 1.0)
95
+ json (2.3.1)
96
+ lamian (1.2.0)
97
+ rails (>= 4.2)
98
+ loofah (2.7.0)
99
+ crass (~> 1.0.2)
100
+ nokogiri (>= 1.5.9)
101
+ mail (2.7.1)
102
+ mini_mime (>= 0.1.1)
103
+ marcel (0.3.3)
104
+ mimemagic (~> 0.3.2)
105
+ memery (1.3.0)
106
+ ruby2_keywords (~> 0.0.2)
107
+ method_source (1.0.0)
108
+ mimemagic (0.3.5)
109
+ mini_mime (1.0.2)
110
+ mini_portile2 (2.4.0)
111
+ minitest (5.14.2)
112
+ nio4r (2.5.4)
113
+ nokogiri (1.10.10)
114
+ mini_portile2 (~> 2.4.0)
115
+ parallel (1.19.2)
116
+ parser (2.7.1.5)
117
+ ast (~> 2.4.1)
118
+ pg (0.21.0)
119
+ pry (0.13.1)
120
+ coderay (~> 1.1)
121
+ method_source (~> 1.0)
122
+ rabbit_messaging (0.7.1)
123
+ bunny (~> 2.0)
124
+ exception_notification
125
+ lamian
126
+ rails
127
+ sneakers (~> 2.0)
128
+ tainbox
129
+ rack (2.2.3)
130
+ rack-test (1.1.0)
131
+ rack (>= 1.0, < 3)
132
+ rails (6.0.3.4)
133
+ actioncable (= 6.0.3.4)
134
+ actionmailbox (= 6.0.3.4)
135
+ actionmailer (= 6.0.3.4)
136
+ actionpack (= 6.0.3.4)
137
+ actiontext (= 6.0.3.4)
138
+ actionview (= 6.0.3.4)
139
+ activejob (= 6.0.3.4)
140
+ activemodel (= 6.0.3.4)
141
+ activerecord (= 6.0.3.4)
142
+ activestorage (= 6.0.3.4)
143
+ activesupport (= 6.0.3.4)
144
+ bundler (>= 1.3.0)
145
+ railties (= 6.0.3.4)
146
+ sprockets-rails (>= 2.0.0)
147
+ rails-dom-testing (2.0.3)
148
+ activesupport (>= 4.2.0)
149
+ nokogiri (>= 1.6)
150
+ rails-html-sanitizer (1.3.0)
151
+ loofah (~> 2.3)
152
+ railties (6.0.3.4)
153
+ actionpack (= 6.0.3.4)
154
+ activesupport (= 6.0.3.4)
155
+ method_source
156
+ rake (>= 0.8.7)
157
+ thor (>= 0.20.3, < 2.0)
158
+ rainbow (3.0.0)
159
+ rake (13.0.1)
160
+ regexp_parser (1.8.1)
161
+ rexml (3.2.4)
162
+ rspec (3.9.0)
163
+ rspec-core (~> 3.9.0)
164
+ rspec-expectations (~> 3.9.0)
165
+ rspec-mocks (~> 3.9.0)
166
+ rspec-core (3.9.2)
167
+ rspec-support (~> 3.9.3)
168
+ rspec-expectations (3.9.2)
169
+ diff-lcs (>= 1.2.0, < 2.0)
170
+ rspec-support (~> 3.9.0)
171
+ rspec-mocks (3.9.1)
172
+ diff-lcs (>= 1.2.0, < 2.0)
173
+ rspec-support (~> 3.9.0)
174
+ rspec-support (3.9.3)
175
+ rubocop (0.90.0)
176
+ parallel (~> 1.10)
177
+ parser (>= 2.7.1.1)
178
+ rainbow (>= 2.2.2, < 4.0)
179
+ regexp_parser (>= 1.7)
180
+ rexml
181
+ rubocop-ast (>= 0.3.0, < 1.0)
182
+ ruby-progressbar (~> 1.7)
183
+ unicode-display_width (>= 1.4.0, < 2.0)
184
+ rubocop-ast (0.7.1)
185
+ parser (>= 2.7.1.5)
186
+ rubocop-config-umbrellio (0.90.0.93)
187
+ rubocop (= 0.90.0)
188
+ rubocop-performance (= 1.7.1)
189
+ rubocop-rails (= 2.7.0)
190
+ rubocop-rspec (= 1.42.0)
191
+ rubocop-performance (1.7.1)
192
+ rubocop (>= 0.82.0)
193
+ rubocop-rails (2.7.0)
194
+ activesupport (>= 4.2.0)
195
+ rack (>= 1.1)
196
+ rubocop (>= 0.87.0)
197
+ rubocop-rspec (1.42.0)
198
+ rubocop (>= 0.87.0)
199
+ ruby-progressbar (1.10.1)
200
+ ruby2_keywords (0.0.2)
201
+ self_data (1.2.1)
202
+ sequel (5.37.0)
203
+ serverengine (2.0.7)
204
+ sigdump (~> 0.2.2)
205
+ sigdump (0.2.4)
206
+ simplecov (0.16.1)
207
+ docile (~> 1.1)
208
+ json (>= 1.8, < 3)
209
+ simplecov-html (~> 0.10.0)
210
+ simplecov-html (0.10.2)
211
+ sneakers (2.11.0)
212
+ bunny (~> 2.12)
213
+ concurrent-ruby (~> 1.0)
214
+ rake
215
+ serverengine (~> 2.0.5)
216
+ thor
217
+ sprockets (4.0.2)
218
+ concurrent-ruby (~> 1.0)
219
+ rack (> 1, < 3)
220
+ sprockets-rails (3.2.2)
221
+ actionpack (>= 4.0)
222
+ activesupport (>= 4.0)
223
+ sprockets (>= 3.0.0)
224
+ sync (0.5.0)
225
+ tainbox (2.1.2)
226
+ activesupport
227
+ term-ansicolor (1.7.1)
228
+ tins (~> 1.0)
229
+ thor (1.0.1)
230
+ thread_safe (0.3.6)
231
+ timecop (0.9.1)
232
+ tins (1.25.0)
233
+ sync
234
+ tzinfo (1.2.7)
235
+ thread_safe (~> 0.1)
236
+ unicode-display_width (1.7.0)
237
+ websocket-driver (0.7.3)
238
+ websocket-extensions (>= 0.1.0)
239
+ websocket-extensions (0.1.5)
240
+ zeitwerk (2.4.0)
241
+
242
+ PLATFORMS
243
+ ruby
244
+
245
+ DEPENDENCIES
246
+ activejob (>= 6.0)
247
+ activerecord (>= 6.0)
248
+ bundler
249
+ bundler-audit
250
+ coveralls (~> 0.8)
251
+ pg (~> 0.18)
252
+ pry
253
+ rake
254
+ rspec (~> 3.8)
255
+ rubocop-config-umbrellio
256
+ sequel
257
+ simplecov (~> 0.16)
258
+ table_sync!
259
+ timecop
260
+
261
+ BUNDLED WITH
262
+ 2.1.4
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 Umbrellio
3
+ Copyright (c) 2019-2020 Umbrellio
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -20,7 +20,10 @@ require 'table_sync'
20
20
 
21
21
  ## Usage
22
22
 
23
- - [Documentation](docs/synopsis.md)
23
+ - [Message protocol](docs/message_protocol.md)
24
+ - [Publising](docs/publishing.md)
25
+ - [Receiving](docs/receiving.md)
26
+ - [Notifications](docs/notifications.md)
24
27
 
25
28
  ## Contributing
26
29
 
@@ -0,0 +1,24 @@
1
+ # Messages protocol
2
+
3
+ ```
4
+ {
5
+ project_id: "pid",
6
+ data: {
7
+ "event": "update",
8
+ "model": "User",
9
+ "version": 1.23,
10
+ "attributes": [
11
+ {
12
+ "id": "1",
13
+ "name": "user1",
14
+ "email": "user1@example.com"
15
+ },
16
+ {
17
+ "id": "2",
18
+ "name": "user2",
19
+ "email": "user2@example.com"
20
+ }
21
+ ]
22
+ }
23
+ }
24
+ ```