Skip to content

Commit befc3bc

Browse files
authored
Merge pull request #110 from heseya/feature/SK-970
Change webhooks default tries and timeout
2 parents 1e75c77 + c7842ff commit befc3bc

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,7 @@ GOOGLE_RECAPTCHA_URL=https://www.google.com/recaptcha/api/siteverify
8484
GOOGLE_RECAPTCHA_SECRET=example
8585

8686
WEBHOOK_QUEUE=default
87+
WEBHOOK_TRIES=3
88+
WEBHOOK_TIMEOUT=10
8789

8890
FLAG_VALIDATE_ADDRESS_FULLNAME=true
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace App\Utils\Webhooks;
4+
5+
use Spatie\WebhookServer\BackoffStrategy\ExponentialBackoffStrategy;
6+
7+
class CustomExponentialBackoffStrategy extends ExponentialBackoffStrategy
8+
{
9+
public function waitInSecondsAfterAttempt(int $attempt): int
10+
{
11+
if ($attempt > 3) {
12+
return 1000;
13+
}
14+
15+
return 10 ** $attempt;
16+
}
17+
}

config/webhook-server.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232
* If a call to a webhook takes longer that this amount of seconds
3333
* the attempt will be considered failed.
3434
*/
35-
'timeout_in_seconds' => 10,
35+
'timeout_in_seconds' => (int) env('WEBHOOK_TIMEOUT', 10),
3636

3737
// The amount of times the webhook should be called before we give up.
38-
'tries' => 3,
38+
'tries' => (int) env('WEBHOOK_TRIES', 3),
3939

4040
// This class determines how many seconds there should be between attempts.
41-
'backoff_strategy' => ExponentialBackoffStrategy::class,
41+
'backoff_strategy' => \App\Utils\Webhooks\CustomExponentialBackoffStrategy::class,
4242

4343
/*
4444
* By default we will verify that the ssl certificate of the destination

0 commit comments

Comments
 (0)