-
-
Save anonymous/20f913b2cb6775b2e6454a4dcb2f25ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Minion/Backend/Pg.pm b/lib/Minion/Backend/Pg.pm | |
index 765c772..49441c4 100644 | |
--- a/lib/Minion/Backend/Pg.pm | |
+++ b/lib/Minion/Backend/Pg.pm | |
@@ -750,3 +750,19 @@ drop type if exists minion_state; | |
-- 8 up | |
alter table minion_jobs add constraint args check(jsonb_typeof(args) = 'array'); | |
create index on minion_jobs (state, priority desc, created); | |
+ | |
+-- 9 up | |
+create or replace function minion_jobs_notify_workers() returns trigger as $$ | |
+ begin | |
+ if new.delayed <= now() then | |
+ perform pg_notify('minion.job', ''); | |
+ end if; | |
+ return null; | |
+ end; | |
+$$ language plpgsql; | |
+set client_min_messages to warning; | |
+drop trigger if exists minion_jobs_insert_trigger on minion_jobs; | |
+drop trigger if exists minion_jobs_notify_workers_trigger on minion_jobs; | |
+set client_min_messages to notice; | |
+create trigger minion_jobs_notify_workers after insert or update of retries | |
+ on minion_jobs for each row execute procedure minion_jobs_notify_workers(); | |
diff --git a/t/pg.t b/t/pg.t | |
index 02f6726..1a1e7ef 100644 | |
--- a/t/pg.t | |
+++ b/t/pg.t | |
@@ -24,10 +24,10 @@ my $worker = $minion->repair->worker; | |
isa_ok $worker->minion->app, 'Mojolicious', 'has default application'; | |
# Migrate up and down | |
-is $minion->backend->pg->migrations->active, 8, 'active version is 8'; | |
+is $minion->backend->pg->migrations->active, 9, 'active version is 9'; | |
is $minion->backend->pg->migrations->migrate(0)->active, 0, | |
'active version is 0'; | |
-is $minion->backend->pg->migrations->migrate->active, 8, 'active version is 8'; | |
+is $minion->backend->pg->migrations->migrate->active, 9, 'active version is 9'; | |
# Register and unregister | |
$worker->register; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment