table_sync 5.0.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d78fecdf8f43cfa8a84fb4ce366af5c9a8da236988b66887ef5aff16c40e3f89
4
- data.tar.gz: 47ad42e41cc6b3383977aa63105a8dc7c575115dddd00f868acfb6b4a15f73b5
3
+ metadata.gz: 9e2da80dd5ebdacac4e255dd9aacae603e6c76c5f52677db25fab0e1bb0dc15e
4
+ data.tar.gz: 6edc6c7805c4f9eea01b43fb14dc3bb19e3af906a1016b2308350077935c911a
5
5
  SHA512:
6
- metadata.gz: 17b77342ca100235816dbc5d1dabf9391eb0a612eb5c540776b6e7f234f23da4a50fe802a62e511e4148657f804a6e04159560798f650dfd3fb1c3b8f07cb005
7
- data.tar.gz: 83e53da6b5895ee392a7b0d53e70509ce453c7973a0f08d3b8bd1b7cea7dc50d252a1848506206cbcfef80fa80bc16abea3f1f711ce4806097a540fac31e0bc3
6
+ metadata.gz: 3b2981462066a389651bef3be1a8301ce165d9b25298b0b912f3002a27daef1e566dc932dbe2aa5c89c70806457449c5c189949fd10c4d9efabf69ba37ee5627
7
+ data.tar.gz: 47c419f7dbdcfc4e8517604b4df14aaccf40d67eb2071e5991a6ccf211d6698735c22aad2cfba339b2d1b9d7b45405d7071b04045ac94c17fb8f8dd379d4eeaf
data/CHANGELOG.md CHANGED
@@ -1,6 +1,19 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [5.1.0] - 2021-09-09
5
+
6
+ ### Changed
7
+ - Provide current fired event to wrap receiver. You'll be able to get it with `wrap_receiving(event:, **rest) {}` as usual for `data, target_keys, version_key`
8
+ - Update rails dependencies with patch version
9
+
10
+ ## [5.0.1] - 2021-04-06
11
+ ### Fixed
12
+ - documentation
13
+
14
+ ### Changed
15
+ - update gems
16
+
4
17
  ## [5.0.0] - 2021-03-04
5
18
  ### Fixed
6
19
  - Fix `delete` events being broken when either `#attrs_for_routing_key` or `#attrs_for_metadata` was defined on a model.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- table_sync (5.0.0)
4
+ table_sync (5.1.0)
5
5
  memery
6
6
  rabbit_messaging
7
7
  rails
@@ -10,60 +10,60 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- actioncable (6.1.3)
14
- actionpack (= 6.1.3)
15
- activesupport (= 6.1.3)
13
+ actioncable (6.1.4.1)
14
+ actionpack (= 6.1.4.1)
15
+ activesupport (= 6.1.4.1)
16
16
  nio4r (~> 2.0)
17
17
  websocket-driver (>= 0.6.1)
18
- actionmailbox (6.1.3)
19
- actionpack (= 6.1.3)
20
- activejob (= 6.1.3)
21
- activerecord (= 6.1.3)
22
- activestorage (= 6.1.3)
23
- activesupport (= 6.1.3)
18
+ actionmailbox (6.1.4.1)
19
+ actionpack (= 6.1.4.1)
20
+ activejob (= 6.1.4.1)
21
+ activerecord (= 6.1.4.1)
22
+ activestorage (= 6.1.4.1)
23
+ activesupport (= 6.1.4.1)
24
24
  mail (>= 2.7.1)
25
- actionmailer (6.1.3)
26
- actionpack (= 6.1.3)
27
- actionview (= 6.1.3)
28
- activejob (= 6.1.3)
29
- activesupport (= 6.1.3)
25
+ actionmailer (6.1.4.1)
26
+ actionpack (= 6.1.4.1)
27
+ actionview (= 6.1.4.1)
28
+ activejob (= 6.1.4.1)
29
+ activesupport (= 6.1.4.1)
30
30
  mail (~> 2.5, >= 2.5.4)
31
31
  rails-dom-testing (~> 2.0)
32
- actionpack (6.1.3)
33
- actionview (= 6.1.3)
34
- activesupport (= 6.1.3)
32
+ actionpack (6.1.4.1)
33
+ actionview (= 6.1.4.1)
34
+ activesupport (= 6.1.4.1)
35
35
  rack (~> 2.0, >= 2.0.9)
36
36
  rack-test (>= 0.6.3)
37
37
  rails-dom-testing (~> 2.0)
