table_sync 6.6.3 → 6.7.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4d1d604c8c1a1763773507a30a2b40e1d8c6cfc36db1d55bc678f17ceb4e514
4
- data.tar.gz: 86bea118946a433c2105ec1a0a439ff16283002bbf6c678987341faa0a59a206
3
+ metadata.gz: d79554682d06782ddf6862863e32666de78430b0ba10dce09b67158c68eba906
4
+ data.tar.gz: 808d0c20dc4a35e1cd39778be65e0116c954d5bbeb68f4ebee81b35064d6028d
5
5
  SHA512:
6
- metadata.gz: 15dd05d1f45a0ed1227ae4b9f39141d549ccb3e6e24b34be3b22c69669b54c1e25ae41eebde4a760d30a2729ba7c923561296e1e64ceb2d77f76df6dd0d6b471
7
- data.tar.gz: 7d275fb8fcc32aefcea932b2c5f2dcd4e289889214141423fe5842bfda5eb4399d6cd3dcb1482aa12fd976ea9c7863c12ac8d9fe704aa021954ba5cb8a7f8d7d
6
+ metadata.gz: f6d8bc62fd1821244ceac8dc144fe9c5fc19a606bcd76cdcf6f55aa26d0926601affa3b56a6572205f2272f22d1f5d6959b0c86477cef6052a020ff28d69d8f2
7
+ data.tar.gz: 82ce14b2f01727197358cbd280f08168603772109c67150e419af5fe50af320504c9b4bb4ded0e4a1c6cb8129747d72112b4107f14f53cf2a0ff3a3ba462d30e
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [6.7.0] - 2025-01-30
5
+ ### Fixed
6
+ - Removed `tainbox` gem from dependencies
7
+ - `rabbit_messaging` gem version is now locked to `>= 1.6.3`
8
+
4
9
  ## [6.6.1] - 2025-01-30
5
10
  ### Fixed
6
11
  - Delete table_name and schema_name as required for TableSync::Publishing::Raw
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- table_sync (6.6.3)
4
+ table_sync (6.7.0)
5
5
  memery
6
- rabbit_messaging (>= 1.1.0)
6
+ rabbit_messaging (>= 1.6.3)
7
7
  rails
8
8
  self_data
9
9
 
@@ -148,6 +148,22 @@ GEM
148
148
  nokogiri (1.18.8)
149
149
  mini_portile2 (~> 2.8.2)
150
150
  racc (~> 1.4)
151
+ nokogiri (1.18.8-aarch64-linux-gnu)
152
+ racc (~> 1.4)
153
+ nokogiri (1.18.8-aarch64-linux-musl)
154
+ racc (~> 1.4)
155
+ nokogiri (1.18.8-arm-linux-gnu)
156
+ racc (~> 1.4)
157
+ nokogiri (1.18.8-arm-linux-musl)
158
+ racc (~> 1.4)
159
+ nokogiri (1.18.8-arm64-darwin)
160
+ racc (~> 1.4)
161
+ nokogiri (1.18.8-x86_64-darwin)
162
+ racc (~> 1.4)
163
+ nokogiri (1.18.8-x86_64-linux-gnu)
164
+ racc (~> 1.4)
165
+ nokogiri (1.18.8-x86_64-linux-musl)
166
+ racc (~> 1.4)
151
167
  ostruct (0.6.1)
152
168
  parallel (1.27.0)
153
169
  parser (3.3.8.0)
@@ -164,10 +180,9 @@ GEM
164
180
  psych (5.2.6)
165
181
  date
166
182
  stringio
167
- rabbit_messaging (1.5.0)
183
+ rabbit_messaging (1.6.3)
168
184
  bunny (~> 2.0)
169
185
  kicks
170
- tainbox
171
186
  racc (1.8.1)
172
187
  rack (3.1.15)
173
188
  rack-session (2.1.1)
@@ -294,8 +309,6 @@ GEM
294
309
  rbtree
295
310
  set (~> 1.0)
296
311
  stringio (3.1.7)
297
- tainbox (2.1.2)
298
- activesupport
299
312
  thor (1.3.2)
300
313
  timecop (0.9.10)
301
314
  timeout (0.4.3)
@@ -312,7 +325,15 @@ GEM
312
325
  zeitwerk (2.6.18)
313
326
 
314
327
  PLATFORMS
328
+ aarch64-linux-gnu
329
+ aarch64-linux-musl
330
+ arm-linux-gnu
331
+ arm-linux-musl
332
+ arm64-darwin
315
333
  ruby
334
+ x86_64-darwin
335
+ x86_64-linux-gnu
336
+ x86_64-linux-musl
316
337
 
317
338
  DEPENDENCIES
318
339
  activejob
