Skip to content

Commit

Permalink
chore: add comments, check for delay seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
gowrizrh committed Feb 14, 2024
1 parent e1dc3d0 commit 80a2cd9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
35 changes: 35 additions & 0 deletions Api/Data/ResultInterface.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,53 @@
<?php

declare(strict_types=1);

namespace MageOS\AsyncEvents\Api\Data;

interface ResultInterface
{
/**
* Getter for is_successful
*
* @return bool
*/
public function getIsSuccessful(): bool;

/**
* Setter for is_successful
*
* @param bool $isSuccessful
* @return void
*/
public function setIsSuccessful(bool $isSuccessful): void;

/**
* Getter for is_retryable
*
* @return bool
*/
public function getIsRetryable(): bool;

/**
* Setter for is_retryable
*
* @param bool $isRetryable
* @return void
*/
public function setIsRetryable(bool $isRetryable): void;

/**
* Getter for retry_after
*
* @return int|null
*/
public function getRetryAfter(): ?int;

/**
* Setter for retry_after
*
* @param int $retryAfter
* @return void
*/
public function setRetryAfter(int $retryAfter): void;
}
6 changes: 3 additions & 3 deletions Service/AsyncEvent/HttpNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ public function notify(AsyncEventInterface $asyncEvent, array $data): NotifierRe
$notifierResult->setResponseData($exceptionMessage);
$notifierResult->setIsRetryable(true);

// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
if ($response->hasHeader('Retry-After')) {
$retryAfter = $response->getHeader('Retry-After')[0];
$notifierResult->setRetryAfter((int) $retryAfter);
if (is_numeric($retryAfter)) {
$notifierResult->setRetryAfter((int) $retryAfter);
}
}

} else {
$notifierResult->setResponseData(
$exception->getMessage()
Expand Down

0 comments on commit 80a2cd9

Please sign in to comment.