eugenganshorn / guzzlebundleretryplugin Goto Github PK
View Code? Open in Web Editor NEWRetry Plugin for EightPointsGuzzleBundle
License: MIT License
Retry Plugin for EightPointsGuzzleBundle
License: MIT License
You already have commit that solve this in 1.1.* version ( d60c917 ), but we can't use v1.1 for symfony 4 .
This fix also should be in 1.0.* branch
There is a dependency on the eight_points_guzzle logger class. When logging is disabled on eight_points_guzzle this class is not defined by the extension.
This gives the following error;
The service "guzzle_bundle_retry_plugin.middleware.retry.xxx" has a dependency on a non-existent service "eight_points_guzzle.middleware.log.class".
Location:
public function loadForClient(array $config, ContainerBuilder $container, string $clientName, Definition $handler): void
{
if ($config['retry_enabled']) {
$logger = new Definition(Logger::class);
$logger->addMethodCall('setLogger', [new Reference('monolog.logger.eight_points_guzzle')]);
$logger->addMethodCall('setFormatter', [new Reference('eight_points_guzzle.symfony_log_formatter')]);
$middleware = new Definition(GuzzleRetryMiddleware::class);
$middleware->setFactory([GuzzleRetryMiddleware::class, 'factory']);
$middleware->setArguments([
[
'max_retry_attempts' => $config['max_retry_attempts'],
'retry_only_if_retry_after_header' => $config['retry_only_if_retry_after_header'],
'retry_on_status' => $config['retry_on_status'],
'default_retry_multiplier' => $config['default_retry_multiplier'],
'retry_on_timeout' => $config['retry_on_timeout'],
'expose_retry_header' => $config['expose_retry_header'],
'retry_header' => $config['retry_header'],
'on_retry_callback' => [$logger, 'callback'],
],
]);
Hi guys!
I wanted to use you plugin for retrying but I need a custom logic to decide is it need to retry a request or not.
I see that you don't use config options with callbacks, for example 'should_retry_callback' or 'on_retry_callback'
https://github.com/EugenGanshorn/GuzzleBundleRetryPlugin/blob/master/src/GuzzleBundleRetryPlugin.php#L90
I tried to make my own plugin for this but it's appeared that the logic with callbacks doesn't work because Symfony tries to serialize it here: https://github.com/symfony/dependency-injection/blob/6.3/Compiler/MergeExtensionConfigurationPass.php#L121
And finally I got error "Serialization of 'Closure' is not allowed"
My example
public function loadForClient(array $config, ContainerBuilder $container, string $clientName, Definition $handler): void
{
$shouldRetryCallback = function () {
// todo
};
$middleware = new Definition(GuzzleRetryMiddleware::class);
$middleware->setFactory([GuzzleRetryMiddleware::class, 'factory']);
$middleware->setArguments([
[
'max_retry_attempts' => 3,
'retry_on_status' => [502, 503],
'should_retry_callback' => $shouldRetryCallback,
],
]);
$middleware->setPublic(true);
$middlewareServiceName = sprintf('guzzle_bundle_retry_plugin.middleware.retry.%s', $clientName);
$container->setDefinition($middlewareServiceName, $middleware);
$middlewareExpression = new Expression(sprintf('service("%s")', $middlewareServiceName));
$handler->addMethodCall('push', [$middlewareExpression]);
}
Sorry, it's not really issue to your plugin
But maybe you know is it possible to use callbacks to configure guzzle middlewares through plugins?
Hey, we had to create a fork of the project and tag to install regularly within Symfony 6.x - would love to switch back and delete the fork if we could get a new release here :)
https://github.com/ProtonMail/GuzzleBundleRetryPlugin/releases/tag/1.4.0
Previously requested here
Are you going to add php-8 support?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.