Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Commit

Permalink
Feature for #177, allow for custom queue name per job
Browse files Browse the repository at this point in the history
  • Loading branch information
gnikyt committed Feb 7, 2019
1 parent 91e8faa commit 8b00b8b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ShopifyApp/Services/AuthShopHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function dispatchWebhooks()
{
$webhooks = Config::get('shopify-app.webhooks');
if (count($webhooks) > 0) {
WebhookInstaller::dispatch($this->shop);
WebhookInstaller::dispatch($this->shop)->onQueue(Config::get('shopify-app.job_queues.webhooks'));
}
}

Expand All @@ -150,7 +150,7 @@ public function dispatchScripttags()
{
$scripttags = Config::get('shopify-app.scripttags');
if (count($scripttags) > 0) {
ScripttagInstaller::dispatch($this->shop, $scripttags);
ScripttagInstaller::dispatch($this->shop, $scripttags)->onQueue(Config::get('shopify-app.job_queues.scripttags'));
}
}

Expand Down Expand Up @@ -178,7 +178,7 @@ public function dispatchAfterAuthenticate()
$job::dispatchNow($this->shop);
} else {
// Run later
$job::dispatch($this->shop);
$job::dispatch($this->shop)->onQueue(Config::get('shopify-app.job_queues.after_authenticate'));
}

return true;
Expand Down
16 changes: 16 additions & 0 deletions src/ShopifyApp/resources/config/shopify-app.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,20 @@
],
*/
],

/*
|--------------------------------------------------------------------------
| Job Queues
|--------------------------------------------------------------------------
|
| This option is for setting a specific job queue for webhooks, scripttags
| and after_authenticate_job.
|
*/

'job_queues' => [
'webhooks' => env('WEBHOOKS_JOB_QUEUE', null),
'scripttags' => env('SCRIPTTAGS_JOB_QUEUE', null),
'after_authenticate' => env('AFTER_AUTHENTICATE_JOB_QUEUE', null),
],
];
2 changes: 2 additions & 0 deletions tests/Services/AuthShopHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public function testJobsRun()
'src' => 'https://localhost/scripts/file.js',
],
]);
Config::set('shopify-app.job_queues.webhooks', 'custom-queue');

$jobClass = \App\Jobs\AfterAuthenticateJob::class;
Config::set('shopify-app.after_authenticate_job', [[
Expand All @@ -187,6 +188,7 @@ public function testJobsRun()
Queue::assertPushed(WebhookInstaller::class);
Queue::assertPushed(ScripttagInstaller::class);
Queue::assertPushed($jobClass);
Queue::assertPushedOn('custom-queue', WebhookInstaller::class);
}

public function testAfterAuthenticateSingleJobRuns()
Expand Down

0 comments on commit 8b00b8b

Please sign in to comment.