mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
deps(common_utils): put the async ext trait behind a feature (#835)
This commit is contained in:
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -5042,13 +5042,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wiremock"
|
name = "wiremock"
|
||||||
version = "0.5.17"
|
version = "0.5.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "12316b50eb725e22b2f6b9c4cbede5b7b89984274d113a7440c86e5c3fc6f99b"
|
checksum = "bd7b0b5b253ebc0240d6aac6dd671c495c467420577bf634d3064ae7e6fa2b4c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"assert-json-diff",
|
"assert-json-diff",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base64 0.13.1",
|
"base64 0.21.0",
|
||||||
"deadpool",
|
"deadpool",
|
||||||
"futures",
|
"futures",
|
||||||
"futures-timer",
|
"futures-timer",
|
||||||
|
|||||||
@ -12,17 +12,22 @@ signals = [
|
|||||||
"dep:signal-hook-tokio",
|
"dep:signal-hook-tokio",
|
||||||
"dep:signal-hook",
|
"dep:signal-hook",
|
||||||
"dep:tokio",
|
"dep:tokio",
|
||||||
"dep:router_env"
|
"dep:router_env",
|
||||||
|
"dep:futures"
|
||||||
|
]
|
||||||
|
async_ext = [
|
||||||
|
"dep:futures",
|
||||||
|
"dep:async-trait"
|
||||||
]
|
]
|
||||||
logs = [
|
logs = [
|
||||||
"dep:router_env"
|
"dep:router_env"
|
||||||
]
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-trait = "0.1.66"
|
async-trait = { version = "0.1.66", optional = true }
|
||||||
bytes = "1.4.0"
|
bytes = "1.4.0"
|
||||||
error-stack = "0.3.1"
|
error-stack = "0.3.1"
|
||||||
futures = "0.3.27"
|
futures = { version = "0.3.27", optional = true }
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
nanoid = "0.4.0"
|
nanoid = "0.4.0"
|
||||||
once_cell = "1.17.1"
|
once_cell = "1.17.1"
|
||||||
|
|||||||
@ -286,7 +286,8 @@ impl<T> StringExt<T> for String {
|
|||||||
///
|
///
|
||||||
/// Extending functionalities of Wrapper types for idiomatic
|
/// Extending functionalities of Wrapper types for idiomatic
|
||||||
///
|
///
|
||||||
#[async_trait::async_trait]
|
#[cfg(feature = "async_ext")]
|
||||||
|
#[cfg_attr(feature = "async_ext", async_trait::async_trait)]
|
||||||
pub trait AsyncExt<A, B> {
|
pub trait AsyncExt<A, B> {
|
||||||
/// Output type of the map function
|
/// Output type of the map function
|
||||||
type WrappedSelf<T>;
|
type WrappedSelf<T>;
|
||||||
@ -307,7 +308,8 @@ pub trait AsyncExt<A, B> {
|
|||||||
Fut: futures::Future<Output = Self::WrappedSelf<B>> + Send;
|
Fut: futures::Future<Output = Self::WrappedSelf<B>> + Send;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[cfg(feature = "async_ext")]
|
||||||
|
#[cfg_attr(feature = "async_ext", async_trait::async_trait)]
|
||||||
impl<A: Send, B, E: Send> AsyncExt<A, B> for Result<A, E> {
|
impl<A: Send, B, E: Send> AsyncExt<A, B> for Result<A, E> {
|
||||||
type WrappedSelf<T> = Result<T, E>;
|
type WrappedSelf<T> = Result<T, E>;
|
||||||
async fn async_and_then<F, Fut>(self, func: F) -> Self::WrappedSelf<B>
|
async fn async_and_then<F, Fut>(self, func: F) -> Self::WrappedSelf<B>
|
||||||
@ -333,7 +335,8 @@ impl<A: Send, B, E: Send> AsyncExt<A, B> for Result<A, E> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[cfg(feature = "async_ext")]
|
||||||
|
#[cfg_attr(feature = "async_ext", async_trait::async_trait)]
|
||||||
impl<A: Send, B> AsyncExt<A, B> for Option<A> {
|
impl<A: Send, B> AsyncExt<A, B> for Option<A> {
|
||||||
type WrappedSelf<T> = Option<T>;
|
type WrappedSelf<T> = Option<T>;
|
||||||
async fn async_and_then<F, Fut>(self, func: F) -> Self::WrappedSelf<B>
|
async fn async_and_then<F, Fut>(self, func: F) -> Self::WrappedSelf<B>
|
||||||
|
|||||||
@ -17,9 +17,11 @@ pub mod validation;
|
|||||||
pub mod date_time {
|
pub mod date_time {
|
||||||
use std::num::NonZeroU8;
|
use std::num::NonZeroU8;
|
||||||
|
|
||||||
|
#[cfg(feature = "async_ext")]
|
||||||
|
use time::Instant;
|
||||||
use time::{
|
use time::{
|
||||||
format_description::well_known::iso8601::{Config, EncodedConfig, Iso8601, TimePrecision},
|
format_description::well_known::iso8601::{Config, EncodedConfig, Iso8601, TimePrecision},
|
||||||
Instant, OffsetDateTime, PrimitiveDateTime,
|
OffsetDateTime, PrimitiveDateTime,
|
||||||
};
|
};
|
||||||
/// Struct to represent milliseconds in time sensitive data fields
|
/// Struct to represent milliseconds in time sensitive data fields
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -42,6 +44,7 @@ pub mod date_time {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Calculate execution time for a async block in milliseconds
|
/// Calculate execution time for a async block in milliseconds
|
||||||
|
#[cfg(feature = "async_ext")]
|
||||||
pub async fn time_it<T, Fut: futures::Future<Output = T>, F: FnOnce() -> Fut>(
|
pub async fn time_it<T, Fut: futures::Future<Output = T>, F: FnOnce() -> Fut>(
|
||||||
block: F,
|
block: F,
|
||||||
) -> (T, f64) {
|
) -> (T, f64) {
|
||||||
|
|||||||
@ -16,7 +16,7 @@ serde = { version = "1.0.155", features = ["derive"] }
|
|||||||
thiserror = "1.0.39"
|
thiserror = "1.0.39"
|
||||||
|
|
||||||
# First party crates
|
# First party crates
|
||||||
common_utils = { version = "0.1.0", path = "../common_utils" }
|
common_utils = { version = "0.1.0", path = "../common_utils", features = ["async_ext"] }
|
||||||
router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra_implicit_fields", "log_custom_entries_to_extra"] }
|
router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra_implicit_fields", "log_custom_entries_to_extra"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|||||||
@ -80,7 +80,7 @@ uuid = { version = "1.3.0", features = ["serde", "v4"] }
|
|||||||
|
|
||||||
# First party crates
|
# First party crates
|
||||||
api_models = { version = "0.1.0", path = "../api_models", features = ["errors"] }
|
api_models = { version = "0.1.0", path = "../api_models", features = ["errors"] }
|
||||||
common_utils = { version = "0.1.0", path = "../common_utils", features = ["signals"] }
|
common_utils = { version = "0.1.0", path = "../common_utils", features = ["signals", "async_ext"] }
|
||||||
external_services = { version = "0.1.0", path = "../external_services" }
|
external_services = { version = "0.1.0", path = "../external_services" }
|
||||||
masking = { version = "0.1.0", path = "../masking" }
|
masking = { version = "0.1.0", path = "../masking" }
|
||||||
redis_interface = { version = "0.1.0", path = "../redis_interface" }
|
redis_interface = { version = "0.1.0", path = "../redis_interface" }
|
||||||
|
|||||||
Reference in New Issue
Block a user