table_sync 1.13.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) 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 -1
  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 +10 -17
  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 +131 -0
  27. data/lib/table_sync/{model → receiving/model}/active_record.rb +37 -23
  28. data/lib/table_sync/{model → receiving/model}/sequel.rb +13 -8
  29. data/lib/table_sync/utils.rb +9 -0
  30. data/lib/table_sync/utils/interface_checker.rb +97 -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 +48 -30
  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/receiving_handler.rb +0 -76
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0dbfc8cab971d182bff7e688066f3020406b378176c2f8ab40e62f79cf2e3c3e
4
- data.tar.gz: 6701e7abc6b3ea3de0999e08f2c5cc20c65c42ae7b14bf5098511db23a71094f
3
+ metadata.gz: 63d56abd7c8729d7301e24bf4da9b6e1b8f4a44c387f3041a746398ed1bb381e
4
+ data.tar.gz: 10344d248c85c9effc5f25ef1442b176a2c90f2135efea3dfaf653df2c53d408
5
5
  SHA512:
6
- metadata.gz: b88bc1cac782a00158289fd6bb7895a8e58b5bb589c9f07d4ac970b79f0798ae84830904a12ce39516b237780ac615b2bf6cb2e2c519e1769182ae7ac7ed7920
7
- data.tar.gz: be89f2b6e4360021b269c9b9c858c89c857007bd147a429cc880e71aebd8c7cbe0a054c84ad6a3b816b375759e7957137b2f8b46cb77c21141e1ad4ede0b9ab7
6
+ metadata.gz: 1c2dc57d1e62c294ffab4e2ec32361b1bcecdc06f3037f6944fb044e19f3fe6f9efe1409b086ab6b8bbe0f5ac801cc609896a5750733bc4536a0f4c11806a008
7
+ data.tar.gz: edb939c55898245a92ac762adbbf933cfd4fb7fc6ebf8e4c0bc1a18398ecd2d354f7604f851206c0c1c7a6b1f2eab4af987a0505a204a6cbdff2966e37257800
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,7 +1,80 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [1.13.1] - 2019-03-24
4
+ ## [4.0.0] - 2020-10-23
5
+ ### Returned
6
+ - config inheritance
7
+
8
+ ### Removed
9
+ - TableSync::Plugins
10
+
11
+ ## [3.0.0] - 2020-09-05
12
+ ### Added
13
+ - option `except`
14
+ - `to_model` in receive method
15
+ - TableSync::Utils::InterfaceChecker
16
+
17
+ ### Changed
18
+ - .rubocop.yml
19
+ - documentation
20
+ - modules hierarchy (split receiving and publishing)
21
+ `TableSync::Publisher` -> `TableSync::Publishing::Publisher`
22
+ `TableSync::BatchPublisher` -> `TableSync::Publishing::BatchPublisher`
23
+ `TableSync::ReceivingHandler` -> `TableSync::Receiving::Handler`
24
+ - made data batches processing as native
25
+ - implemented callbacks as options
26
+ - implemented `wrap_receiving` as option
27
+ - type checking in options
28
+ - `before_commit on: event, &block` -> `before_update(&block)` or `before_destroy(&block)`
29
+ - `after_commit on: event, &block` -> `after_commit_on_update(&block)` or `after_commit_on_destroy(&block)`
30
+ - changed parameters in some options:
31
+ add `raw_data`
32
+ `current_row` -> `row`
33
+ ...
34
+ see documents for details
35
+
36
+ ### Removed
37
+ - TableSync::Config::CallbackRegistry
38
+ - TableSync::EventActions
39
+ - TableSync::EventActions::DataWrapper
40
+ - config option `on_destroy`
41
+ - config option `partitions`
42
+ - config option `first_sync_time_key`
43
+
44
+ ## [2.3.0] - 2020-07-22
45
+ ### Added
46
+ - ruby 2.7 in Travis
47
+ - Gemfile.lock
48
+
49
+ ### Changed
50
+ - some fixes to get rid of warnings for ruby 2.7 (implicit conversion of hashes into kwargs will be dropped)
51
+ - TableSync.sync now explicitly expects klass and kwargs (it converts them into hash)
52
+ - TableSync::Instrument.notify now explicitly expects kwargs and delegates them further as kwargs
53
+
54
+ ### Removed
55
+ - ruby 2.3, 2.4 from Travis
56
+
57
+ ## [2.2.0] - 2020-04-12
58
+ ### Added
59
+ - Introduce Plugin ecosystem (**TableSync::Plugins**);
60
+
61
+ ## [2.1.1] - 2020-04-10
62
+ ### Fixed
63
+ - Updated docs for batch_publishing to fully reflect changes in 2.1.0
64
+
65
+ ## [2.1.0] - 2020-04-09
66
+ ### Added
67
+ - **TableSync::BatchPublisher**: custom headers;
68
+ - **TableSync::BatchPublisher**: custom events;
69
+
70
+ ### Changed
71
+ - Slight changes to specs
72
+
73
+ ## [2.0.0] - 2020-04-06
74
+ ### Changed
75
+ - Sequel publishing hooks: checking for `:destroy` events inside `:if`/`:unless` predicates
76
+
77
+ ## [1.13.1] - 2020-03-24
5
78
  ### Fixed
6
79
  - **TableSync::BatchPublisher**: incorrect `attrs_for_metadata` definition (typo in method name);
7
80
 
@@ -0,0 +1,262 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ table_sync (4.0.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
+ ```