table_sync 2.1.0 → 4.1.1

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 +70 -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} +4 -4
  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 +136 -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 -338
  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: 00c09777052902dc012d825d79668aeebe130d2fd4fcfefb77d3d33bbb1dc511
4
- data.tar.gz: ec571dc138e800ada7e0f4fd112516caed6f110bbaabcc64cdfb3aac36b81989
3
+ metadata.gz: 5c2a571110c8f306d04bcfb7b796a511b0b78d951228d9d09f7e9c85b10f704a
4
+ data.tar.gz: e69f07af2fbfee19655edd291c78f4c22773aa602d1e5c06b1ccde4b1a6d1cfb
5
5
  SHA512:
6
- metadata.gz: 18ed6af8a53a850c59ec1fbffa2ae9e85d197644528cbde81f8502fce2a88affbedfed071890430f0abbcfa718c11567c0171eef2f90886d6d01ff4db21c10fa
7
- data.tar.gz: ea36659bef94f7cf27109c8882f5f6e5cacc90201032024ce8c41ce0bac3449dfb3172d0ba675b0f5b8d075e82bd9b0807571f49340e2d6e6a62330028c7695f
6
+ metadata.gz: 4f8e01507a1ad943aa26f08d667869d80c2154bd4c0effe8de25b3ca4698cd4b7af67a741fbb81875f7dbc3f45f082ca04abb43a41aa35d340e6409858f5503b
7
+ data.tar.gz: a931a4d842586f703730c96c90bae10b43cea362e17d45ca4c62d27185306e9fc7cdcf18ac6c209c0ecb38ff6f4dc3f38415c1487cad6eea2a3be095c8cede72
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,76 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [4.1.1] - 2020-11-06
5
+ ### Fixed
6
+ - dead locks in receiving module (see: `spec/receiving/handler_spec.rb#avoid dead locks`)
7
+
8
+ ## [4.1.0] - 2020-11-02
9
+ ### Changed
10
+ - move `TableSync::Instrument.notify` from models to the handler
11
+ - fire `TableSync::Instrument.notify` after commit insted of in transaction
12
+
13
+ ## [4.0.0] - 2020-10-23
14
+ ### Returned
15
+ - config inheritance
16
+
17
+ ### Removed
18
+ - TableSync::Plugins
19
+
20
+ ## [3.0.0] - 2020-09-05
21
+ ### Added
22
+ - option `except`
23
+ - `to_model` in receive method
24
+ - TableSync::Utils::InterfaceChecker
25
+
26
+ ### Changed
27
+ - .rubocop.yml
28
+ - documentation
29
+ - modules hierarchy (split receiving and publishing)
30
+ `TableSync::Publisher` -> `TableSync::Publishing::Publisher`
31
+ `TableSync::BatchPublisher` -> `TableSync::Publishing::BatchPublisher`
32
+ `TableSync::ReceivingHandler` -> `TableSync::Receiving::Handler`
33
+ - made data batches processing as native
34
+ - implemented callbacks as options
35
+ - implemented `wrap_receiving` as option
36
+ - type checking in options
37
+ - `before_commit on: event, &block` -> `before_update(&block)` or `before_destroy(&block)`
38
+ - `after_commit on: event, &block` -> `after_commit_on_update(&block)` or `after_commit_on_destroy(&block)`
39
+ - changed parameters in some options:
40
+ add `raw_data`
41
+ `current_row` -> `row`
42
+ ...
43
+ see documents for details
44
+
45
+ ### Removed
46
+ - TableSync::Config::CallbackRegistry
47
+ - TableSync::EventActions
48
+ - TableSync::EventActions::DataWrapper
49
+ - config option `on_destroy`
50
+ - config option `partitions`
51
+ - config option `first_sync_time_key`
52
+
53
+ ## [2.3.0] - 2020-07-22
54
+ ### Added
55
+ - ruby 2.7 in Travis
56
+ - Gemfile.lock
57
+
58
+ ### Changed
59
+ - some fixes to get rid of warnings for ruby 2.7 (implicit conversion of hashes into kwargs will be dropped)
60
+ - TableSync.sync now explicitly expects klass and kwargs (it converts them into hash)
61
+ - TableSync::Instrument.notify now explicitly expects kwargs and delegates them further as kwargs
62
+
63
+ ### Removed
64
+ - ruby 2.3, 2.4 from Travis
65
+
66
+ ## [2.2.0] - 2020-04-12
67
+ ### Added
68
+ - Introduce Plugin ecosystem (**TableSync::Plugins**);
69
+
70
+ ## [2.1.1] - 2020-04-10
71
+ ### Fixed
72
+ - Updated docs for batch_publishing to fully reflect changes in 2.1.0
73
+
4
74
  ## [2.1.0] - 2020-04-09
5
75
  ### Added
6
76
  - **TableSync::BatchPublisher**: custom headers;
@@ -0,0 +1,262 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ table_sync (4.1.1)
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
+ ```