table_sync 4.1.0 → 4.2.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/Gemfile.lock +4 -4
- data/lib/table_sync/receiving/handler.rb +28 -13
- data/lib/table_sync/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d5af530003a4144653d1866fda0a581a5ecf021cbcd8e7c2a29028c0e838eb2
|
4
|
+
data.tar.gz: 836de51df89dc99294bd8be65eeaf4e00cba6bdb22071170bef42372c4984a70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2558335ef49a853d8d0d12878cdb42cfb91d4bf7dc7838f22c4853dbf09a22aa60569c420eaee0f5a667f21ea55c02b4a62d3c9d7a4299128d2a6d4b47d7b76a
|
7
|
+
data.tar.gz: d24f3e8e2cab9f946a37296261d531a44b3ea6e660aa1a9424e0685c9ba2ffff73130e6b9661f3ff76a0636eab9c877e4f7b18ce2c1b7b65326bfb5d2434df48
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,26 @@
|
|
1
1
|
# Changelog
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## [4.2.2] - 2020-11-20
|
5
|
+
### Fixed
|
6
|
+
- potential data corruption with batches
|
7
|
+
|
8
|
+
## [4.2.1] - 2020-11-20
|
9
|
+
### Fixed
|
10
|
+
- bug with sorting data in handler, it was bad idea to use `.hash` replaced to `.to_s`
|
11
|
+
|
12
|
+
## [4.2.0] - 2020-11-19
|
13
|
+
|
14
|
+
- No changes. Just stabilization release.
|
15
|
+
|
16
|
+
## [4.1.2] - 2020-11-19
|
17
|
+
### Fixed
|
18
|
+
- bug with sorting data in handler
|
19
|
+
|
20
|
+
## [4.1.1] - 2020-11-06
|
21
|
+
### Fixed
|
22
|
+
- dead locks in receiving module (see: `spec/receiving/handler_spec.rb#avoid dead locks`)
|
23
|
+
|
4
24
|
## [4.1.0] - 2020-11-02
|
5
25
|
### Changed
|
6
26
|
- move `TableSync::Instrument.notify` from models to the handler
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
table_sync (4.
|
4
|
+
table_sync (4.2.2)
|
5
5
|
memery
|
6
6
|
rabbit_messaging (~> 0.3)
|
7
7
|
rails
|
@@ -84,7 +84,7 @@ GEM
|
|
84
84
|
crass (1.0.6)
|
85
85
|
diff-lcs (1.4.4)
|
86
86
|
docile (1.3.2)
|
87
|
-
erubi (1.
|
87
|
+
erubi (1.10.0)
|
88
88
|
exception_notification (4.4.3)
|
89
89
|
actionmailer (>= 4.0, < 7)
|
90
90
|
activesupport (>= 4.0, < 7)
|
@@ -119,11 +119,11 @@ GEM
|
|
119
119
|
pry (0.13.1)
|
120
120
|
coderay (~> 1.1)
|
121
121
|
method_source (~> 1.0)
|
122
|
-
rabbit_messaging (0.
|
122
|
+
rabbit_messaging (0.9.0)
|
123
123
|
bunny (~> 2.0)
|
124
124
|
exception_notification
|
125
125
|
lamian
|
126
|
-
rails
|
126
|
+
rails (>= 5.2)
|
127
127
|
sneakers (~> 2.0)
|
128
128
|
tainbox
|
129
129
|
rack (2.2.3)
|
@@ -23,6 +23,8 @@ class TableSync::Receiving::Handler < Rabbit::EventHandler
|
|
23
23
|
|
24
24
|
validate_data(data, target_keys: target_keys)
|
25
25
|
|
26
|
+
data.sort_by! { |row| row.values_at(*target_keys).to_s }
|
27
|
+
|
26
28
|
params = { data: data, target_keys: target_keys, version_key: version_key }
|
27
29
|
|
28
30
|
if event == :update
|
@@ -53,16 +55,20 @@ class TableSync::Receiving::Handler < Rabbit::EventHandler
|
|
53
55
|
end
|
54
56
|
|
55
57
|
def configs
|
56
|
-
@configs ||=
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
58
|
+
@configs ||= begin
|
59
|
+
configs = self.class.configs[model]
|
60
|
+
configs = configs.sort_by { |config| "#{config.model.schema}.#{config.model.table}" }
|
61
|
+
configs.map do |config|
|
62
|
+
::TableSync::Receiving::ConfigDecorator.new(
|
63
|
+
config: config,
|
64
|
+
# next parameters will be send to each proc-options from config
|
65
|
+
event: event,
|
66
|
+
model: model,
|
67
|
+
version: version,
|
68
|
+
project_id: project_id,
|
69
|
+
raw_data: data,
|
70
|
+
)
|
71
|
+
end
|
66
72
|
end
|
67
73
|
end
|
68
74
|
|
@@ -99,9 +105,18 @@ class TableSync::Receiving::Handler < Rabbit::EventHandler
|
|
99
105
|
end
|
100
106
|
|
101
107
|
if data.uniq { |row| row.slice(*target_keys) }.size != data.size
|
102
|
-
raise TableSync::DataError.new(
|
103
|
-
|
104
|
-
|
108
|
+
raise TableSync::DataError.new(data, target_keys, "Duplicate rows found!")
|
109
|
+
end
|
110
|
+
|
111
|
+
keys_sample = data[0].keys
|
112
|
+
keys_diff = data.each_with_object(Set.new) do |row, set|
|
113
|
+
(row.keys - keys_sample | keys_sample - row.keys).each(&set.method(:add))
|
114
|
+
end
|
115
|
+
|
116
|
+
unless keys_diff.empty?
|
117
|
+
raise TableSync::DataError.new(data, target_keys, <<~MESSAGE)
|
118
|
+
Bad batch structure, check keys: #{keys_diff.to_a}
|
119
|
+
MESSAGE
|
105
120
|
end
|
106
121
|
end
|
107
122
|
|
data/lib/table_sync/version.rb
CHANGED
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: 4.
|
4
|
+
version: 4.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Umbrellio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: memery
|