Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Commit

Permalink
don't retry on NoPublicIPv4Error
Browse files Browse the repository at this point in the history
  • Loading branch information
xvello committed May 6, 2024
1 parent 4e0a546 commit ac81afe
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions hook-worker/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ use reqwest::{header, Client};
use tokio::sync;
use tracing::error;

use crate::dns::PublicIPv4Resolver;
use crate::error::{WebhookError, WebhookParseError, WebhookRequestError, WorkerError};
use crate::dns::{NoPublicIPv4Error, PublicIPv4Resolver};
use crate::error::{
is_error_source, WebhookError, WebhookParseError, WebhookRequestError, WorkerError,
};
use crate::util::first_n_bytes_of_response;

/// A WebhookJob is any `PgQueueJob` with `WebhookJobParameters` and `WebhookJobMetadata`.
Expand Down Expand Up @@ -401,10 +403,19 @@ async fn send_webhook(
.body(body)
.send()
.await
.map_err(|e| WebhookRequestError::RetryableRequestError {
error: e,
response: None,
retry_after: None,
.map_err(|e| {
if is_error_source::<NoPublicIPv4Error>(&e) {
WebhookRequestError::NonRetryableRetryableRequestError {
error: e,
response: None,
}
} else {
WebhookRequestError::RetryableRequestError {
error: e,
response: None,
retry_after: None,
}
}
})?;

let retry_after = parse_retry_after_header(response.headers());
Expand Down

0 comments on commit ac81afe

Please sign in to comment.