@@ -1,18 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class TableSync::Publishing::Batch
4
- include Tainbox
5
- include TableSync::Utils::RequiredValidator
4
+ attr_accessor :object_class,
5
+ :original_attributes,
6
+ :custom_version,
7
+ :routing_key,
8
+ :headers,
9
+ :event
6
10
 
7
- attribute :object_class
8
- attribute :original_attributes
9
- attribute :custom_version
10
- attribute :routing_key
11
- attribute :headers
11
+ def initialize(attrs = {})
12
+ attrs = attrs.with_indifferent_access
12
13
 
13
- attribute :event, default: :update
14
+ self.object_class = attrs[:object_class]
15
+ self.original_attributes = attrs[:original_attributes]
16
+ self.custom_version = attrs[:custom_version]
17
+ self.routing_key = attrs[:routing_key]
18
+ self.headers = attrs[:headers]
19
+ self.event = attrs.fetch(:event, :update).to_sym
14
20
 
15
- require_attributes :object_class, :original_attributes
21
+ validate_required_attributes!
22
+ end
16
23
 
17
24
  def publish_later
18
25
  job.perform_later(job_attributes)
@@ -30,6 +37,27 @@ class TableSync::Publishing::Batch
30
37
 
31
38
  private
32
39
 
40
+ def validate_required_attributes!
41
+ missing = []
42
+ missing << :object_class if object_class.nil?
43
+ missing << :original_attributes if original_attributes.nil?
44
+
45
+ unless missing.empty?
46
+ raise ArgumentError, "Some of required attributes is not provided: #{missing.inspect}"
47
+ end
48
+ end
49
+
50
+ def attributes
51
+ {
52
+ object_class: object_class,
53
+ original_attributes: original_attributes,
54
+ custom_version: custom_version,
55
+ routing_key: routing_key,
56
+ headers: headers,
57
+ event: event,
58
+ }
59
+ end
60
+
33
61
  # JOB
34
62
 
35
63
  def job
@@ -2,17 +2,18 @@
2
2
 
3
3
  module TableSync::Publishing::Message
4
4
  class Base
5
- include Tainbox
5
+ attr_accessor :custom_version,
6
+ :object_class,
7
+ :original_attributes,
8
+ :event
6
9
 
7
10
  attr_reader :objects
8
11
 
9
- attribute :custom_version
10
- attribute :object_class
11
- attribute :original_attributes
12
- attribute :event
13
-
14
- def initialize(params)
15
- super
12
+ def initialize(params = {})
13
+ self.custom_version = params[:custom_version]
14
+ self.object_class = params[:object_class]
15
+ self.original_attributes = params[:original_attributes]
16
+ self.event = params[:event].to_sym
16
17
 
17
18
  @objects = find_or_init_objects
18
19
 
@@ -2,12 +2,18 @@
2
2
 
3
3
  module TableSync::Publishing::Message
4
4
  class Batch < Base
5
- attribute :headers
6
- attribute :routing_key
5
+ attr_accessor :headers, :routing_key
6
+
7
+ def initialize(params = {})
8
+ super
9
+
10
+ self.headers = params[:headers]
11
+ self.routing_key = params[:routing_key]
12
+ end
7
13
 
8
14
  def params
9
15
  TableSync::Publishing::Params::Batch.new(
10
- attributes.slice(:object_class, :headers, :routing_key).compact,
16
+ { object_class:, headers:, routing_key: }.compact,
11
17
  ).construct
12
18
  end
13
19
  end
@@ -2,17 +2,25 @@
2
2
 
3
3
  module TableSync::Publishing::Message
4
4
  class Raw
5
- include Tainbox
5
+ attr_accessor :model_name,
6
+ :table_name,
7
+ :schema_name,
8
+ :original_attributes,
9
+ :routing_key,
10
+ :headers,
11
+ :custom_version,
12
+ :event
6
13
 
7
- attribute :model_name
8
- attribute :table_name
9
- attribute :schema_name
10
- attribute :original_attributes
11
-
12
- attribute :routing_key
13
- attribute :headers
14
- attribute :custom_version
15
- attribute :event
14
+ def initialize(params = {})
15
+ self.model_name = params[:model_name]
16
+ self.table_name = params[:table_name]
17
+ self.schema_name = params[:schema_name]
18
+ self.original_attributes = params[:original_attributes]
19
+ self.routing_key = params[:routing_key]
20
+ self.headers = params[:headers]
21
+ self.custom_version = params[:custom_version]
22
+ self.event = params[:event]
23
+ end
16
24
 
17
25
  def publish
18
26
  Rabbit.publish(message_params)
@@ -49,7 +57,7 @@ module TableSync::Publishing::Message
49
57
 
50
58
  def params
