Skip to content

Commit 8b00b8b

Browse files
committed
Feature for gnikyt#177, allow for custom queue name per job
1 parent 91e8faa commit 8b00b8b

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

src/ShopifyApp/Services/AuthShopHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public function dispatchWebhooks()
137137
{
138138
$webhooks = Config::get('shopify-app.webhooks');
139139
if (count($webhooks) > 0) {
140-
WebhookInstaller::dispatch($this->shop);
140+
WebhookInstaller::dispatch($this->shop)->onQueue(Config::get('shopify-app.job_queues.webhooks'));
141141
}
142142
}
143143

@@ -150,7 +150,7 @@ public function dispatchScripttags()
150150
{
151151
$scripttags = Config::get('shopify-app.scripttags');
152152
if (count($scripttags) > 0) {
153-
ScripttagInstaller::dispatch($this->shop, $scripttags);
153+
ScripttagInstaller::dispatch($this->shop, $scripttags)->onQueue(Config::get('shopify-app.job_queues.scripttags'));
154154
}
155155
}
156156

@@ -178,7 +178,7 @@ public function dispatchAfterAuthenticate()
178178
$job::dispatchNow($this->shop);
179179
} else {
180180
// Run later
181-
$job::dispatch($this->shop);
181+
$job::dispatch($this->shop)->onQueue(Config::get('shopify-app.job_queues.after_authenticate'));
182182
}
183183

184184
return true;

src/ShopifyApp/resources/config/shopify-app.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,20 @@
266266
],
267267
*/
268268
],
269+
270+
/*
271+
|--------------------------------------------------------------------------
272+
| Job Queues
273+
|--------------------------------------------------------------------------
274+
|
275+
| This option is for setting a specific job queue for webhooks, scripttags
276+
| and after_authenticate_job.
277+
|
278+
*/
279+
280+
'job_queues' => [
281+
'webhooks' => env('WEBHOOKS_JOB_QUEUE', null),
282+
'scripttags' => env('SCRIPTTAGS_JOB_QUEUE', null),
283+
'after_authenticate' => env('AFTER_AUTHENTICATE_JOB_QUEUE', null),
284+
],
269285
];

tests/Services/AuthShopHandlerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ public function testJobsRun()
169169
'src' => 'https://localhost/scripts/file.js',
170170
],
171171
]);
172+
Config::set('shopify-app.job_queues.webhooks', 'custom-queue');
172173

173174
$jobClass = \App\Jobs\AfterAuthenticateJob::class;
174175
Config::set('shopify-app.after_authenticate_job', [[
@@ -187,6 +188,7 @@ public function testJobsRun()
187188
Queue::assertPushed(WebhookInstaller::class);
188189
Queue::assertPushed(ScripttagInstaller::class);
189190
Queue::assertPushed($jobClass);
191+
Queue::assertPushedOn('custom-queue', WebhookInstaller::class);
190192
}
191193

192194
public function testAfterAuthenticateSingleJobRuns()

0 commit comments

Comments
 (0)