Pool::activate
(PHP 8.6+, True Async 1.0)
public Pool::activate(): void
Forcefully transitions the pool to the ACTIVE state. Resources become available
for acquisition again. Used for manual Circuit Breaker management, for example,
after confirming that the service has recovered.
Parameters
This method takes no parameters.
Return Value
No value is returned.
Examples
Example #1 Manual activation after verification
<?php
use Async\Pool;
use Async\CircuitBreakerState;
$pool = new Pool(
factory: fn() => new HttpClient('https://api.example.com'),
max: 5
);
// Suppose the pool was deactivated
if ($pool->getState() === CircuitBreakerState::INACTIVE) {
// Manually check service availability
if (checkServiceHealth('https://api.example.com/health')) {
$pool->activate();
echo "Pool activated\n";
}
}
Example #2 Activation by external signal
<?php
use Async\Pool;
// Webhook handler from the monitoring system
function onServiceRestored(Pool $pool): void
{
$pool->activate();
echo "Service restored, pool activated\n";
}
See Also
- Pool::deactivate — Transition to INACTIVE state
- Pool::recover — Transition to RECOVERING state
- Pool::getState — Current state