nats_wave 1.1.15 → 1.1.17

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: 4777c9a4a662a49320023b9a7d990f85048104bb9aa6a69e7560c16032d93e1d
4
- data.tar.gz: 87f7b15fa4fad543c57f79724179559921da10a86782f2bc8beb7ad9ca06a316
3
+ metadata.gz: 96d6d8104b53ea2928cb582117540bee7ea2e6b7f53cd59d6fe45e4b425951dc
4
+ data.tar.gz: 54f25e266faeef7de1f7596582d16d755aa37a50969fc07e1249f9cef48311ae
5
5
  SHA512:
6
- metadata.gz: ea31a18412ee4bc53dc81b5847daf5387419d5c2e3deeab2f5b704679533a53125a5dda6ed341521aa1dfc8c5e0aacfdd740df329250750b7b8d61e9c1f79053
7
- data.tar.gz: a96f7870c5e44c9c73da2b7c807e30a130d672c84c55c9d7ab718f5db75809c1f3fcc4c31190e7a6b33be86b779c02099bc63aff93a4f0bfbbc8c24f7ce84e1b
6
+ metadata.gz: 9c891b5df233ab589e4481fe88b6c37900c1577fcac0f84babef441c31a4966c8cc1725419cbd12ac69eb07e196cdc0446212ea0fb230a99a018a6bbfcefc07d
7
+ data.tar.gz: 76e24d165d453ca8f51450e1eaa44a2823778928855ba1182d000aa22f6bf42c73a64d8e1174bb85fafd7430755e73a0b31ba0bdece98d3babf657fd321c0282
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nats_wave (1.1.15)
4
+ nats_wave (1.1.17)
5
5
  activerecord (>= 6.1, < 8.0)
6
6
  activesupport (>= 6.1, < 8.0)
7
7
  concurrent-ruby (~> 1.1)
data/README.md CHANGED
@@ -174,7 +174,7 @@ rails console
174
174
  # This automatically publishes via nats_wave_publishes_to
175
175
  ```
176
176
 
177
- ## ⚙️ Configuration
177
+ ## ⚙️ Configuration
178
178
 
179
179
  ### Environment Variables
180
180
 
@@ -77,7 +77,7 @@ module NatsWave
77
77
  {
78
78
  service: @service_name,
79
79
  environment: ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'unknown',
80
- version: ENV['APP_VERSION'] || '1.1.15'
80
+ version: ENV['APP_VERSION'] || '1.1.17'
81
81
  }
82
82
  end
83
83
 
@@ -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 "📤 #{self.name}: Setting up publishing to subjects: #{subjects.inspect}"
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 "📤 #{self.name}: Registered publishing config for subjects: #{subjects}"
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 "📤 #{self.name}: Added publishing callbacks"
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 "📨 Processing subscription message for #{model_class.name}"
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 "📨 Performing auto-sync first"
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 "📨 Calling custom subscription handler after auto-sync"
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 "📤 Skipping publish - conditions not met"
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 "📤 Calling custom publishing handler after publishing"
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.15"
21
+ @version = ENV['NATS_SERVICE_VERSION'] || "1.1.17"
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NatsWave
4
- VERSION = '1.1.15'
4
+ VERSION = '1.1.17'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nats_wave
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.15
4
+ version: 1.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeffrey Dabo