1 | <?php |
||
5 | final class PersistentSubscriptionSettings |
||
6 | { |
||
7 | const STRATEGY_ROUND_ROBIN = 'RoundRobin'; |
||
8 | const STRATEGY_DISPATCH_TO_SINGLE = 'DispatchToSingle'; |
||
9 | const CURRENT_POSITION = -1; |
||
10 | |||
11 | /** |
||
12 | * @var bool |
||
13 | */ |
||
14 | private $resolveLinktos = true; |
||
15 | |||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | private $namedConsumerStrategy = self::STRATEGY_ROUND_ROBIN; |
||
20 | |||
21 | /** |
||
22 | * @var int |
||
23 | */ |
||
24 | private $startFrom = self::CURRENT_POSITION; |
||
25 | |||
26 | /** |
||
27 | * @var int |
||
28 | */ |
||
29 | private $messageTimeoutMilliseconds = 10000; |
||
30 | |||
31 | /** |
||
32 | * @var int |
||
33 | */ |
||
34 | private $checkPointAfterMilliseconds = 1000; |
||
35 | |||
36 | /** |
||
37 | * @var int |
||
38 | */ |
||
39 | private $minCheckPointCount = 10; |
||
40 | |||
41 | /** |
||
42 | * @var int |
||
43 | */ |
||
44 | private $maxCheckPointCount = 500; |
||
45 | |||
46 | /** |
||
47 | * @var int |
||
48 | */ |
||
49 | private $maxRetryCount = 10; |
||
50 | |||
51 | /** |
||
52 | * @var bool |
||
53 | */ |
||
54 | private $extraStatistics = false; |
||
55 | |||
56 | /** |
||
57 | * @var int |
||
58 | */ |
||
59 | private $readBatchSize = 20; |
||
60 | |||
61 | /** |
||
62 | * @var int |
||
63 | */ |
||
64 | private $maxSubscriberCount = 10; |
||
65 | |||
66 | /** |
||
67 | * Tells the subscription to resolve link events. |
||
68 | * |
||
69 | * @return PersistentSubscriptionSettings |
||
70 | */ |
||
71 | public function resolveLinktos(): PersistentSubscriptionSettings |
||
77 | |||
78 | /** |
||
79 | * Tells the subscription to not resolve link events. |
||
80 | * |
||
81 | * @return PersistentSubscriptionSettings |
||
82 | */ |
||
83 | public function doNotResolveLinktos(): PersistentSubscriptionSettings |
||
89 | |||
90 | /** |
||
91 | * If possible prefer to round robin between the connections with messages (if not possible will use next available). |
||
92 | * |
||
93 | * @return PersistentSubscriptionSettings |
||
94 | */ |
||
95 | public function preferRoundRobin(): PersistentSubscriptionSettings |
||
101 | |||
102 | /** |
||
103 | * If possible prefer to dispatch to a single connection (if not possible will use next available). |
||
104 | * |
||
105 | * @return PersistentSubscriptionSettings |
||
106 | */ |
||
107 | public function preferDispatchToSingle(): PersistentSubscriptionSettings |
||
113 | |||
114 | /** |
||
115 | * Start the subscription from the position-th event in the stream. |
||
116 | * |
||
117 | * @return PersistentSubscriptionSettings |
||
118 | */ |
||
119 | public function startFromBeginning(): PersistentSubscriptionSettings |
||
125 | |||
126 | /** |
||
127 | * Start the subscription from the position-th event in the stream. |
||
128 | * |
||
129 | * @param int $position |
||
130 | * |
||
131 | * @return PersistentSubscriptionSettings |
||
132 | */ |
||
133 | public function startFrom(int $position): PersistentSubscriptionSettings |
||
142 | |||
143 | /** |
||
144 | * Start the subscription from the current position. |
||
145 | * |
||
146 | * @return PersistentSubscriptionSettings |
||
147 | */ |
||
148 | public function startFromCurrent(): PersistentSubscriptionSettings |
||
154 | |||
155 | /** |
||
156 | * Sets the timeout in milliseconds for a client before the message will be retried. |
||
157 | * |
||
158 | * @param int $timeout |
||
159 | * |
||
160 | * @return PersistentSubscriptionSettings |
||
161 | */ |
||
162 | public function withMessageTimeoutInMillisecondsOf(int $timeout): PersistentSubscriptionSettings |
||
172 | |||
173 | /** |
||
174 | * The amount of time the system should try to checkpoint after. |
||
175 | * |
||
176 | * @param int $time |
||
177 | * |
||
178 | * @return PersistentSubscriptionSettings |
||
179 | */ |
||
180 | public function checkPointAfter(int $time): PersistentSubscriptionSettings |
||
190 | |||
191 | /** |
||
192 | * The minimum number of messages to write a checkpoint for. |
||
193 | * |
||
194 | * @param int $count |
||
195 | * |
||
196 | * @return PersistentSubscriptionSettings |
||
197 | */ |
||
198 | public function minCheckPointOf(int $count): PersistentSubscriptionSettings |
||
208 | |||
209 | /** |
||
210 | * The maximum number of messages not checkpointed before forcing a checkpoint. |
||
211 | * |
||
212 | * @param int $count |
||
213 | * |
||
214 | * @return PersistentSubscriptionSettings |
||
215 | */ |
||
216 | public function maxCheckPointOf(int $count): PersistentSubscriptionSettings |
||
230 | |||
231 | /** |
||
232 | * Sets the number of times a message should be retried before being considered a bad message. |
||
233 | * |
||
234 | * @param int $count |
||
235 | * |
||
236 | * @return PersistentSubscriptionSettings |
||
237 | */ |
||
238 | public function withMaxRetriesOf(int $count): PersistentSubscriptionSettings |
||
248 | |||
249 | /** |
||
250 | * The size of the read batch when in paging mode. |
||
251 | * |
||
252 | * @param int $count |
||
253 | * |
||
254 | * @return PersistentSubscriptionSettings |
||
255 | */ |
||
256 | public function WithReadBatchOf(int $count): PersistentSubscriptionSettings |
||
266 | |||
267 | /** |
||
268 | * Tells the backend to measure timings on the clients so statistics will contain histograms of them. |
||
269 | * |
||
270 | * @return PersistentSubscriptionSettings |
||
271 | */ |
||
272 | public function withExtraStatistics(): PersistentSubscriptionSettings |
||
278 | |||
279 | /** |
||
280 | * @param int $count |
||
281 | */ |
||
282 | public function withMaxSubscribersOf(int $count) |
||
292 | |||
293 | /** |
||
294 | * Sets the maximum number of allowed subscribers. |
||
295 | * |
||
296 | * @return array |
||
297 | */ |
||
298 | public function toArray() |
||
314 | } |
||
315 |