journaled 5.2.0 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7fc4b493edc90534706cd22dbb1fae76cdacc693d95e44734f9ce92db2d0716c
4
- data.tar.gz: 46edc5873055e2a4e7ceae9f8dc63c558b331a821826803cd36aa971b42258f5
3
+ metadata.gz: 677d0f45ee5a62e362e5889cfee0745e6645be394617b60585302ccbf28099a0
4
+ data.tar.gz: 30c02276b17d9cfce2534f530806b2b037c42e0b3708ef0d10b194f295f09e74
5
5
  SHA512:
6
- metadata.gz: 6c9871cbc8b6439f9d29e29bbc24068d2a25667eb42003bed42ca016505b463586b8b3bc0b4c33d2f130a76d5dbc70bf7815d41b992def7a8dc4f71e697113e8
7
- data.tar.gz: 6770fd7d6a3c92bce0122def374fa1a7e31f74c8a67d8ebeb9c2ccf5e1e02c616aae42274b5fd145e6cd59d6aa7e5b483dca134d8479822652e65c0bd7c1df84
6
+ metadata.gz: a8b5fb2a36241ea80bfe6f07965fe048e9b5f246ff71e77c61259d78f9739e41b20a3dcf669a2ab1514169c95e01d2b8e21ac885beaa943243b6abc2ad673deb
7
+ data.tar.gz: 65baecc64ef3f99fae2e45e5133ec844cf16fcaad2463b103d8d03ad95eb32de52bde0341a58c07c65a25935359e80913806d68b12cea2de74f48517ce2d177a
data/README.md CHANGED
@@ -682,6 +682,14 @@ This feature can be disabled conditionally:
682
682
  Journaled.transactional_batching_enabled = false
683
683
  ```
684
684
 
685
+ And can then be enabled via the following block:
686
+
687
+ ```ruby
688
+ Journaled.with_transactional_batching do
689
+ # your code
690
+ end
691
+ ```
692
+
685
693
  Backwards compatibility has been included for background jobs enqueued by
686
694
  version 4.0 and above, but **has been dropped for jobs emitted by versions prior
687
695
  to 4.0**. (Again, be sure to upgrade only one major version at a time.)
@@ -83,7 +83,7 @@ module Journaled
83
83
 
84
84
  def dup
85
85
  super.tap do |config|
86
- config.ignored_columns = ignored_columns.dup
86
+ config.ignored_columns = ignored_columns.dup # rubocop:disable Rails/IgnoredColumnsAssignment
87
87
  config.enqueue_opts = enqueue_opts.dup
88
88
  end
89
89
  end
@@ -2,11 +2,11 @@ module Journaled
2
2
  module Connection
3
3
  class << self
4
4
  def available?
5
- Journaled.transactional_batching_enabled && transaction_open?
5
+ Journaled.transactional_batching_enabled? && transaction_open?
6
6
  end
7
7
 
8
8
  def stage!(event)
9
- raise TransactionSafetyError, <<~MSG unless transaction_open?
9
+ raise TransactionSafetyError, <<~MSG unless available?
10
10
  Transaction not available! By default, journaled event batching requires an open database transaction.
11
11
  MSG
12
12
 
@@ -1,3 +1,3 @@
1
1
  module Journaled
2
- VERSION = "5.2.0".freeze
2
+ VERSION = "5.3.0".freeze
3
3
  end
data/lib/journaled.rb CHANGED
@@ -16,7 +16,19 @@ module Journaled
16
16
  mattr_accessor(:http_open_timeout) { 2 }
17
17
  mattr_accessor(:http_read_timeout) { 60 }
18
18
  mattr_accessor(:job_base_class_name) { 'ActiveJob::Base' }
19
- mattr_accessor(:transactional_batching_enabled) { true }
19
+ mattr_writer(:transactional_batching_enabled) { true }
20
+
21
+ def self.transactional_batching_enabled?
22
+ Thread.current[:journaled_transactional_batching_enabled] || @@transactional_batching_enabled
23
+ end
24
+
25
+ def self.with_transactional_batching
26
+ value_was = Thread.current[:journaled_transactional_batching_enabled]
27
+ Thread.current[:journaled_transactional_batching_enabled] = true
28
+ yield
29
+ ensure
30
+ Thread.current[:journaled_transactional_batching_enabled] = value_was
31
+ end
20
32
 
21
33
  def self.development_or_test?
22
34
  %w(development test).include?(Rails.env)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: journaled
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.0
4
+ version: 5.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Lipson
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2022-10-13 00:00:00.000000000 Z
14
+ date: 2022-12-01 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activejob