38
38
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
39
- actiontext (6.1.3)
40
- actionpack (= 6.1.3)
41
- activerecord (= 6.1.3)
42
- activestorage (= 6.1.3)
43
- activesupport (= 6.1.3)
39
+ actiontext (6.1.4.1)
40
+ actionpack (= 6.1.4.1)
41
+ activerecord (= 6.1.4.1)
42
+ activestorage (= 6.1.4.1)
43
+ activesupport (= 6.1.4.1)
44
44
  nokogiri (>= 1.8.5)
45
- actionview (6.1.3)
46
- activesupport (= 6.1.3)
45
+ actionview (6.1.4.1)
46
+ activesupport (= 6.1.4.1)
47
47
  builder (~> 3.1)
48
48
  erubi (~> 1.4)
49
49
  rails-dom-testing (~> 2.0)
50
50
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
51
- activejob (6.1.3)
52
- activesupport (= 6.1.3)
51
+ activejob (6.1.4.1)
52
+ activesupport (= 6.1.4.1)
53
53
  globalid (>= 0.3.6)
54
- activemodel (6.1.3)
55
- activesupport (= 6.1.3)
56
- activerecord (6.1.3)
57
- activemodel (= 6.1.3)
58
- activesupport (= 6.1.3)
59
- activestorage (6.1.3)
60
- actionpack (= 6.1.3)
61
- activejob (= 6.1.3)
62
- activerecord (= 6.1.3)
63
- activesupport (= 6.1.3)
64
- marcel (~> 0.3.1)
65
- mimemagic (~> 0.3.2)
66
- activesupport (6.1.3)
54
+ activemodel (6.1.4.1)
55
+ activesupport (= 6.1.4.1)
56
+ activerecord (6.1.4.1)
57
+ activemodel (= 6.1.4.1)
58
+ activesupport (= 6.1.4.1)
59
+ activestorage (6.1.4.1)
60
+ actionpack (= 6.1.4.1)
61
+ activejob (= 6.1.4.1)
62
+ activerecord (= 6.1.4.1)
63
+ activesupport (= 6.1.4.1)
64
+ marcel (~> 1.0.0)
65
+ mini_mime (>= 1.1.0)
66
+ activesupport (6.1.4.1)
67
67
  concurrent-ruby (~> 1.0, >= 1.0.2)
68
68
  i18n (>= 1.6, < 2)
69
69
  minitest (>= 5.1)
@@ -72,13 +72,14 @@ GEM
72
72
  amq-protocol (2.3.2)
73
73
  ast (2.4.2)
74
74
  builder (3.2.4)
75
- bundler-audit (0.7.0.1)
75
+ bundler-audit (0.8.0)
76
76
  bundler (>= 1.2.0, < 3)
77
- thor (>= 0.18, < 2)
78
- bunny (2.17.0)
77
+ thor (~> 1.0)
78
+ bunny (2.19.0)
79
79
  amq-protocol (~> 2.3, >= 2.3.1)
80
+ sorted_set (~> 1, >= 1.0.2)
80
81
  coderay (1.1.3)
81
- concurrent-ruby (1.1.8)
82
+ concurrent-ruby (1.1.9)
82
83
  crass (1.0.6)
83
84
  diff-lcs (1.4.4)
84
85
  docile (1.3.5)
@@ -86,29 +87,27 @@ GEM
86
87
  exception_notification (4.4.3)
87
88
  actionmailer (>= 4.0, < 7)
88
89
  activesupport (>= 4.0, < 7)
89
- globalid (0.4.2)
90
- activesupport (>= 4.2.0)
91
- i18n (1.8.9)
90
+ globalid (0.5.2)
91
+ activesupport (>= 5.0)
92
+ i18n (1.8.10)
92
93
  concurrent-ruby (~> 1.0)
93
94
  lamian (1.2.0)
94
95
  rails (>= 4.2)
95
- loofah (2.9.0)
96
+ loofah (2.12.0)
96
97
  crass (~> 1.0.2)
97
98
  nokogiri (>= 1.5.9)
98
99
  mail (2.7.1)
99
100
  mini_mime (>= 0.1.1)
100
- marcel (0.3.3)
101
- mimemagic (~> 0.3.2)
102
- memery (1.3.0)
101
+ marcel (1.0.1)
102
+ memery (1.4.1)
103
103
  ruby2_keywords (~> 0.0.2)
104
104
  method_source (1.0.0)
105
- mimemagic (0.3.5)
106
- mini_mime (1.0.2)
107
- mini_portile2 (2.5.0)
105
+ mini_mime (1.1.1)
106
+ mini_portile2 (2.6.1)
108
107
  minitest (5.14.4)
109
- nio4r (2.5.7)
110
- nokogiri (1.11.1)
111
- mini_portile2 (~> 2.5.0)
108
+ nio4r (2.5.8)
109
+ nokogiri (1.12.4)
110
+ mini_portile2 (~> 2.6.1)
112
111
  racc (~> 1.4)
113
112
  parallel (1.20.1)
114
113
  parser (3.0.0.0)
@@ -117,7 +116,7 @@ GEM
117
116
  pry (0.14.0)
118
117
  coderay (~> 1.1)
119
118
  method_source (~> 1.0)
120
- rabbit_messaging (0.9.0)
119
+ rabbit_messaging (0.12.0)
121
120
  bunny (~> 2.0)
122
121
  exception_notification
123
122
  lamian
@@ -128,36 +127,37 @@ GEM
128
127
  rack (2.2.3)
129
128
  rack-test (1.1.0)
130
129
  rack (>= 1.0, < 3)
131
- rails (6.1.3)
132
- actioncable (= 6.1.3)
133
- actionmailbox (= 6.1.3)
134
- actionmailer (= 6.1.3)
135
- actionpack (= 6.1.3)
136
- actiontext (= 6.1.3)
137
- actionview (= 6.1.3)
138
- activejob (= 6.1.3)
139
- activemodel (= 6.1.3)
140
- activerecord (= 6.1.3)
141
- activestorage (= 6.1.3)
142
- activesupport (= 6.1.3)
130
+ rails (6.1.4.1)
131
+ actioncable (= 6.1.4.1)
132
+ actionmailbox (= 6.1.4.1)
133
+ actionmailer (= 6.1.4.1)
134
+ actionpack (= 6.1.4.1)
135
+ actiontext (= 6.1.4.1)
136
+ actionview (= 6.1.4.1)
137
+ activejob (= 6.1.4.1)
138
+ activemodel (= 6.1.4.1)
139
+ activerecord (= 6.1.4.1)
140
+ activestorage (= 6.1.4.1)
141
+ activesupport (= 6.1.4.1)
143
142
  bundler (>= 1.15.0)
144
- railties (= 6.1.3)
143
+ railties (= 6.1.4.1)
145
144
  sprockets-rails (>= 2.0.0)
146
145
  rails-dom-testing (2.0.3)
147
146
  activesupport (>= 4.2.0)
148
147
  nokogiri (>= 1.6)
149
- rails-html-sanitizer (1.3.0)
148
+ rails-html-sanitizer (1.4.2)
150
149
  loofah (~> 2.3)
151
- railties (6.1.3)
152
- actionpack (= 6.1.3)
153
- activesupport (= 6.1.3)
150
+ railties (6.1.4.1)
151
+ actionpack (= 6.1.4.1)
152
+ activesupport (= 6.1.4.1)
154
153
  method_source
155
- rake (>= 0.8.7)
154
+ rake (>= 0.13)
156
155
  thor (~> 1.0)
157
156
  rainbow (3.0.0)
158
- rake (13.0.3)
157
+ rake (13.0.6)
158
+ rbtree (0.4.4)
159
159
  regexp_parser (2.1.1)
160
- rexml (3.2.4)
160
+ rexml (3.2.5)
161
161
  rspec (3.10.0)
162
162
  rspec-core (~> 3.10.0)
163
163
  rspec-expectations (~> 3.10.0)
@@ -204,11 +204,12 @@ GEM
204
204
  rubocop-sequel (0.2.0)
205
205
  rubocop (~> 1.0)
206
206
  ruby-progressbar (1.11.0)
207
- ruby2_keywords (0.0.4)
207
+ ruby2_keywords (0.0.5)
208
208
  self_data (1.2.1)
209
- sequel (5.42.0)
209
+ sequel (5.43.0)
210
210
  serverengine (2.0.7)
211
211
  sigdump (~> 0.2.2)
212
+ set (1.0.1)
212
213
  sigdump (0.2.4)
213
214
  simplecov (0.21.2)
214
215
  docile (~> 1.1)
@@ -223,6 +224,9 @@ GEM
223
224
  rake
224
225
  serverengine (~> 2.0.5)
225
226
  thor
227
+ sorted_set (1.0.3)
228
+ rbtree
229
+ set (~> 1.0)
226
230
  sprockets (4.0.2)
227
231
  concurrent-ruby (~> 1.0)
228
232
  rack (> 1, < 3)
@@ -237,7 +241,7 @@ GEM
237
241
  tzinfo (2.0.4)
238
242
  concurrent-ruby (~> 1.0)
239
243
  unicode-display_width (2.0.0)
