pub_sub_model_sync 1.0.beta1 → 1.0.beta2

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: 13b5f627ef31865359d033508451bca2297f99cf2cba31d2d3b1a0edb5e0120e
4
- data.tar.gz: e273ff16f01bda1cae1ec2d78b8fd33174dadccdc78b4430503bd5ae40a35988
3
+ metadata.gz: 50a27cf5815a6b9be1f38f399e47569d403831d61dec25b7b4ffdc126f6f450e
4
+ data.tar.gz: 3a97f970d4f0ca08387b59b6da53e0be9f2ce3429db3baf41b5f60b004300b6f
5
5
  SHA512:
6
- metadata.gz: 8bbff15963073476121be61b70abc9899b34c88f12d4b0c75e658f9554cb97b7a6adfeeff7eb1b265fcdd46d3ab2a9bfe97274fc9cd2d67b3a7192d28cf52fb8
7
- data.tar.gz: dea3272e6930728975dfa140e5b49355ce799c9361d892f0d2acd5a665a699f16383a930db714f64746f03185726abaa1a477da1ae03a3ca22730e750397dccc
6
+ metadata.gz: ee52cce7dba866949b64882e385e5b88aabe4725a18fe8b8f4abbf156d50bf2dc840421fd94e2a65a4cc1580c12ff2e086378101cdfbac812745949af1e85c6a
7
+ data.tar.gz: ed67b56451d963e63163d1afb03ffd248ad9033bbad9e08b214afc0b15c933608eefb134ca7c67da8c32e55324fe0f1da8dbcc36da440d9f8d5b3c194c41fdf5
data/CHANGELOG.md CHANGED
@@ -14,7 +14,8 @@
14
14
  - Refactor: Renamed `ps_before_sync` into `ps_before_publish`, `ps_skip_sync` into `ps_skip_publish`, `ps_after_sync` into `ps_after_publish`
15
15
  - Refactor: Renamed `payload.attributes` into `payload.info`
16
16
  - Feat: Support for plain Ruby Objects (Non ActiveRecord models)
17
- - Fix: Retry errors for 5 times before exiting notifications listener
17
+ - Fix: Retry errors for 5 times before exiting notifications listener
18
+ - Feat: Added transactions max_buffer
18
19
 
19
20
  # 0.6.0 (March 03, 2021)
20
21
  - feat: add support to include custom payload headers
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pub_sub_model_sync (1.0.beta1)
4
+ pub_sub_model_sync (1.0.beta2)
5
5
  rails
6
6
 
7
7
  GEM
@@ -55,22 +55,28 @@ module PubSubModelSync
55
55
 
56
56
  # @param crud_actions (Symbol|Array<Symbol>): :create, :update, :destroy
57
57
  # @param method_name (Symbol, optional) method to be called
58
- def ps_on_crud_event(crud_actions, method_name = nil, &block) # rubocop:disable Metrics/MethodLength
58
+ def ps_on_crud_event(crud_actions, method_name = nil, &block)
59
59
  callback = ->(action) { method_name ? send(method_name, action) : instance_exec(action, &block) }
60
- commit_name = respond_to?(:before_commit) ? :before_commit : :after_commit
61
60
  Array(crud_actions).each do |action|
62
61
  if action == :destroy
63
62
  after_destroy { instance_exec(action, &callback) }
64
- elsif PubSubModelSync::Config.enable_rails4_before_commit # rails 4 compatibility
65
- define_method("ps_before_#{action}_commit") { instance_exec(action, &callback) }
66
63
  else
67
- send(commit_name, on: action) { instance_exec(action, &callback) }
64
+ ps_crud_define_commit_action(action, callback)
68
65
  end
69
66
  end
70
67
  end
71
68
 
72
69
  private
73
70
 
71
+ def ps_crud_define_commit_action(action, callback)
72
+ commit_name = respond_to?(:before_commit) ? :before_commit : :after_commit
73
+ if PubSubModelSync::Config.enable_rails4_before_commit # rails 4 compatibility
74
+ define_method("ps_before_#{action}_commit") { instance_exec(action, &callback) }
75
+ else
76
+ send(commit_name, on: action) { instance_exec(action, &callback) }
77
+ end
78
+ end
79
+
74
80
  # Initialize calls to start and end pub_sub transactions and deliver all them in the same order
75
81
  def ps_init_transaction_callbacks
76
82
  start_transaction = lambda do
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'pub_sub_model_sync'
4
4
  require 'rails'
5
+ require 'active_record'
5
6
  require 'pub_sub_model_sync/config'
6
7
  module PubSubModelSync
7
8
  class Railtie < ::Rails::Railtie
@@ -8,7 +8,7 @@ end
8
8
  module PubSubModelSync
9
9
  class ServiceRabbit < ServiceBase
10
10
  QUEUE_SETTINGS = { durable: true, auto_delete: false }.freeze
11
- LISTEN_SETTINGS = { manual_ack: true }.freeze
11
+ LISTEN_SETTINGS = { manual_ack: false }.freeze
12
12
  PUBLISH_SETTINGS = {}.freeze
13
13
 
14
14
  # @!attribute topic_names (Array): ['Topic 1', 'Topic 2']
@@ -57,9 +57,11 @@ module PubSubModelSync
57
57
 
58
58
  def deliver_payloads
59
59
  payloads.each do |payload|
60
- PUBLISHER_KLASS.connector_publish(payload)
61
- rescue => e
62
- PUBLISHER_KLASS.send(:notify_error, e, payload)
60
+ begin # rubocop:disable Style/RedundantBegin (ruby 2.4 support)
61
+ PUBLISHER_KLASS.connector_publish(payload)
62
+ rescue => e
63
+ PUBLISHER_KLASS.send(:notify_error, e, payload)
64
+ end
63
65
  end
64
66
  self.payloads = []
65
67
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PubSubModelSync
4
- VERSION = '1.0.beta1'
4
+ VERSION = '1.0.beta2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pub_sub_model_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.beta1
4
+ version: 1.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Owen