fosm-rails 0.2.2 → 0.2.3

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: 4c993eea70daa26a211f4fa1bfda6750bbbf97389af2f621d673b12f58e41bac
4
- data.tar.gz: 45b2cc6617e618c7500dccdf81ccf6bce49821307bad13e0f30374a95c9cbd04
3
+ metadata.gz: 50ac8659af44dfad52d33f333001e6b3b846cfbb635e56534366ca371631501a
4
+ data.tar.gz: 5d727e837eefe74fa85677199b6cbc78b7e3df28fe33f8275e4c8bd93900383b
5
5
  SHA512:
6
- metadata.gz: 4e1fa8d26f70a0ff09add103cf8fe0fbb95a63986a5dd4b1e1f052ff22b6cb28fb04e38d3b5e3e5a8be4a0a3d370bf80dc07447f0a1d6bb8292a9ce9d8de189a
7
- data.tar.gz: 32a6f160c73a05def43c6a31bdd48975060557987f205f89edab4754b8a410ab505eb8917fa7338931695f261c47c4b52b01b15979de48314efe96cc9fd40ebc
6
+ metadata.gz: e3adb965398f95f843d6d58f39f6b1b54d6c0084c46761b0f30678c7484bf6ca6c4e182e21ce5504b391cf147d9495da4d0d1fcad3ec4992693d7129c40c80c0
7
+ data.tar.gz: 04e1e7595f6dc9c211d7eb923ef167e80d612fab71149f1b5624cc5cbffd46ed64f16d909efd8a4c4a418a4895ba02fba39926fd98f1bcb1a09a028b06e7ca3e
@@ -6,7 +6,7 @@ module Fosm
6
6
  # at most a brief delay between the transition completing and the log entry
7
7
  # appearing. For strict consistency, use config.transition_log_strategy = :sync.
8
8
  class TransitionLogJob < Fosm::ApplicationJob
9
- queue_as :fosm_audit
9
+ queue_as { Fosm.config.transition_log_job_queue }
10
10
 
11
11
  # @param log_data [Hash] all columns for the transition log row (string keys)
12
12
  def perform(log_data)
@@ -2,7 +2,7 @@ module Fosm
2
2
  # Delivers webhook payloads to configured endpoints when FOSM events fire.
3
3
  # Runs asynchronously after the transition completes.
4
4
  class WebhookDeliveryJob < ApplicationJob
5
- queue_as :default
5
+ queue_as { Fosm.config.webhook_job_queue }
6
6
  retry_on StandardError, wait: :polynomially_longer, attempts: 5
7
7
 
8
8
  def perform(record_type:, record_id:, event_name:, from_state:, to_state:, metadata: {})
@@ -34,6 +34,28 @@ module Fosm
34
34
  # config.transition_log_strategy = :async
35
35
  attr_accessor :transition_log_strategy
36
36
 
37
+ # Queue name for Fosm::WebhookDeliveryJob.
38
+ # Webhook delivery is fire-and-forget; route it to a low-priority queue to
39
+ # avoid competing with user-facing jobs on the default queue.
40
+ #
41
+ # Example:
42
+ # config.webhook_job_queue = :low
43
+ attr_accessor :webhook_job_queue
44
+
45
+ # Queue name for Fosm::TransitionLogJob (used when transition_log_strategy = :async).
46
+ #
47
+ # Example:
48
+ # config.transition_log_job_queue = :low
49
+ attr_accessor :transition_log_job_queue
50
+
51
+ # When false, skip enqueuing WebhookDeliveryJob after every transition.
52
+ # Set to false if your app has no webhook subscriptions to eliminate
53
+ # unnecessary queue writes (reduces SQLite write pressure).
54
+ #
55
+ # Example:
56
+ # config.webhooks_enabled = false
57
+ attr_accessor :webhooks_enabled
58
+
37
59
  def initialize
38
60
  @base_controller = "ApplicationController"
39
61
  @admin_authorize = -> { true } # Override in initializer!
@@ -42,6 +64,9 @@ module Fosm
42
64
  @admin_layout = "fosm/application"
43
65
  @app_layout = "application"
44
66
  @transition_log_strategy = :sync
67
+ @webhook_job_queue = :default
68
+ @transition_log_job_queue = :fosm_audit
69
+ @webhooks_enabled = true
45
70
  end
46
71
  end
47
72
 
@@ -286,15 +286,17 @@ module Fosm
286
286
  Fosm::TransitionBuffer.push(log_data)
287
287
  end
288
288
 
289
- # Deliver webhooks asynchronously (outside transaction, always)
290
- Fosm::WebhookDeliveryJob.perform_later(
291
- record_type: self.class.name,
292
- record_id: self.id.to_s,
293
- event_name: event_name.to_s,
294
- from_state: from_state,
295
- to_state: to_state,
296
- metadata: metadata
297
- )
289
+ # Deliver webhooks asynchronously (outside transaction, skipped when disabled)
290
+ if Fosm.config.webhooks_enabled
291
+ Fosm::WebhookDeliveryJob.perform_later(
292
+ record_type: self.class.name,
293
+ record_id: self.id.to_s,
294
+ event_name: event_name.to_s,
295
+ from_state: from_state,
296
+ to_state: to_state,
297
+ metadata: metadata
298
+ )
299
+ end
298
300
 
299
301
  true
300
302
  end
data/lib/fosm/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fosm
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fosm-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abhishek Parolkar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-03-26 00:00:00.000000000 Z
11
+ date: 2026-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails