Skip to content

Commit cba936e

Browse files
authored
Merge pull request #14 from bluerabbit/support_enqueue_after_transaction_commit
Support for enqueue_after_transaction_commit setting introduced in Rails 7.2
2 parents 3198666 + 4ea66f3 commit cba936e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/active_job/google_cloud_tasks/http/adapter.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ module ActiveJob
66
module GoogleCloudTasks
77
module HTTP
88
class Adapter
9-
def initialize(project:, location:, url:, task_options: {}, client: nil)
9+
def initialize(project:, location:, url:, task_options: {}, client: nil, enqueue_after_transaction_commit: false)
1010
@project = project
1111
@location = location
1212
@url = url
1313
@task_options = task_options
1414
@client = client
15+
@enqueue_after_transaction_commit = enqueue_after_transaction_commit
16+
end
17+
18+
# Method expected in Rails 7.2 and later
19+
def enqueue_after_transaction_commit?
20+
@enqueue_after_transaction_commit
1521
end
1622

1723
def enqueue(job, attributes = {})

lib/active_job/google_cloud_tasks/http/inline.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ module ActiveJob
44
module GoogleCloudTasks
55
module HTTP
66
module Inlining
7+
# Method expected in Rails 7.2 and later
8+
def enqueue_after_transaction_commit?
9+
false
10+
end
11+
712
def enqueue(job, *)
813
ActiveJob::Base.execute job.serialize
914
end

0 commit comments

Comments
 (0)