1 | <?php |
||
11 | trait RequestRecordStorage |
||
12 | { |
||
13 | /** |
||
14 | * @var RequestRecord[] |
||
15 | */ |
||
16 | protected $reqs = []; |
||
17 | |||
18 | /** |
||
19 | * Create RequestRecord. |
||
20 | * |
||
21 | * @param string $pid |
||
22 | * @param callable|null $success |
||
23 | * @param callable|null $failure |
||
24 | * @param callable|null $cancel |
||
25 | * @param float $timeout |
||
26 | * @return RequestRecord |
||
27 | */ |
||
28 | 2 | protected function createRequest($pid, callable $success = null, callable $failure = null, callable $cancel = null, $timeout = 0.0) |
|
37 | |||
38 | /** |
||
39 | * Check if RequestRecord with given protocol ID exists. |
||
40 | * |
||
41 | * @param string $pid |
||
42 | * @return bool |
||
43 | */ |
||
44 | 3 | protected function existsRequest($pid) |
|
48 | |||
49 | /** |
||
50 | * Add new RequestRecord to storage. |
||
51 | * |
||
52 | * @param string $pid |
||
53 | * @param RequestRecord $request |
||
54 | */ |
||
55 | 5 | protected function addRequest($pid, RequestRecord $request) |
|
59 | |||
60 | /** |
||
61 | * Return RequestRecord if it exists or null if it does not exist. |
||
62 | * |
||
63 | * @param string $pid |
||
64 | * @return RequestRecord|null |
||
65 | */ |
||
66 | 1 | protected function getRequest($pid) |
|
70 | |||
71 | /** |
||
72 | * Resolve RequestRecord if it exists that has protocol ID equal to $pid. |
||
73 | * |
||
74 | * @param string $pid |
||
75 | * @param string $message |
||
76 | */ |
||
77 | 1 | protected function resolveRequest($pid, $message) |
|
83 | |||
84 | /** |
||
85 | * Reject RequestRecord if it exists that has protocol ID equal to $pid. |
||
86 | * |
||
87 | * @param string $pid |
||
88 | * @param Error|Exception|ThrowableProxy $ex |
||
89 | */ |
||
90 | 1 | protected function rejectRequest($pid, $ex) |
|
96 | |||
97 | /** |
||
98 | * Cancel RequestRecord if it exists that has protocol ID equal to $pid. |
||
99 | * |
||
100 | * @param string $pid |
||
101 | * @param Error|Exception|ThrowableProxy $ex |
||
102 | */ |
||
103 | 1 | protected function cancelRequest($pid, $ex) |
|
109 | |||
110 | /** |
||
111 | * Cancel overdue Requests. |
||
112 | */ |
||
113 | protected function expireRequests() |
||
136 | } |
||
137 |