-
Notifications
You must be signed in to change notification settings - Fork 440
/
Copy pathConfig.php
178 lines (148 loc) · 3.94 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?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 $separator;
/**
* @var string
*/
private $app;
/**
* @var string
*/
private $routerTopic;
/**
* @var string
*/
private $routerQueue;
/**
* @var string
*/
private $defaultQueue;
/**
* @var string
*/
private $routerProcessor;
/**
* @var array
*/
private $transportConfig;
/**
* @var array
*/
private $driverConfig;
public function __construct(
string $prefix,
string $separator,
string $app,
string $routerTopic,
string $routerQueue,
string $defaultQueue,
string $routerProcessor,
array $transportConfig,
array $driverConfig
) {
$this->prefix = trim($prefix);
$this->app = trim($app);
$this->routerTopic = trim($routerTopic);
if (empty($this->routerTopic)) {
throw new \InvalidArgumentException('Router topic is empty.');
}
$this->routerQueue = trim($routerQueue);
if (empty($this->routerQueue)) {
throw new \InvalidArgumentException('Router queue is empty.');
}
$this->defaultQueue = trim($defaultQueue);
if (empty($this->defaultQueue)) {
throw new \InvalidArgumentException('Default processor queue name is empty.');
}
$this->routerProcessor = trim($routerProcessor);
if (empty($this->routerProcessor)) {
throw new \InvalidArgumentException('Router processor name is empty.');
}
$this->transportConfig = $transportConfig;
$this->driverConfig = $driverConfig;
$this->separator = $separator;
}
public function getPrefix(): string
{
return $this->prefix;
}
public function getSeparator(): string
{
return $this->separator;
}
public function getApp(): string
{
return $this->app;
}
public function getRouterTopic(): string
{
return $this->routerTopic;
}
public function getRouterQueue(): string
{
return $this->routerQueue;
}
public function getDefaultQueue(): string
{
return $this->defaultQueue;
}
public function getRouterProcessor(): string
{
return $this->routerProcessor;
}
public function getTransportOption(string $name, $default = null)
{
return array_key_exists($name, $this->transportConfig) ? $this->transportConfig[$name] : $default;
}
public function getTransportOptions(): array
{
return $this->transportConfig;
}
public function getDriverOption(string $name, $default = null)
{
return array_key_exists($name, $this->driverConfig) ? $this->driverConfig[$name] : $default;
}
public function getDriverOptions(): array
{
return $this->driverConfig;
}
public static function create(
string $prefix = null,
string $separator = null,
string $app = null,
string $routerTopic = null,
string $routerQueue = null,
string $defaultQueue = null,
string $routerProcessor = null,
array $transportConfig = [],
array $driverConfig = []
): self {
return new static(
$prefix ?: '',
$separator ?: '.',
$app ?: '',
$routerTopic ?: 'router',
$routerQueue ?: 'default',
$defaultQueue ?: 'default',
$routerProcessor ?: 'router',
$transportConfig,
$driverConfig
);
}
}