240
- websocket-driver (0.7.3)
244
+ websocket-driver (0.7.5)
241
245
  websocket-extensions (>= 0.1.0)
242
246
  websocket-extensions (0.1.5)
243
247
  zeitwerk (2.4.2)
@@ -262,4 +266,4 @@ DEPENDENCIES
262
266
  timecop
263
267
 
264
268
  BUNDLED WITH
265
- 2.2.11
269
+ 2.2.27
data/docs/publishing.md CHANGED
@@ -41,7 +41,7 @@ Example:
41
41
  ```ruby
42
42
  class TableSync::Job < ActiveJob::Base
43
43
  def perform(*args)
44
- TableSync::Publisher.new(*args).publish_now
44
+ TableSync::Publishing::Publisher.new(*args).publish_now
45
45
  end
46
46
  end
47
47
  ```
@@ -70,16 +70,16 @@ TableSync.routing_metadata_callable = -> (klass, attributes) { attributes.slice(
70
70
 
71
71
  # Manual publishing
72
72
 
73
- `TableSync::Publisher.new(object_class, original_attributes, confirm: true, state: :updated, debounce_time: 45)`
73
+ `TableSync::Publishing::Publisher.new(object_class, original_attributes, confirm: true, state: :updated, debounce_time: 45)`
74
74
  where state is one of `:created / :updated / :destroyed` and `confirm` is Rabbit's confirm delivery flag and optional param `debounce_time` determines debounce time in seconds, 1 minute by default.
75
75
 
76
76
  # Manual publishing with batches
77
77
 
78
- You can use `TableSync::BatchPublisher` to publish changes in batches (array of hashes in `attributes`).
78
+ You can use `TableSync::Publishing::BatchPublisher` to publish changes in batches (array of hashes in `attributes`).
79
79
 
80
- When using `TableSync::BatchPublisher`,` TableSync.routing_key_callable` is called as follows: `TableSync.routing_key_callable.call(klass, {})`, i.e. empty hash is passed instead of attributes. And `TableSync.routing_metadata_callable` is not called at all: metadata is set to empty hash.
80
+ When using `TableSync::Publishing::BatchPublisher`,` TableSync.routing_key_callable` is called as follows: `TableSync.routing_key_callable.call(klass, {})`, i.e. empty hash is passed instead of attributes. And `TableSync.routing_metadata_callable` is not called at all: metadata is set to empty hash.
81
81
 
82
- `TableSync::BatchPublisher.new(object_class, original_attributes_array, **options)`, where `original_attributes_array` is an array with hash of attributes of published objects and `options` is a hash of options.
82
+ `TableSync::Publishing::BatchPublisher.new(object_class, original_attributes_array, **options)`, where `original_attributes_array` is an array with hash of attributes of published objects and `options` is a hash of options.
83
83
 
84
84
  `options` consists of:
85
85
  - `confirm`, which is a flag for RabbitMQ, `true` by default
@@ -92,7 +92,7 @@ original_attributes_array will be pushed to Rabbit instead of fetching records f
92
92
  Example:
93
93
 
94
94
  ```ruby
95
- TableSync::BatchPublisher.new(
95
+ TableSync::Publishing::BatchPublisher.new(
96
96
  "SomeClass",
97
97
  [{ id: 1 }, { id: 2 }],
98
98
  confirm: false,
@@ -105,11 +105,11 @@ TableSync::BatchPublisher.new(
105
105
 
106
106
  # Manual publishing with batches (Russian)
107
107
 
108
- С помощью класса `TableSync::BatchPublisher` вы можете опубликовать изменения батчами (массивом в `attributes`).
108
+ С помощью класса `TableSync::Publishing::BatchPublisher` вы можете опубликовать изменения батчами (массивом в `attributes`).
109
109
 
110
- При использовании `TableSync::BatchPublisher`, `TableSync.routing_key_callable` вызывается следующим образом: `TableSync.routing_key_callable.call(klass, {})`, то есть вместо аттрибутов передается пустой хэш. А `TableSync.routing_metadata_callable` не вызывается вовсе: в метадате устанавливается пустой хэш.
110
+ При использовании `TableSync::Publishing::BatchPublisher`, `TableSync.routing_key_callable` вызывается следующим образом: `TableSync.routing_key_callable.call(klass, {})`, то есть вместо аттрибутов передается пустой хэш. А `TableSync.routing_metadata_callable` не вызывается вовсе: в метадате устанавливается пустой хэш.
111
111
 
112
- `TableSync::BatchPublisher.new(object_class, original_attributes_array, **options)`, где `original_attributes_array` - массив с аттрибутами публикуемых объектов и `options`- это хэш с дополнительными опциями.
112
+ `TableSync::Publishing::BatchPublisher.new(object_class, original_attributes_array, **options)`, где `original_attributes_array` - массив с аттрибутами публикуемых объектов и `options`- это хэш с дополнительными опциями.
113
113
 
114
114
  `options` состоит из:
115
115
  - `confirm`, флаг для RabbitMQ, по умолчанию - `true`
@@ -121,7 +121,7 @@ TableSync::BatchPublisher.new(
121
121
  Example:
122
122
 
123
123
  ```ruby
124
- TableSync::BatchPublisher.new(
124
+ TableSync::Publishing::BatchPublisher.new(
125
125
  "SomeClass",
126
126
  [{ id: 1 }, { id: 2 }],
127
127
  confirm: false,
data/docs/receiving.md CHANGED
@@ -68,7 +68,7 @@ The method receives following arguments
68
68
  - `events` - array of supported events (optional)
69
69
  - `block` - configuration block with options (optional)
70
70
 
71
- This method implements logic of mapping `source` to `to_table` (or to `to_model`) and allows customizing
71
+ This method implements logic of mapping `source` to `to_table` (or to `to_model`) and allows customizing
72
72
  the event handling logic with provided block.
73
73
  You can use one `source` for a lot of `to_table` or `to_moel`.
74
74
 
@@ -235,12 +235,13 @@ default value is `false`
235
235
  Proc that is used to wrap the receiving logic by custom block of code.
236
236
 
237
237
  ```ruby
238
- wrap_receiving do |data:, target_keys:, version_key:, default_values: {}, &receiving_logic|
238
+ wrap_receiving do |data:, target_keys:, version_key:, default_values: {}, event:, &receiving_logic|
239
239
  receiving_logic.call
240
240
  return makes no sense
241
241
  end
242
242
  ```
243
243
 
244
+ event option is current fired event
244
245
  default value is `proc { |&block| block.call }`
245
246
 
246
247
  #### before_update
@@ -262,15 +263,17 @@ end
262
263
  Perform code after updated data was committed.
263
264
 
264
265
  ```ruby
265
- after_commit_on_update do |data:, target_keys:, version_key:, default_values:|
266
+ after_commit_on_update do |data:, target_keys:, version_key:, default_values:, results:|
266
267
  return makes no sense
267
268
  end
268
269
 
269
- after_commit_on_update do |data:, target_keys:, version_key:, default_values:|
270
+ after_commit_on_update do |data:, target_keys:, version_key:, default_values:, results:|
270
271
  return makes no sense
271
272
  end
272
273
  ```
273
274
 
275
+ - `results` - returned value from `model.upsert`
276
+
274
277
  Сan be defined several times. Execution order guaranteed.
275
278
 
276
279
  #### before_destroy
@@ -292,15 +295,17 @@ end
292
295
  Perform code after destroyed data was committed.
293
296
 
294
297
  ```ruby
295
- after_commit_on_destroy do |data:, target_keys:, version_key:|
298
+ after_commit_on_destroy do |data:, target_keys:, version_key:, results:|
296
299
  return makes no sense
297
300
  end
298
301
 
299
- after_commit_on_destroy do |data:, target_keys:, version_key:|
302
+ after_commit_on_destroy do |data:, target_keys:, version_key:, results:|
300
303
  return makes no sense
301
304
  end
302
305
  ```
303
306
 
307
+ - `results` - returned value from `model.destroy`
308
+
304
309
  Сan be defined several times. Execution order guaranteed.
305
310
 
306
311
  ### Custom model
@@ -31,7 +31,7 @@ class TableSync::Receiving::Handler < Rabbit::EventHandler
31
31
  params[:default_values] = config.default_values(data: data)
32
32
  end
33
33
 
34
- config.wrap_receiving(**params) do
34
+ config.wrap_receiving(event: event, **params) do
35
35
  perform(config, params)
36
36
  end
37
37
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TableSync
4
- VERSION = "5.0.0"
4
+ VERSION = "5.1.0"
5
5
  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: 5.0.0
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Umbrellio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-04 00:00:00.000000000 Z
11
+ date: 2021-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: memery
@@ -317,7 +317,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
317
317
  - !ruby/object:Gem::Version
318
318
  version: '0'
319
319
  requirements: []
320
- rubygems_version: 3.2.11
320
+ rubygems_version: 3.2.3
321
321
  signing_key:
322
322
  specification_version: 4
323
323
  summary: DB Table synchronization between microservices based on Model's event system