pub_sub_model_sync 1.0.beta1 → 1.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -1
- data/Gemfile.lock +1 -1
- data/lib/pub_sub_model_sync/publisher_concern.rb +11 -5
- data/lib/pub_sub_model_sync/railtie.rb +1 -0
- data/lib/pub_sub_model_sync/service_rabbit.rb +1 -1
- data/lib/pub_sub_model_sync/transaction.rb +5 -3
- data/lib/pub_sub_model_sync/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50a27cf5815a6b9be1f38f399e47569d403831d61dec25b7b4ffdc126f6f450e
|
4
|
+
data.tar.gz: 3a97f970d4f0ca08387b59b6da53e0be9f2ce3429db3baf41b5f60b004300b6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
@@ -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)
|
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
|
-
|
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
|
@@ -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:
|
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
|
-
|
61
|
-
|
62
|
-
|
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
|