Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
27a630d007
commit
6789e3f14a
13
Cargo.lock
generated
13
Cargo.lock
generated
@ -186,6 +186,18 @@ dependencies = [
|
|||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "backon"
|
||||||
|
version = "0.4.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d67782c3f868daa71d3533538e98a8e13713231969def7536e8039606fc46bf0"
|
||||||
|
dependencies = [
|
||||||
|
"fastrand",
|
||||||
|
"futures-core",
|
||||||
|
"pin-project",
|
||||||
|
"tokio",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "backtrace"
|
name = "backtrace"
|
||||||
version = "0.3.71"
|
version = "0.3.71"
|
||||||
@ -344,6 +356,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"axum",
|
"axum",
|
||||||
|
"backon",
|
||||||
"clap",
|
"clap",
|
||||||
"dagger-sdk",
|
"dagger-sdk",
|
||||||
"dotenv",
|
"dotenv",
|
||||||
|
@ -22,3 +22,4 @@ itertools = "0.12.1"
|
|||||||
regex = "1.10.4"
|
regex = "1.10.4"
|
||||||
serde_json = "1.0.115"
|
serde_json = "1.0.115"
|
||||||
dagger-sdk = "0.9.8"
|
dagger-sdk = "0.9.8"
|
||||||
|
backon = "0.4.4"
|
||||||
|
@ -241,18 +241,35 @@ impl DefaultGiteaClient {
|
|||||||
|
|
||||||
tracing::trace!("calling url: {}", &url);
|
tracing::trace!("calling url: {}", &url);
|
||||||
|
|
||||||
let response = client
|
let response = (|| async {
|
||||||
.get(&url)
|
client
|
||||||
.header("Content-Type", "application/json")
|
.get(&url)
|
||||||
.header("Authorization", format!("token {}", self.token))
|
.header("Content-Type", "application/json")
|
||||||
.send()
|
.header("Authorization", format!("token {}", self.token))
|
||||||
.await?;
|
.send()
|
||||||
|
.await
|
||||||
|
})
|
||||||
|
.retry(&ExponentialBuilder::default())
|
||||||
|
.notify(|err, dur| {
|
||||||
|
tracing::debug!("retrying job: {err}, in: {} seconds", dur.as_secs());
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
|
||||||
match response.error_for_status() {
|
match response.error_for_status() {
|
||||||
Ok(_) => Ok(Some(())),
|
Ok(_) => Ok(Some(())),
|
||||||
Err(e) => match e.status() {
|
Err(e) => match e.status() {
|
||||||
Some(StatusCode::NOT_FOUND) => Ok(None),
|
Some(StatusCode::NOT_FOUND) => Ok(None),
|
||||||
_ => anyhow::bail!(e),
|
Some(status) => {
|
||||||
|
tracing::warn!(
|
||||||
|
"failed to call fetch renovate for: {}, with error: {}",
|
||||||
|
&repo,
|
||||||
|
status
|
||||||
|
);
|
||||||
|
anyhow::bail!(e)
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
anyhow::bail!(e)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -267,12 +284,19 @@ impl DefaultGiteaClient {
|
|||||||
|
|
||||||
tracing::trace!("calling url: {}", &url);
|
tracing::trace!("calling url: {}", &url);
|
||||||
|
|
||||||
let response = client
|
let response = (|| async {
|
||||||
.get(&url)
|
client
|
||||||
.header("Content-Type", "application/json")
|
.get(&url)
|
||||||
.header("Authorization", format!("token {}", self.token))
|
.header("Content-Type", "application/json")
|
||||||
.send()
|
.header("Authorization", format!("token {}", self.token))
|
||||||
.await?;
|
.send()
|
||||||
|
.await
|
||||||
|
})
|
||||||
|
.retry(&ExponentialBuilder::default())
|
||||||
|
.notify(|err, dur| {
|
||||||
|
tracing::debug!("retrying job: {err}, in: {} seconds", dur.as_secs());
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
|
||||||
let webhooks = response.json::<Vec<GiteaWebhook>>().await?;
|
let webhooks = response.json::<Vec<GiteaWebhook>>().await?;
|
||||||
|
|
||||||
@ -301,14 +325,21 @@ impl DefaultGiteaClient {
|
|||||||
serde_json::to_string(&val)?
|
serde_json::to_string(&val)?
|
||||||
);
|
);
|
||||||
|
|
||||||
let response = client
|
let response = (|| async {
|
||||||
.post(&url)
|
client
|
||||||
.header("Content-Type", "application/json")
|
.post(&url)
|
||||||
.header("Accept", "application/json")
|
.header("Content-Type", "application/json")
|
||||||
.header("Authorization", format!("token {}", self.token))
|
.header("Accept", "application/json")
|
||||||
.json(&val)
|
.header("Authorization", format!("token {}", self.token))
|
||||||
.send()
|
.json(&val)
|
||||||
.await?;
|
.send()
|
||||||
|
.await
|
||||||
|
})
|
||||||
|
.retry(&ExponentialBuilder::default())
|
||||||
|
.notify(|err, dur| {
|
||||||
|
tracing::debug!("retrying job: {err}, in: {} seconds", dur.as_secs());
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
|
||||||
if let Err(e) = response.error_for_status_ref() {
|
if let Err(e) = response.error_for_status_ref() {
|
||||||
if let Ok(ok) = response.text().await {
|
if let Ok(ok) = response.text().await {
|
||||||
@ -351,14 +382,21 @@ impl DefaultGiteaClient {
|
|||||||
serde_json::to_string(&val)?
|
serde_json::to_string(&val)?
|
||||||
);
|
);
|
||||||
|
|
||||||
let response = client
|
let response = (|| async {
|
||||||
.patch(&url)
|
client
|
||||||
.header("Content-Type", "application/json")
|
.patch(&url)
|
||||||
.header("Accept", "application/json")
|
.header("Content-Type", "application/json")
|
||||||
.header("Authorization", format!("token {}", self.token))
|
.header("Accept", "application/json")
|
||||||
.json(&val)
|
.header("Authorization", format!("token {}", self.token))
|
||||||
.send()
|
.json(&val)
|
||||||
.await?;
|
.send()
|
||||||
|
.await
|
||||||
|
})
|
||||||
|
.retry(&ExponentialBuilder::default())
|
||||||
|
.notify(|err, dur| {
|
||||||
|
tracing::debug!("retrying job: {err}, in: {} seconds", dur.as_secs());
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
|
||||||
if let Err(e) = response.error_for_status_ref() {
|
if let Err(e) = response.error_for_status_ref() {
|
||||||
if let Ok(ok) = response.text().await {
|
if let Ok(ok) = response.text().await {
|
||||||
@ -463,6 +501,7 @@ mod extensions;
|
|||||||
pub mod traits;
|
pub mod traits;
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
|
use backon::{ExponentialBuilder, Retryable};
|
||||||
pub use extensions::*;
|
pub use extensions::*;
|
||||||
use futures::{stream::FuturesUnordered, TryStreamExt};
|
use futures::{stream::FuturesUnordered, TryStreamExt};
|
||||||
use reqwest::{StatusCode, Url};
|
use reqwest::{StatusCode, Url};
|
||||||
|
@ -103,6 +103,7 @@ impl Reconciler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut enabled = Vec::new();
|
let mut enabled = Vec::new();
|
||||||
|
|
||||||
while let Some(res) = futures.next().await {
|
while let Some(res) = futures.next().await {
|
||||||
let res = res?;
|
let res = res?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user