Skip to content

Commit

Permalink
Merge branch 'ditkrg:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammadnawzad authored Dec 6, 2023
2 parents 5ef8d6a + e486de9 commit eb6de39
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
outboxable (1.0.3)
outboxable (1.0.5)
bunny (>= 2.19.0)
connection_pool (~> 2.3.0)

Expand Down
2 changes: 1 addition & 1 deletion lib/generators/outboxable/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def initialize(*)

# Copy initializer into user app
def copy_initializer
copy_file('activerecod_initializer.rb', 'config/initializers/z_outboxable.rb') if @orm == 'activerecord'
copy_file('activerecord_initializer.rb', 'config/initializers/z_outboxable.rb') if @orm == 'activerecord'
copy_file('mongoid_initializer.rb', 'config/initializers/z_outboxable.rb') if @orm == 'mongoid'
end

Expand Down
2 changes: 1 addition & 1 deletion lib/outboxable/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Outboxable
VERSION = '1.0.3'
VERSION = '1.0.5'
end
10 changes: 7 additions & 3 deletions lib/templates/activerecrod_outbox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Outbox < ApplicationRecord
before_save :check_publishing
# Callbacks
before_create :set_last_attempted_at
after_save :publish, if: :allow_publish
after_commit :publish, if: :allow_publish?
# Enums
enum status: { pending: 0, processing: 1, published: 2, failed: 3 }
enum size: { single: 0, batch: 1 }
Expand All @@ -20,8 +20,12 @@ def set_last_attempted_at
end

def publish
Outboxable::Worker.perform_async(id)
update(status: :processing, last_attempted_at: 1.minute.from_now, allow_publish: false)
# Run this in own thread
threaded = Thread.new do
Outboxable::Worker.perform_inline(id)
update(status: :processing, last_attempted_at: 1.minute.from_now, allow_publish: false)
end
threaded.join
end

def check_publishing
Expand Down

0 comments on commit eb6de39

Please sign in to comment.