|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Bdf\QueueBundle\FailerFactory; |
|
4
|
|
|
|
|
5
|
|
|
use Bdf\Dsn\DsnRequest; |
|
6
|
|
|
use Bdf\Prime\ServiceLocator; |
|
7
|
|
|
use Bdf\Queue\Failer\DbFailedJobRepository; |
|
|
|
|
|
|
8
|
|
|
use Bdf\Queue\Failer\DbFailedJobStorage; |
|
|
|
|
|
|
9
|
|
|
use Bdf\Queue\Failer\FailedJobRepositoryAdapter; |
|
10
|
|
|
use Bdf\Queue\Failer\FailedJobRepositoryInterface; |
|
11
|
|
|
use InvalidArgumentException; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Factory for storage using prime |
|
15
|
|
|
* |
|
16
|
|
|
* The package "b2pweb/bdf-queue-prime-adapter" must be installed and |
|
17
|
|
|
* "b2pweb/bdf-prime-bundle" configure to enable this failer repository |
|
18
|
|
|
* |
|
19
|
|
|
* DSN format: "prime://[connection]/[table]?maxRows=[cursorSize]" |
|
20
|
|
|
* with: |
|
21
|
|
|
* - [connection] as the prime connection to use for store failed jobs |
|
22
|
|
|
* - [table] as the table name |
|
23
|
|
|
* - [cursorSize] (optional): number of loaded jobs each times by the cursor with calling |
|
24
|
|
|
* `FailedJobRepositoryInterface::all()` or `search()`. Default value is 50 |
|
25
|
|
|
*/ |
|
26
|
|
|
final class PrimeFailerFactory implements FailerDsnFactoryInterface |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* @var ServiceLocator |
|
30
|
|
|
*/ |
|
31
|
|
|
private $prime; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param ServiceLocator $prime |
|
35
|
|
|
*/ |
|
36
|
7 |
|
public function __construct(ServiceLocator $prime) |
|
37
|
|
|
{ |
|
38
|
7 |
|
$this->prime = $prime; |
|
39
|
7 |
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* {@inheritdoc} |
|
43
|
|
|
*/ |
|
44
|
4 |
|
public function scheme(): string |
|
45
|
|
|
{ |
|
46
|
4 |
|
return 'prime'; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* {@inheritdoc} |
|
51
|
|
|
*/ |
|
52
|
4 |
|
public function create(DsnRequest $dsn): FailedJobRepositoryInterface |
|
53
|
|
|
{ |
|
54
|
4 |
|
if (!$host = $dsn->getHost()) { |
|
55
|
1 |
|
throw new InvalidArgumentException('The connection name is required on prime failer DSN'); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
3 |
|
if (!$path = trim($dsn->getPath(), '/')) { |
|
|
|
|
|
|
59
|
1 |
|
throw new InvalidArgumentException('The table name is required on prime failer DSN'); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
$schema = [ |
|
63
|
2 |
|
'connection' => $host, |
|
64
|
2 |
|
'table' => $path |
|
65
|
|
|
]; |
|
66
|
2 |
|
$maxRows = (int) $dsn->query('maxRows', 50); |
|
67
|
|
|
|
|
68
|
2 |
|
if (class_exists(DbFailedJobRepository::class)) { |
|
69
|
|
|
return DbFailedJobRepository::make($this->prime, $schema, $maxRows); |
|
70
|
|
|
} else { |
|
71
|
2 |
|
return FailedJobRepositoryAdapter::adapt(DbFailedJobStorage::make($this->prime, $schema, $maxRows)); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Check if the prime repository is supported (i.e. package "b2pweb/bdf-queue-prime-adapter" is installed) |
|
77
|
|
|
* |
|
78
|
|
|
* @return bool |
|
79
|
|
|
*/ |
|
80
|
2 |
|
public static function supported(): bool |
|
81
|
|
|
{ |
|
82
|
2 |
|
return class_exists(DbFailedJobRepository::class) || class_exists(DbFailedJobStorage::class); |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths