mirror of
https://github.com/TrueLayer/reqwest-middleware.git
synced 2024-12-26 10:56:32 +00:00
fix typos, add github action (#122)
This commit is contained in:
parent
d20903e2f7
commit
2a3f239a05
8 changed files with 19 additions and 10 deletions
9
.github/workflows/ci.yml
vendored
9
.github/workflows/ci.yml
vendored
|
@ -87,6 +87,15 @@ jobs:
|
|||
command: clippy
|
||||
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:
|
||||
name: Docs
|
||||
runs-on: ubuntu-latest
|
||||
|
|
|
@ -15,7 +15,7 @@ implementations. This repository also contains a couple of useful concrete middl
|
|||
* [`reqwest-tracing`](https://crates.io/crates/reqwest-tracing):
|
||||
[`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
|
||||
reintroduce the tests and get them passing before we'd merge it (see
|
||||
https://github.com/TrueLayer/reqwest-middleware/pull/105).
|
||||
|
|
|
@ -90,7 +90,7 @@ where
|
|||
next: Next<'_>,
|
||||
) -> Result<Response> {
|
||||
// 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
|
||||
// and copy those into the the `global` Extensions map.
|
||||
self.execute_with_retry(req, next, extensions).await
|
||||
|
|
|
@ -4,7 +4,7 @@ use reqwest_middleware::Error;
|
|||
/// Classification of an error/status returned by request.
|
||||
#[derive(PartialEq, Eq)]
|
||||
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,
|
||||
/// Unresolvable error.
|
||||
Fatal,
|
||||
|
|
|
@ -59,7 +59,7 @@ use reqwest_middleware::Error;
|
|||
/// let retry_policy = ExponentialBackoff::builder()
|
||||
/// .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(
|
||||
/// retry_policy,
|
||||
/// Retry201,
|
||||
|
@ -154,7 +154,7 @@ pub fn default_on_request_failure(error: &Error) -> Option<Retryable> {
|
|||
#[cfg(not(target_arch = "wasm32"))]
|
||||
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.
|
||||
// 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`].
|
||||
// Instead hyper::Error(Canceled) is raised when the connection is
|
||||
// gracefully closed on the server side.
|
||||
|
|
|
@ -76,7 +76,7 @@ macro_rules! assert_retry_succeeds_inner {
|
|||
macro_rules! assert_retry_succeeds {
|
||||
($x:tt, $status:expr) => {
|
||||
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();
|
||||
stream.read_buf(&mut buffer).await.unwrap();
|
||||
if counter.fetch_add(1, Ordering::SeqCst) > 1 {
|
||||
// This triggeres hyper:Error(Canceled).
|
||||
// This triggers hyper:Error(Canceled).
|
||||
let _res = stream
|
||||
.into_std()
|
||||
.unwrap()
|
||||
|
@ -326,7 +326,7 @@ async fn assert_retry_on_connection_reset_by_peer() {
|
|||
let mut buffer = Vec::new();
|
||||
stream.read_buf(&mut buffer).await.unwrap();
|
||||
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);
|
||||
} else {
|
||||
let _res = stream.write("HTTP/1.1 200 OK\r\n\r\n".as_bytes()).await;
|
||||
|
|
|
@ -41,7 +41,7 @@ pub const HTTP_USER_AGENT: &str = "http.user_agent";
|
|||
///
|
||||
/// [`TracingMiddleware`]: crate::middleware::TracingMiddleware.
|
||||
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;
|
||||
|
||||
/// Runs after the request call has executed.
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
/// 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
|
||||
/// 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.
|
||||
///
|
||||
/// You can define new fields following the same syntax of [`tracing::info_span!`] for fields:
|
||||
|
|
Loading…
Reference in a new issue