<commit_before><?php

namespace Phive\TaskQueue\ExecutorAdapter;

use Phive\TaskQueue\ExecutionContext;
use Phive\TaskQueue\ExecutionFailedException;
use Phive\TaskQueue\RetryAwarePayload;
use Phive\TaskQueue\RetryStrategy\RetryStrategy;

class RetryableExecutorAdapter implements ExecutorAdapter
{
    private $adapter;
    private $retryStrategy;

    public function __construct(ExecutorAdapter $adapter, RetryStrategy $retryStrategy)
    {
        $this->adapter = $adapter;
        $this->retryStrategy = $retryStrategy;
    }

    public function execute($payload, ExecutionContext $context)
    {
        if (!$payload instanceof RetryAwarePayload) {
            $payload = new RetryAwarePayload($payload);
        }

        try {
            return $this->adapter->execute($payload->getPayload(), $context);
        } catch (ExecutionFailedException $e) {
            throw $e;
        } catch (\Exception $e) {
            $delay = $this->retryStrategy->getDelay($payload->incRetry());

            if (null !== $delay) {
                $context->getQueue()->push($payload, "+$delay seconds");
            }
<commit_msg>Tweak RetryableExecutorAdapter<commit_after><?php

namespace Phive\TaskQueue\ExecutorAdapter;

use Phive\TaskQueue\ExecutionContext;
use Phive\TaskQueue\ExecutionFailedException;
use Phive\TaskQueue\RetryAwarePayload;
use Phive\TaskQueue\RetryStrategy\RetryStrategy;

class RetryableExecutorAdapter implements ExecutorAdapter
{
    private $adapter;
    private $retryStrategy;

    public function __construct(ExecutorAdapter $adapter, RetryStrategy $retryStrategy)
    {
        $this->adapter = $adapter;
        $this->retryStrategy = $retryStrategy;
    }

    public function execute($payload, ExecutionContext $context)
    {
        if (!$payload instanceof RetryAwarePayload) {
            $payload = new RetryAwarePayload($payload);
        }

        try {
            $this->adapter->execute($payload->getPayload(), $context);
        } catch (ExecutionFailedException $e) {
            throw $e;
        } catch (\Exception $e) {
            $delay = $this->retryStrategy->getDelay($payload->incRetry());

            if (null !== $delay) {
                $context->getQueue()->push($payload, "+$delay seconds");
            }

{'fraction_non_alphanumeric': 0.1153169014084507, 'fraction_numerical': 0.0, 'mean_word_length': 3.051693404634581, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4146028', 'n_tokens_mistral': 600, 'n_tokens_neox': 613, 'n_words': 122}