WC_Helper_API_Backoff::record_from_response
Record a backoff window for a request type from a rate-limited response.
The wait is taken from the response's rate-limit headers and honored as-is, capped only at the request type's max. This respects both a global rate limit's short Retry-After and a per-endpoint limit's longer window. When no usable header is present (a malformed 429), the per-type default is used so there is always a sensible backoff.
Метод класса: WC_Helper_API_Backoff{}
Хуков нет.
Возвращает
void. Ничего (null).
Использование
$result = WC_Helper_API_Backoff::record_from_response( $request_type, $response ): void;
- $request_type(строка) (обязательный)
- The Helper API request type (e.g. 'update-check').
- $response(массив) (обязательный)
- The rate-limited (HTTP 429) response from the Helper API call.
Код WC_Helper_API_Backoff::record_from_response() WC Helper API Backoff::record from response WC 11.2.2
public static function record_from_response( string $request_type, array $response ): void {
$now = time();
$bounds = self::get_bounds( $request_type );
$retry_after = self::get_retry_after_from_headers( $response );
if ( null === $retry_after ) {
// No Retry-After header — apply the per-type default window.
$retry_after = $bounds['default'];
} else {
// Honor the server's directive, but never longer than the per-type
// maximum (a safety net against an erroneous far value).
$retry_after = min( $retry_after, $bounds['max'] );
}
set_transient( self::get_transient_key( $request_type ), $now + $retry_after, $retry_after );
}