mirror of
https://github.com/ditkrg/outboxable.git
synced 2026-01-22 22:06:47 +00:00
Merge branch 'ditkrg:main' into main
This commit is contained in:
commit
eb6de394bc
@ -1,7 +1,7 @@
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
outboxable (1.0.3)
|
||||
outboxable (1.0.5)
|
||||
bunny (>= 2.19.0)
|
||||
connection_pool (~> 2.3.0)
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ module Outboxable
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Outboxable
|
||||
VERSION = '1.0.3'
|
||||
VERSION = '1.0.5'
|
||||
end
|
||||
|
||||
@ -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 }
|
||||
@ -20,9 +20,13 @@ class Outbox < ApplicationRecord
|
||||
end
|
||||
|
||||
def publish
|
||||
Outboxable::Worker.perform_async(id)
|
||||
# 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
|
||||
self.allow_publish = false if published?
|
||||
|
||||
Loading…
Reference in New Issue
Block a user