Skip to content

Commit 576c1a8

Browse files
committed
Add new QueueService provider
Mostly for DataGrab
1 parent 4f7a148 commit 576c1a8

4 files changed

Lines changed: 101 additions & 0 deletions

File tree

addons/queue/Commands/CommandQueueWork.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class CommandQueueWork extends Cli
6363
*/
6464
public function handle()
6565
{
66+
ee()->load->library('session');
67+
6668
$this->container = ee('queue:QueueManager')->getContainer();
6769

6870
$this->listenForEvents();
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace BoldMinded\Queue\Contracts;
4+
5+
/**
6+
* Queue Service Provider Interface
7+
*
8+
* This interface allows other addons to consume Queue's services without
9+
* having type conflicts between differently-scoped Laravel Queue dependencies.
10+
*
11+
* @package Queue
12+
* @author BoldMinded, LLC
13+
*/
14+
interface QueueServiceProvider
15+
{
16+
/**
17+
* Get the Queue Manager instance
18+
*
19+
* @return mixed QueueManager instance (scoped to Queue's namespace)
20+
*/
21+
public function getQueueManager();
22+
23+
/**
24+
* Get the Queue Worker instance
25+
*
26+
* @return mixed Worker instance (scoped to Queue's namespace)
27+
*/
28+
public function getWorker();
29+
30+
/**
31+
* Get the Queue Worker Options instance
32+
*
33+
* @return mixed WorkerOptions instance (scoped to Queue's namespace)
34+
*/
35+
public function getWorkerOptions();
36+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
namespace BoldMinded\Queue\Service;
4+
5+
use BoldMinded\Queue\Contracts\QueueServiceProvider;
6+
7+
/**
8+
* Queue Service
9+
*
10+
* Provides Queue addon services to other addons without type conflicts.
11+
* This allows addons with differently-scoped Laravel Queue dependencies
12+
* to share a single Queue implementation.
13+
*
14+
* @package Queue
15+
* @author BoldMinded, LLC
16+
*/
17+
class QueueService implements QueueServiceProvider
18+
{
19+
/**
20+
* Create a new QueueService instance
21+
*
22+
* @param mixed $queueManager QueueManager instance
23+
* @param mixed $queueWorker Worker instance
24+
* @param mixed $queueWorkerOptions WorkerOptions instance
25+
*/
26+
public function __construct(
27+
private $queueManager,
28+
private $queueWorker,
29+
private $queueWorkerOptions
30+
) {
31+
}
32+
33+
/**
34+
* @inheritDoc
35+
*/
36+
public function getQueueManager()
37+
{
38+
return $this->queueManager;
39+
}
40+
41+
/**
42+
* @inheritDoc
43+
*/
44+
public function getWorker()
45+
{
46+
return $this->queueWorker;
47+
}
48+
49+
/**
50+
* @inheritDoc
51+
*/
52+
public function getWorkerOptions()
53+
{
54+
return $this->queueWorkerOptions;
55+
}
56+
}

addons/queue/addon.setup.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ function () {}
163163
enabled: get_bool_from_string($config['enable_logging'] ?? 'no'),
164164
);
165165
},
166+
'QueueService' => function ($provider) {
167+
return new \BoldMinded\Queue\Service\QueueService(
168+
$provider->make('QueueManager'),
169+
$provider->make('QueueWorker'),
170+
$provider->make('QueueWorkerOptions')
171+
);
172+
},
166173
],
167174
'commands' => [
168175
'queue:test' => BoldMinded\Queue\Commands\CommandQueueTest::class,

0 commit comments

Comments
 (0)