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
|
PATH
|
||||||
remote: .
|
remote: .
|
||||||
specs:
|
specs:
|
||||||
outboxable (1.0.3)
|
outboxable (1.0.5)
|
||||||
bunny (>= 2.19.0)
|
bunny (>= 2.19.0)
|
||||||
connection_pool (~> 2.3.0)
|
connection_pool (~> 2.3.0)
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ module Outboxable
|
|||||||
|
|
||||||
# Copy initializer into user app
|
# Copy initializer into user app
|
||||||
def copy_initializer
|
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'
|
copy_file('mongoid_initializer.rb', 'config/initializers/z_outboxable.rb') if @orm == 'mongoid'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Outboxable
|
module Outboxable
|
||||||
VERSION = '1.0.3'
|
VERSION = '1.0.5'
|
||||||
end
|
end
|
||||||
|
|||||||
@ -4,7 +4,7 @@ class Outbox < ApplicationRecord
|
|||||||
before_save :check_publishing
|
before_save :check_publishing
|
||||||
# Callbacks
|
# Callbacks
|
||||||
before_create :set_last_attempted_at
|
before_create :set_last_attempted_at
|
||||||
after_save :publish, if: :allow_publish
|
after_commit :publish, if: :allow_publish?
|
||||||
# Enums
|
# Enums
|
||||||
enum status: { pending: 0, processing: 1, published: 2, failed: 3 }
|
enum status: { pending: 0, processing: 1, published: 2, failed: 3 }
|
||||||
enum size: { single: 0, batch: 1 }
|
enum size: { single: 0, batch: 1 }
|
||||||
@ -20,8 +20,12 @@ class Outbox < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def publish
|
def publish
|
||||||
Outboxable::Worker.perform_async(id)
|
# Run this in own thread
|
||||||
update(status: :processing, last_attempted_at: 1.minute.from_now, allow_publish: false)
|
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
|
end
|
||||||
|
|
||||||
def check_publishing
|
def check_publishing
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user