51
59
  TableSync::Publishing::Params::Raw.new(
52
- attributes.slice(:model_name, :headers, :routing_key).compact,
60
+ { model_name:, headers:, routing_key: }.compact,
53
61
  ).construct
54
62
  end
55
63
  end
@@ -2,13 +2,27 @@
2
2
 
3
3
  module TableSync::Publishing::Params
4
4
  class Batch < Base
5
- include Tainbox
5
+ attr_accessor :object_class
6
+ attr_writer :exchange_name, :routing_key, :headers
6
7
 
7
- attribute :object_class
8
+ def initialize(attrs = {})
9
+ self.object_class = attrs[:object_class]
10
+ @exchange_name = attrs[:exchange_name]
11
+ @routing_key = attrs[:routing_key]
12
+ @headers = attrs[:headers]
13
+ end
14
+
15
+ def exchange_name
16
+ @exchange_name || TableSync.exchange_name
17
+ end
8
18
 
9
- attribute :exchange_name, default: -> { TableSync.exchange_name }
10
- attribute :routing_key, default: -> { calculated_routing_key }
11
- attribute :headers, default: -> { calculated_headers }
19
+ def routing_key
20
+ @routing_key || calculated_routing_key
21
+ end
22
+
23
+ def headers
24
+ @headers || calculated_headers
25
+ end
12
26
 
13
27
  private
14
28
 
@@ -2,8 +2,13 @@
2
2
 
3
3
  module TableSync::Publishing::Params
4
4
  class Raw < Batch
5
- attribute :model_name
5
+ attr_accessor :model_name
6
6
 
7
7
  alias_method :object_class, :model_name
8
+
9
+ def initialize(attrs = {})
10
+ super
11
+ self.model_name = attrs[:model_name]
12
+ end
8
13
  end
9
14
  end
@@ -1,18 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class TableSync::Publishing::Raw
4
- include Tainbox
5
4
  include TableSync::Utils::RequiredValidator
6
5
 
7
- attribute :model_name
8
- attribute :table_name
9
- attribute :schema_name
10
- attribute :original_attributes
11
- attribute :custom_version
12
- attribute :routing_key
13
- attribute :headers
6
+ attr_accessor :model_name,
7
+ :table_name,
8
+ :schema_name,
9
+ :original_attributes,
10
+ :custom_version,
11
+ :routing_key,
12
+ :headers,
13
+ :event
14
14
 
15
- attribute :event, default: :update
15
+ def initialize(attributes = {})
16
+ attributes = attributes.with_indifferent_access
17
+
18
+ self.model_name = attributes[:model_name]
19
+ self.table_name = attributes[:table_name]
20
+ self.schema_name = attributes[:schema_name]
21
+ self.original_attributes = attributes[:original_attributes]
22
+ self.custom_version = attributes[:custom_version]
23
+ self.routing_key = attributes[:routing_key]
24
+ self.headers = attributes[:headers]
25
+ self.event = attributes.fetch(:event, :update).to_sym
26
+ end
16
27
 
17
28
  require_attributes :model_name, :original_attributes
18
29
 
@@ -23,4 +34,19 @@ class TableSync::Publishing::Raw
23
34
  def message
24
35
  TableSync::Publishing::Message::Raw.new(attributes)
25
36
  end
37
+
38
+ private
39
+
40
+ def attributes
41
+ {
42
+ model_name: model_name,
43
+ table_name: table_name,
44
+ schema_name: schema_name,
45
+ original_attributes: original_attributes,
46
+ custom_version: custom_version,
47
+ routing_key: routing_key,
48
+ headers: headers,
49
+ event: event,
50
+ }
51
+ end
26
52
  end
@@ -1,14 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class TableSync::Publishing::Single
4
- include Tainbox
5
4
  include Memery
6
5
 
7
- attribute :object_class
8
- attribute :original_attributes
9
- attribute :debounce_time
10
- attribute :custom_version
11
- attribute :event, Symbol, default: :update
6
+ attr_accessor :object_class,
7
+ :original_attributes,
8
+ :debounce_time,
9
+ :custom_version,
10
+ :event
11
+
12
+ def initialize(attrs = {})
13
+ attrs = attrs.with_indifferent_access
14
+
15
+ self.object_class = attrs[:object_class]
16
+ self.original_attributes = attrs[:original_attributes]
17
+ self.debounce_time = attrs[:debounce_time]
18
+ self.custom_version = attrs[:custom_version]
19
+ self.event = attrs.fetch(:event, :update)
20
+ end
12
21
 
13
22
  # expect job to have perform_at method
14
23
  # debounce destroyed event
@@ -40,6 +49,16 @@ class TableSync::Publishing::Single
40
49
 
41
50
  private
42
51
 
