-
Notifications
You must be signed in to change notification settings - Fork 439
/
Copy pathConfig.php
142 lines (118 loc) · 3.45 KB
/
Config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
namespace Enqueue\Client;
class Config
{
const TOPIC = 'enqueue.topic';
const COMMAND = 'enqueue.command';
const PROCESSOR = 'enqueue.processor';
const EXPIRE = 'enqueue.expire';
const PRIORITY = 'enqueue.priority';
const DELAY = 'enqueue.delay';
const CONTENT_TYPE = 'enqueue.content_type';
/**
* @var string
*/
private $prefix;
/**
* @var string
*/
private $appName;
/**
* @var string
*/
private $routerTopicName;
/**
* @var string
*/
private $routerQueueName;
/**
* @var string
*/
private $defaultProcessorQueueName;
/**
* @var string
*/
private $routerProcessorName;
/**
* @var array
*/
private $transportConfig;
public function __construct(string $prefix, string $appName, string $routerTopicName, string $routerQueueName, string $defaultProcessorQueueName, string $routerProcessorName, array $transportConfig = [])
{
$this->prefix = trim($prefix);
$this->appName = trim($appName);
$this->routerTopicName = trim($routerTopicName);
if (empty($this->routerTopicName)) {
throw new \InvalidArgumentException('Router topic is empty.');
}
$this->routerQueueName = trim($routerQueueName);
if (empty($this->routerQueueName)) {
throw new \InvalidArgumentException('Router queue is empty.');
}
$this->defaultProcessorQueueName = trim($defaultProcessorQueueName);
if (empty($this->defaultProcessorQueueName)) {
throw new \InvalidArgumentException('Default processor queue name is empty.');
}
$this->routerProcessorName = trim($routerProcessorName);
if (empty($this->routerProcessorName)) {
throw new \InvalidArgumentException('Router processor name is empty.');
}
$this->transportConfig = $transportConfig;
}
public function getPrefix(): string
{
return $this->prefix;
}
public function getSeparator(): string
{
return '.';
}
public function getAppName(): string
{
return $this->appName;
}
public function getRouterTopicName(): string
{
return $this->routerTopicName;
}
public function getRouterQueueName(): string
{
return $this->routerQueueName;
}
public function getDefaultProcessorQueueName(): string
{
return $this->defaultProcessorQueueName;
}
public function getRouterProcessorName(): string
{
return $this->routerProcessorName;
}
/**
* @deprecated
*
* @param null|mixed $default
*/
public function getTransportOption(string $name, $default = null)
{
return array_key_exists($name, $this->transportConfig) ? $this->transportConfig[$name] : $default;
}
public static function create(
string $prefix = null,
string $appName = null,
string $routerTopicName = null,
string $routerQueueName = null,
string $defaultProcessorQueueName = null,
string $routerProcessorName = null,
array $transportConfig = []
): self {
return new static(
$prefix ?: '',
$appName ?: '',
$routerTopicName ?: 'router',
$routerQueueName ?: 'default',
$defaultProcessorQueueName ?: 'default',
$routerProcessorName ?: 'router',
$transportConfig
);
}
}