Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new strategies should be possible without modifying RetryStrategyFactory #6

Open
rybakit opened this issue Sep 29, 2018 · 0 comments

Comments

@rybakit
Copy link
Member

rybakit commented Sep 29, 2018

Possible refactoring:

interface RetryStrategyFactory
{
    public function createFromArray(array $data) : RetryStrategy;
}

class RetryHandler implements Handler
{
    ...

    public function setStrategyFactory(string $name, RetryStrategyFactory $factory) : self
    { ... }

    public function handle(Task $task, Queue $queue): void
    {
        ...
        $strategy = $this->factories[$strategyName]->createFromArray($retryOptions);
        ...
    }
}

$retryHandler = (new RetryHandler())
    ->setStrategyFactory(RetryStrategies::CONSTANT, new ConstantRetryStrategyFactory())
    ->setStrategyFactory(RetryStrategies::LINEAR, new LinearRetryStrategyFactory())
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant