I'm trying to migrate over from Bullet. We have a Delayed Job plugin at the moment, that disables Bullet while a background job is running and re-enables it when the job is complete. This way we can run Bullet in tests but have it only run on foreground code.
It looks this:
module Delayed
module Plugins
class BulletDisable < Plugin
callbacks do |lifecycle|
lifecycle.around(:invoke_job) do |job, *args, &block|
@bullet_was_enabled = Bullet.enabled?
Bullet.enabled = false
block.call(job, *args)
Bullet.enabled = @bullet_was_enabled
end
end
end
end
end
This PR adds Prosopite.pause and Prosopite.resume which allows you to do the same thing with Prosopite. So our plugin would become this:
module Delayed
module Plugins
class ProsopitePause < Plugin
callbacks do |lifecycle|
lifecycle.around(:invoke_job) do |job, *args, &block|
Prosopite.pause
block.call(job, *args)
Prosopite.resume
end
end
end
end
end
I'm trying to migrate over from Bullet. We have a Delayed Job plugin at the moment, that disables Bullet while a background job is running and re-enables it when the job is complete. This way we can run Bullet in tests but have it only run on foreground code.
It looks this:
This PR adds
Prosopite.pause
andProsopite.resume
which allows you to do the same thing with Prosopite. So our plugin would become this: