nats_wave 1.1.15 → 1.1.16
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/Gemfile.lock +1 -1
- data/lib/nats_wave/adapters/datadog_metrics.rb +1 -1
- data/lib/nats_wave/concerns/mappable.rb +23 -8
- data/lib/nats_wave/configuration.rb +1 -1
- data/lib/nats_wave/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: 70b9abe2ec70949d2ffd0b97d0d2e33688590d8d4bc5c01baa2a555cb0b355e4
|
4
|
+
data.tar.gz: cbef4f7b640670744b71626606a0ad62de313012bfb524e7e406594ff0b31e9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 552e1c4272994c73ab29ed2c714aa7d9e776ef6cd81431a97da99af9609669815ad8af64651a12278154609033f1a1e82c37a9fa921ce400770a2228f56078bb
|
7
|
+
data.tar.gz: 6c2f1a722122a2de176186b58835158764ff0ba4a5913c7d15e0b15b8b15feaba6b053fd12a97acc8d0699b3b2db7f701797679efe5322574e43c1b86b4cd6fd
|
data/Gemfile.lock
CHANGED
@@ -1037,7 +1037,7 @@ module NatsWave
|
|
1037
1037
|
|
1038
1038
|
# Configure publishing with optional custom handler AND auto-publishing callbacks
|
1039
1039
|
def nats_wave_publishes_to(*subjects, **options, &block)
|
1040
|
-
NatsWave.logger.debug "
|
1040
|
+
NatsWave.logger.debug "⚙️#{self.name}: Setting up publishing to subjects: #{subjects.inspect}"
|
1041
1041
|
|
1042
1042
|
# Custom handler is now optional and runs AFTER default behavior
|
1043
1043
|
custom_handler = options[:handler] || block
|
@@ -1062,7 +1062,7 @@ module NatsWave
|
|
1062
1062
|
# Add ActiveRecord callbacks for auto-publishing (only once per model)
|
1063
1063
|
setup_publishing_callbacks_once
|
1064
1064
|
|
1065
|
-
NatsWave.logger.debug "
|
1065
|
+
NatsWave.logger.debug "⚙️#{self.name}: Registered publishing config for subjects: #{subjects}"
|
1066
1066
|
end
|
1067
1067
|
|
1068
1068
|
# Get all subscription configurations
|
@@ -1222,7 +1222,7 @@ module NatsWave
|
|
1222
1222
|
after_commit :trigger_nats_wave_auto_publish_on_destroy, on: :destroy
|
1223
1223
|
|
1224
1224
|
@nats_wave_callbacks_added = true
|
1225
|
-
NatsWave.logger.debug "
|
1225
|
+
NatsWave.logger.debug "⚙️#{self.name}: Added publishing callbacks"
|
1226
1226
|
end
|
1227
1227
|
|
1228
1228
|
# Create a subscription handler that processes data and calls custom handler AFTER auto-sync
|
@@ -1231,25 +1231,40 @@ module NatsWave
|
|
1231
1231
|
|
1232
1232
|
lambda do |message|
|
1233
1233
|
begin
|
1234
|
-
NatsWave.logger.debug "
|
1234
|
+
NatsWave.logger.debug "⚙️Processing subscription message for #{model_class.name}"
|
1235
1235
|
|
1236
1236
|
# Extract the raw data
|
1237
1237
|
raw_data = message['data'] || {}
|
1238
1238
|
model_name = message['model']
|
1239
1239
|
action = message['action']
|
1240
1240
|
|
1241
|
+
# If action is empty, try to extract from subject
|
1242
|
+
if action.blank? && message['subject']
|
1243
|
+
# Extract action from subject like "ims.item.create" -> "create"
|
1244
|
+
subject_parts = message['subject'].split('.')
|
1245
|
+
action = subject_parts.last if subject_parts.any?
|
1246
|
+
end
|
1247
|
+
|
1248
|
+
NatsWave.logger.debug "✅Extracted action: '#{action}' from message"
|
1249
|
+
|
1250
|
+
# Handle nested data structure
|
1251
|
+
if raw_data['data'].is_a?(Hash)
|
1252
|
+
raw_data = raw_data['data']
|
1253
|
+
NatsWave.logger.debug "⚙️Using nested data structure"
|
1254
|
+
end
|
1255
|
+
|
1241
1256
|
# Process the data through mappings and transformations
|
1242
1257
|
processed_data = model_class.process_subscription_data(raw_data, config)
|
1243
1258
|
|
1244
1259
|
# Always perform auto-sync first (if enabled)
|
1245
1260
|
if config[:auto_sync]
|
1246
|
-
NatsWave.logger.debug "
|
1261
|
+
NatsWave.logger.debug "⚙️Performing auto-sync first"
|
1247
1262
|
model_class.perform_auto_sync(model_name, action, processed_data, config)
|
1248
1263
|
end
|
1249
1264
|
|
1250
1265
|
# Then call custom handler if provided (optional)
|
1251
1266
|
if config[:custom_handler]
|
1252
|
-
NatsWave.logger.debug "
|
1267
|
+
NatsWave.logger.debug "⚙️Calling custom subscription handler after auto-sync"
|
1253
1268
|
config[:custom_handler].call(model_name, action, processed_data, message)
|
1254
1269
|
end
|
1255
1270
|
|
@@ -1272,7 +1287,7 @@ module NatsWave
|
|
1272
1287
|
|
1273
1288
|
# Check conditions (only for publishing)
|
1274
1289
|
if config[:conditions].any? && !evaluate_conditions(config[:conditions])
|
1275
|
-
NatsWave.logger.debug "
|
1290
|
+
NatsWave.logger.debug "⚙️Skipping publish - conditions not met"
|
1276
1291
|
next
|
1277
1292
|
end
|
1278
1293
|
|
@@ -1300,7 +1315,7 @@ module NatsWave
|
|
1300
1315
|
|
1301
1316
|
# Then call custom handler if provided (optional)
|
1302
1317
|
if config[:custom_handler]
|
1303
|
-
NatsWave.logger.debug "
|
1318
|
+
NatsWave.logger.debug "⚙️Calling custom publishing handler after publishing"
|
1304
1319
|
config[:custom_handler].call(self.class.name, action, processed_data, self)
|
1305
1320
|
end
|
1306
1321
|
end
|
@@ -18,7 +18,7 @@ module NatsWave
|
|
18
18
|
def initialize(options = {})
|
19
19
|
@nats_url = ENV['NATS_URL'] || "nats://localhost:4222"
|
20
20
|
@service_name = ENV['NATS_SERVICE_NAME'] || "purplewave"
|
21
|
-
@version = ENV['NATS_SERVICE_VERSION'] || "1.1.
|
21
|
+
@version = ENV['NATS_SERVICE_VERSION'] || "1.1.16"
|
22
22
|
@instance_id = ENV['NATS_INSTANCE_ID'] || Socket.gethostname
|
23
23
|
@database_url = ENV['NATS_DATABASE_URL'] || nil
|
24
24
|
@connection_pool_size = (ENV['NATS_CONNECTION_POOL_SIZE'] || 10).to_i
|
data/lib/nats_wave/version.rb
CHANGED