52
+ def attributes
53
+ {
54
+ object_class: object_class,
55
+ original_attributes: original_attributes,
56
+ debounce_time: debounce_time,
57
+ custom_version: custom_version,
58
+ event: event,
59
+ }
60
+ end
61
+
43
62
  # JOB
44
63
 
45
64
  def job
@@ -3,10 +3,16 @@
3
3
  class TableSync::Receiving::Handler < Rabbit::EventHandler
4
4
  extend TableSync::Receiving::DSL
5
5
 
6
- # Rabbit::EventHandler uses Tainbox and performs `handler.new(message).call`
7
- attribute :event
8
- attribute :model
9
- attribute :version
6
+ attr_accessor :version
7
+ attr_reader :event, :model
8
+
9
+ def initialize(message)
10
+ super
11
+
12
+ self.event = message.data[:event]
13
+ self.model = message.data[:model]
14
+ self.version = message.data[:version]
15
+ end
10
16
 
11
17
  def call
12
18
  configs.each do |config|
@@ -40,22 +46,22 @@ class TableSync::Receiving::Handler < Rabbit::EventHandler
40
46
  private
41
47
 
42
48
  # redefine setter from Rabbit::EventHandler
43
- def data=(data)
44
- super(Array.wrap(data[:attributes]))
49
+ def data=(raw_data)
50
+ super(Array.wrap(raw_data[:attributes]))
45
51
  end
46
52
 
47
53
  def event=(event_name)
48
54
  event_name = event_name.to_sym
49
55
 
50
56
  if event_name.in?(TableSync::Event::VALID_RESOLVED_EVENTS)
51
- super
57
+ @event = event_name
52
58
  else
53
59
  raise TableSync::UndefinedEvent.new(event)
54
60
  end
55
61
  end
56
62
 
57
63
  def model=(model_name)
58
- super(model_name.to_s)
64
+ @model = model_name.to_s
59
65
  end
60
66
 
61
67
  def configs
@@ -2,20 +2,16 @@
2
2
 
3
3
  module TableSync::Setup
4
4
  class Base
5
- include Tainbox
6
-
7
5
  EVENTS = %i[create update destroy].freeze
8
6
  INVALID_EVENT = Class.new(StandardError)
9
7
  INVALID_CONDITION = Class.new(StandardError)
10
8
 
11
- attribute :object_class
12
- attribute :debounce_time
13
- attribute :on
14
- attribute :if_condition
15
- attribute :unless_condition
9
+ attr_accessor :object_class, :debounce_time, :on, :if_condition, :unless_condition
16
10
 
17
- def initialize(attrs)
18
- super
11
+ def initialize(attrs = {})
12
+ attrs.each do |key, value|
13
+ public_send("#{key}=", value)
14
+ end
19
15
 
20
16
  self.on = Array.wrap(on).map(&:to_sym)
21
17
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TableSync
4
- VERSION = "6.6.3"
4
+ VERSION = "6.7.0"
5
5
  end
data/table_sync.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  end
28
28
 
29
29
  spec.add_dependency "memery"
30
- spec.add_dependency "rabbit_messaging", ">= 1.1.0"
30
+ spec.add_dependency "rabbit_messaging", ">= 1.6.3"
31
31
  spec.add_dependency "rails"
32
32
  spec.add_dependency "self_data"
33
33
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: table_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.6.3
4
+ version: 6.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Umbrellio
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2025-06-25 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: memery
@@ -29,14 +30,14 @@ dependencies:
29
30
  requirements:
30
31
  - - ">="
31
32
  - !ruby/object:Gem::Version
32
- version: 1.1.0
33
+ version: 1.6.3
33
34
  type: :runtime
34
35
  prerelease: false
35
36
  version_requirements: !ruby/object:Gem::Requirement
36
37
  requirements:
37
38
  - - ">="
38
39
  - !ruby/object:Gem::Version
39
- version: 1.1.0
40
+ version: 1.6.3
40
41
  - !ruby/object:Gem::Dependency
41
42
  name: rails
42
43
  requirement: !ruby/object:Gem::Requirement
@@ -134,6 +135,7 @@ homepage: https://github.com/umbrellio/table_sync
134
135
  licenses:
135
136
  - MIT
136
137
  metadata: {}
138
+ post_install_message:
137
139
  rdoc_options: []
138
140
  require_paths:
139
141
  - lib
@@ -148,7 +150,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
150
  - !ruby/object:Gem::Version
149
151
  version: '0'
150
152
  requirements: []
151
- rubygems_version: 3.6.9
153
+ rubygems_version: 3.5.3
154
+ signing_key:
152
155
  specification_version: 4
153
156
  summary: DB Table synchronization between microservices based on Model's event system
154
157
  and RabbitMQ messaging