fix typos, add github action (#122)

pull/125/head
Vasiliy Taranov 2024-03-12 18:10:18 +03:00 committed by GitHub
parent d20903e2f7
commit 2a3f239a05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 19 additions and 10 deletions

View File

@ -87,6 +87,15 @@ jobs:
command: clippy command: clippy
args: --all-targets --features ${{ matrix.otel_version }} --workspace -- -D warnings args: --all-targets --features ${{ matrix.otel_version }} --workspace -- -D warnings
typos:
name: Spell Check with Typos
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v4
- name: Check spelling
uses: crate-ci/typos@master
docs: docs:
name: Docs name: Docs
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -15,7 +15,7 @@ implementations. This repository also contains a couple of useful concrete middl
* [`reqwest-tracing`](https://crates.io/crates/reqwest-tracing): * [`reqwest-tracing`](https://crates.io/crates/reqwest-tracing):
[`tracing`](https://crates.io/crates/tracing) integration, optional opentelemetry support. [`tracing`](https://crates.io/crates/tracing) integration, optional opentelemetry support.
Note about browser support: automated tests targetting wasm are disabled. The crate may work with Note about browser support: automated tests targeting wasm are disabled. The crate may work with
wasm but wasm support is unmaintained. PRs improving wasm are still welcome but you'd need to wasm but wasm support is unmaintained. PRs improving wasm are still welcome but you'd need to
reintroduce the tests and get them passing before we'd merge it (see reintroduce the tests and get them passing before we'd merge it (see
https://github.com/TrueLayer/reqwest-middleware/pull/105). https://github.com/TrueLayer/reqwest-middleware/pull/105).

View File

@ -90,7 +90,7 @@ where
next: Next<'_>, next: Next<'_>,
) -> Result<Response> { ) -> Result<Response> {
// TODO: Ideally we should create a new instance of the `Extensions` map to pass // TODO: Ideally we should create a new instance of the `Extensions` map to pass
// downstream. This will guard against previous retries poluting `Extensions`. // downstream. This will guard against previous retries polluting `Extensions`.
// That is, we only return what's populated in the typemap for the last retry attempt // That is, we only return what's populated in the typemap for the last retry attempt
// and copy those into the the `global` Extensions map. // and copy those into the the `global` Extensions map.
self.execute_with_retry(req, next, extensions).await self.execute_with_retry(req, next, extensions).await

View File

@ -4,7 +4,7 @@ use reqwest_middleware::Error;
/// Classification of an error/status returned by request. /// Classification of an error/status returned by request.
#[derive(PartialEq, Eq)] #[derive(PartialEq, Eq)]
pub enum Retryable { pub enum Retryable {
/// The failure was due to something tha might resolve in the future. /// The failure was due to something that might resolve in the future.
Transient, Transient,
/// Unresolvable error. /// Unresolvable error.
Fatal, Fatal,

View File

@ -59,7 +59,7 @@ use reqwest_middleware::Error;
/// let retry_policy = ExponentialBackoff::builder() /// let retry_policy = ExponentialBackoff::builder()
/// .build_with_max_retries(2); /// .build_with_max_retries(2);
/// ///
/// // Create the actual middleware, with the exponential backoff and custom retry stategy. /// // Create the actual middleware, with the exponential backoff and custom retry strategy.
/// let ret_s = RetryTransientMiddleware::new_with_policy_and_strategy( /// let ret_s = RetryTransientMiddleware::new_with_policy_and_strategy(
/// retry_policy, /// retry_policy,
/// Retry201, /// Retry201,
@ -154,7 +154,7 @@ pub fn default_on_request_failure(error: &Error) -> Option<Retryable> {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
if let Some(hyper_error) = get_source_error_type::<hyper::Error>(&error) { if let Some(hyper_error) = get_source_error_type::<hyper::Error>(&error) {
// The hyper::Error(IncompleteMessage) is raised if the HTTP response is well formatted but does not contain all the bytes. // The hyper::Error(IncompleteMessage) is raised if the HTTP response is well formatted but does not contain all the bytes.
// This can happen when the server has started sending back the response but the connection is cut halfway thorugh. // This can happen when the server has started sending back the response but the connection is cut halfway through.
// We can safely retry the call, hence marking this error as [`Retryable::Transient`]. // We can safely retry the call, hence marking this error as [`Retryable::Transient`].
// Instead hyper::Error(Canceled) is raised when the connection is // Instead hyper::Error(Canceled) is raised when the connection is
// gracefully closed on the server side. // gracefully closed on the server side.

View File

@ -76,7 +76,7 @@ macro_rules! assert_retry_succeeds_inner {
macro_rules! assert_retry_succeeds { macro_rules! assert_retry_succeeds {
($x:tt, $status:expr) => { ($x:tt, $status:expr) => {
paste! { paste! {
assert_retry_succeeds_inner!($x, [<assert_retry_succeds_on_ $x>], $status, 3, 2, RetryResponder::new(3 as u32, $x)); assert_retry_succeeds_inner!($x, [<assert_retry_succeeds_on_ $x>], $status, 3, 2, RetryResponder::new(3 as u32, $x));
} }
}; };
} }
@ -275,7 +275,7 @@ async fn assert_retry_on_hyper_canceled() {
let mut buffer = Vec::new(); let mut buffer = Vec::new();
stream.read_buf(&mut buffer).await.unwrap(); stream.read_buf(&mut buffer).await.unwrap();
if counter.fetch_add(1, Ordering::SeqCst) > 1 { if counter.fetch_add(1, Ordering::SeqCst) > 1 {
// This triggeres hyper:Error(Canceled). // This triggers hyper:Error(Canceled).
let _res = stream let _res = stream
.into_std() .into_std()
.unwrap() .unwrap()
@ -326,7 +326,7 @@ async fn assert_retry_on_connection_reset_by_peer() {
let mut buffer = Vec::new(); let mut buffer = Vec::new();
stream.read_buf(&mut buffer).await.unwrap(); stream.read_buf(&mut buffer).await.unwrap();
if counter.fetch_add(1, Ordering::SeqCst) > 1 { if counter.fetch_add(1, Ordering::SeqCst) > 1 {
// This triggeres hyper:Error(Io, io::Error(ConnectionReset)). // This triggers hyper:Error(Io, io::Error(ConnectionReset)).
drop(stream); drop(stream);
} else { } else {
let _res = stream.write("HTTP/1.1 200 OK\r\n\r\n".as_bytes()).await; let _res = stream.write("HTTP/1.1 200 OK\r\n\r\n".as_bytes()).await;

View File

@ -41,7 +41,7 @@ pub const HTTP_USER_AGENT: &str = "http.user_agent";
/// ///
/// [`TracingMiddleware`]: crate::middleware::TracingMiddleware. /// [`TracingMiddleware`]: crate::middleware::TracingMiddleware.
pub trait ReqwestOtelSpanBackend { pub trait ReqwestOtelSpanBackend {
/// Initalized a new span before the request is executed. /// Initialized a new span before the request is executed.
fn on_request_start(req: &Request, extension: &mut Extensions) -> Span; fn on_request_start(req: &Request, extension: &mut Extensions) -> Span;
/// Runs after the request call has executed. /// Runs after the request call has executed.

View File

@ -54,7 +54,7 @@
/// If nothing else is specified, the span generated by `reqwest_otel_span!` is identical to the one you'd /// If nothing else is specified, the span generated by `reqwest_otel_span!` is identical to the one you'd
/// get by using [`DefaultSpanBackend`]. Note that to avoid leaking sensitive information, the /// get by using [`DefaultSpanBackend`]. Note that to avoid leaking sensitive information, the
/// macro doesn't include `http.url`, even though it's required by opentelemetry. You can add the /// macro doesn't include `http.url`, even though it's required by opentelemetry. You can add the
/// URL attribute explicitly by usng [`SpanBackendWithUrl`] instead of `DefaultSpanBackend` or /// URL attribute explicitly by using [`SpanBackendWithUrl`] instead of `DefaultSpanBackend` or
/// adding the field on your own implementation. /// adding the field on your own implementation.
/// ///
/// You can define new fields following the same syntax of [`tracing::info_span!`] for fields: /// You can define new fields following the same syntax of [`tracing::info_span!`] for fields: