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 $timeout = 3; |
||
30 | |||
31 | /** |
||
32 | * @var int |
||
33 | */ |
||
34 | private $checkpointAfter = 3; |
||
35 | |||
36 | /** |
||
37 | * @var int |
||
38 | */ |
||
39 | private $minCheckPointCount = 100; |
||
40 | |||
41 | /** |
||
42 | * @var int |
||
43 | */ |
||
44 | private $maxCheckPointCount = 500; |
||
45 | |||
46 | /** |
||
47 | * @var int |
||
48 | */ |
||
49 | private $maxRetries = 3; |
||
50 | |||
51 | /** |
||
52 | * @var bool |
||
53 | */ |
||
54 | private $extraStatistics = false; |
||
55 | |||
56 | /** |
||
57 | * @var int |
||
58 | */ |
||
59 | private $readBatch = 20; |
||
60 | |||
61 | /** |
||
62 | * Tells the subscription to resolve link events. |
||
63 | * |
||
64 | * @return PersistentSubscriptionSettings |
||
65 | */ |
||
66 | public function resolveLinkTos(): PersistentSubscriptionSettings |
||
72 | |||
73 | /** |
||
74 | * Tells the subscription to not resolve link events. |
||
75 | * |
||
76 | * @return PersistentSubscriptionSettings |
||
77 | */ |
||
78 | public function doNotResolveLinkTos(): PersistentSubscriptionSettings |
||
84 | |||
85 | /** |
||
86 | * If possible prefer to round robin between the connections with messages (if not possible will use next available). |
||
87 | * |
||
88 | * @return PersistentSubscriptionSettings |
||
89 | */ |
||
90 | public function preferRoundRobin(): PersistentSubscriptionSettings |
||
96 | |||
97 | /** |
||
98 | * If possible prefer to dispatch to a single connection (if not possible will use next available). |
||
99 | * |
||
100 | * @return PersistentSubscriptionSettings |
||
101 | */ |
||
102 | public function preferDispatchToSingle(): PersistentSubscriptionSettings |
||
108 | |||
109 | /** |
||
110 | * Start the subscription from the position-th event in the stream. |
||
111 | * |
||
112 | * @return PersistentSubscriptionSettings |
||
113 | */ |
||
114 | public function startFromBeginning(): PersistentSubscriptionSettings |
||
120 | |||
121 | public function startFrom(int $position): PersistentSubscriptionSettings |
||
130 | |||
131 | /** |
||
132 | * Start the subscription from the current position. |
||
133 | * |
||
134 | * @return PersistentSubscriptionSettings |
||
135 | */ |
||
136 | public function startFromCurrent(): PersistentSubscriptionSettings |
||
142 | |||
143 | /** |
||
144 | * Sets the timeout for a client before the message will be retried. |
||
145 | * |
||
146 | * @param int $timeout |
||
147 | * |
||
148 | * @return PersistentSubscriptionSettings |
||
149 | */ |
||
150 | public function withMessageTimeoutOf(int $timeout): PersistentSubscriptionSettings |
||
160 | |||
161 | /** |
||
162 | * The amount of time the system should try to checkpoint after. |
||
163 | * |
||
164 | * @param int $time |
||
165 | * |
||
166 | * @return PersistentSubscriptionSettings |
||
167 | */ |
||
168 | public function checkPointAfter(int $time): PersistentSubscriptionSettings |
||
178 | |||
179 | /** |
||
180 | * The minimum number of messages to write a checkpoint for. |
||
181 | * |
||
182 | * @param int $count |
||
183 | * |
||
184 | * @return PersistentSubscriptionSettings |
||
185 | */ |
||
186 | public function minCheckPointCountOf(int $count): PersistentSubscriptionSettings |
||
196 | |||
197 | /** |
||
198 | * The maximum number of messages not checkpointed before forcing a checkpoint. |
||
199 | * |
||
200 | * @param int $count |
||
201 | * |
||
202 | * @return PersistentSubscriptionSettings |
||
203 | */ |
||
204 | public function maxCheckPointCountOf(int $count): PersistentSubscriptionSettings |
||
218 | |||
219 | /** |
||
220 | * Sets the number of times a message should be retried before being considered a bad message. |
||
221 | * |
||
222 | * @param int $count |
||
223 | * |
||
224 | * @return PersistentSubscriptionSettings |
||
225 | */ |
||
226 | public function withMaxRetriesOf(int $count): PersistentSubscriptionSettings |
||
236 | |||
237 | /** |
||
238 | * The size of the read batch when in paging mode. |
||
239 | * |
||
240 | * @param int $count |
||
241 | * |
||
242 | * @return PersistentSubscriptionSettings |
||
243 | */ |
||
244 | public function WithReadBatchOf(int $count): PersistentSubscriptionSettings |
||
254 | |||
255 | /** |
||
256 | * Tells the backend to measure timings on the clients so statistics will contain histograms of them. |
||
257 | * |
||
258 | * @return PersistentSubscriptionSettings |
||
259 | */ |
||
260 | public function withExtraStatistics(): PersistentSubscriptionSettings |
||
266 | } |
||
267 |