8000 feature #49815 [HttpClient][Messenger] add `PingWebhookMessage` and `… · symfony/framework-bundle@4bc2e94 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4bc2e94

Browse files
committed
feature #49815 [HttpClient][Messenger] add PingWebhookMessage and PingWebhookMessageHandler (kbond)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [HttpClient][Messenger] add `PingWebhookMessage` and `PingWebhookMessageHandler` | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | n/a | License | MIT | Doc PR | todo With symfony/scheduler, it could be useful to ping some kind of uptime monitoring service like [ohdearapp](https://ohdear.app/). ## Usage ```php use Symfony\Component\HttpClient\Messenger\PingWebhookMessage; $bus->dispatch(new PingWebhookMessage('GET', 'https://example.com')); // simple ping, throws HttpExceptionInterface on 3xx/4xx/5xx $bus->dispatch(new PingWebhookMessage('GET', 'https://example.com', throw: false)); // ping, but does not throw HttpExceptionInterface on 3xx/4xx/5xx $bus->dispatch(new PingWebhookMessage('GET', 'https://example.com', [ 'headers' => ['X-FOO => 'bar'], // any HttpClientInterface options ])); ``` TODO: - [x] wire up - [x] tests Commits ------- f0644d9f25 [HttpClient][Messenger] add `PingWebhookMessage` and `PingWebhookMessageHandler`
2 parents ded7d5b + e9dcfea commit 4bc2e94

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
use Symfony\Component\HtmlSanitizer\HtmlSanitizer;
8484
use Symfony\Component\HtmlSanitizer\HtmlSanitizerConfig;
8585
use Symfony\Component\HtmlSanitizer\HtmlSanitizerInterface;
86+
use Symfony\Component\HttpClient\Messenger\PingWebhookMessageHandler;
8687
use Symfony\Component\HttpClient\MockHttpClient;
8788
use Symfony\Component\HttpClient\Retry\GenericRetryStrategy;
8889
use Symfony\Component\HttpClient\RetryableHttpClient;
@@ -2462,6 +2463,10 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
24622463
unset($options['vars']);
24632464
$container->getDefinition('http_client.transport')->setArguments([$options, $config['max_host_connections'] ?? 6]);
24642465

2466+
if (!class_exists(PingWebhookMessageHandler::class)) {
2467+
$container->removeDefinition('http_client.messenger.ping_webhook_handler');
2468+
}
2469+
24652470
if (!$hasPsr18 = ContainerBuilder::willBeAvailable('psr/http-client', ClientInterface::class, ['symfony/framework-bundle', 'symfony/http-client'])) {
24662471
$container->removeDefinition('psr18.http_client');
24672472
$container->removeAlias(ClientInterface::class);

Resources/config/http_client.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Psr\Http\Message\StreamFactoryInterface;
1818
use Symfony\Component\HttpClient\HttpClient;
1919
use Symfony\Component\HttpClient\HttplugClient;
20+
use Symfony\Component\HttpClient\Messenger\PingWebhookMessageHandler;
2021
use Symfony\Component\HttpClient\Psr18Client;
2122
use Symfony\Component\HttpClient\Retry\GenericRetryStrategy;
2223
use Symfony\Component\HttpClient\UriTemplateHttpClient;
@@ -90,5 +91,11 @@
9091
->args([
9192
[inline_service(\Rize\UriTemplate::class), 'expand'],
9293
])
94+
95+
->set('http_client.messenger.ping_webhook_handler', PingWebhookMessageHandler::class)
96+
->args([
97+
service('http_client'),
98+
])
99+
->tag('messenger.message_handler')
93100
;
94101
};

0 commit comments

Comments
 (0)
0