1 | <?php |
||
19 | class ConstantLimitationSolver implements LimitationSolverInterface, EventHandlerInterface |
||
20 | { |
||
21 | /** |
||
22 | * Limit of running requests |
||
23 | * |
||
24 | * @var int |
||
25 | */ |
||
26 | private $limit; |
||
27 | |||
28 | /** |
||
29 | * Key with number of active requests in execution context |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | private $key; |
||
34 | |||
35 | /** |
||
36 | * ConstantLimitationSolver constructor. |
||
37 | * |
||
38 | * @param int $limit Limit of running requests |
||
39 | */ |
||
40 | 6 | public function __construct($limit) |
|
45 | |||
46 | /** {@inheritdoc} */ |
||
47 | 6 | public function initialize(RequestExecutorInterface $executor, ExecutionContext $executionContext) |
|
51 | |||
52 | /** {@inheritdoc} */ |
||
53 | 6 | public function finalize(RequestExecutorInterface $executor, ExecutionContext $executionContext) |
|
57 | |||
58 | /** {@inheritdoc} */ |
||
59 | 2 | public function decide( |
|
72 | |||
73 | /** {@inheritdoc} */ |
||
74 | 2 | public function invokeEvent( |
|
89 | |||
90 | /** |
||
91 | * Process socket initialize event |
||
92 | * |
||
93 | * @param ExecutionContext $executionContext Execution context |
||
94 | * |
||
95 | * @return void |
||
96 | */ |
||
97 | 2 | private function onSocketRequestInitialize(ExecutionContext $executionContext) |
|
105 | |||
106 | /** |
||
107 | * Process request termination |
||
108 | * |
||
109 | * @param ExecutionContext $executionContext Execution context |
||
110 | * |
||
111 | * @return void |
||
112 | */ |
||
113 | 1 | private function onSocketRequestFinalize(ExecutionContext $executionContext) |
|
121 | } |
||
122 |