Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(external_services): add proto build under the dynamic_routing feature flag (#5945)
Amisha Prabhatc0cac8d9135b
diff --git a/.github/workflows/CI-pr.yml b/.github/workflows/CI-pr.ymlindex c5b005849a..e43af03ec6 100644--- a/.github/workflows/CI-pr.yml+++ b/.github/workflows/CI-pr.yml@@ -123,6 +123,8 @@ jobs:- name: Install Protocuses: arduino/setup-protoc@v3+ with:+ repo-token: ${{ secrets.GITHUB_TOKEN }}- name: Install sccacheuses: taiki-e/[email protected]@@ -224,6 +226,8 @@ jobs:- name: Install Protocuses: arduino/setup-protoc@v3+ with:+ repo-token: ${{ secrets.GITHUB_TOKEN }}- name: Install sccacheuses: taiki-e/[email protected]@@ -306,6 +310,8 @@ jobs:- name: Install Protocuses: arduino/setup-protoc@v3+ with:+ repo-token: ${{ secrets.GITHUB_TOKEN }}- name: Install rust cacheuses: Swatinem/[email protected]diff --git a/.github/workflows/CI-push.yml b/.github/workflows/CI-push.ymlindex dc7195714b..7bc5599588 100644--- a/.github/workflows/CI-push.yml+++ b/.github/workflows/CI-push.yml@@ -73,6 +73,8 @@ jobs:- name: Install Protocuses: arduino/setup-protoc@v3+ with:+ repo-token: ${{ secrets.GITHUB_TOKEN }}- uses: Swatinem/[email protected]with:@@ -155,6 +157,8 @@ jobs:- name: Install Protocuses: arduino/setup-protoc@v3+ with:+ repo-token: ${{ secrets.GITHUB_TOKEN }}- name: Install cargo-hackuses: baptiste0928/[email protected]@@ -225,6 +229,8 @@ jobs:- name: Install Protocuses: arduino/setup-protoc@v3+ with:+ repo-token: ${{ secrets.GITHUB_TOKEN }}- name: Install rust cacheuses: Swatinem/[email protected]diff --git a/.github/workflows/postman-collection-runner.yml b/.github/workflows/postman-collection-runner.ymlindex 95949593fb..de8235c14e 100644--- a/.github/workflows/postman-collection-runner.yml+++ b/.github/workflows/postman-collection-runner.yml@@ -97,6 +97,8 @@ jobs:- name: Install Protocif: ${{ ((github.event_name == 'pull_request') && (github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name)) || (github.event_name == 'merge_group')}}uses: arduino/setup-protoc@v3+ with:+ repo-token: ${{ secrets.GITHUB_TOKEN }}- name: Install Diesel CLI with Postgres Supportif: ${{ ((github.event_name == 'pull_request') && (github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name)) || (github.event_name == 'merge_group')}}diff --git a/config/config.example.toml b/config/config.example.tomlindex 861785dc34..1f32481fec 100644--- a/config/config.example.toml+++ b/config/config.example.toml@@ -749,3 +749,7 @@ check_token_status_url= "" # base url to check token status from token servic[network_tokenization_supported_connectors]connector_list = "cybersource" # Supported connectors for network tokenization++[grpc_client.dynamic_routing_client] # Dynamic Routing Client Configuration+host = "localhost" # Client Host+port = 7000 # Client Portdiff --git a/config/deployments/env_specific.toml b/config/deployments/env_specific.tomlindex 6235037627..319cdafed1 100644--- a/config/deployments/env_specific.toml+++ b/config/deployments/env_specific.toml@@ -311,3 +311,7 @@ private_key= "" # private key to decrypt response payload from tokey_id= "" # key id to encrypt data for token servicedelete_token_url= "" # base url to delete token from token servicecheck_token_status_url= "" # base url to check token status from token service++[grpc_client.dynamic_routing_client] # Dynamic Routing Client Configuration+host = "localhost" # Client Host+port = 7000 # Client Portdiff --git a/crates/external_services/Cargo.toml b/crates/external_services/Cargo.tomlindex a882cdc9f5..fd7391c13b 100644--- a/crates/external_services/Cargo.toml+++ b/crates/external_services/Cargo.toml@@ -13,7 +13,7 @@ email = ["dep:aws-config"]aws_s3 = ["dep:aws-config", "dep:aws-sdk-s3"]hashicorp-vault = ["dep:vaultrs"]v1 = ["hyperswitch_interfaces/v1"]-dynamic_routing = ["dep:prost", "dep:tonic", "dep:tonic-reflection", "dep:tonic-types", "dep:api_models", "tokio/macros", "tokio/rt-multi-thread"]+dynamic_routing = ["dep:prost", "dep:tonic", "dep:tonic-reflection", "dep:tonic-types", "dep:api_models", "tokio/macros", "tokio/rt-multi-thread" , "dep:tonic-build", "dep:router_env"][dependencies]async-trait = "0.1.79"@@ -49,7 +49,8 @@ api_models = { version = "0.1.0", path = "../api_models", optional = true }[build-dependencies]-tonic-build = "0.12"+tonic-build = { version = "0.12" , optional = true }+router_env = { version = "0.1.0", path = "../router_env", default-features = false, optional = true }[lints]workspace = truediff --git a/crates/external_services/build.rs b/crates/external_services/build.rsindex 61e19f308d..605ef69971 100644--- a/crates/external_services/build.rs+++ b/crates/external_services/build.rs@@ -1,15 +1,13 @@-use std::{env, path::PathBuf};-#[allow(clippy::expect_used)]fn main() -> Result<(), Box<dyn std::error::Error>> {- // Get the directory of the current crate- let crate_dir = env::var("CARGO_MANIFEST_DIR")?;- let proto_file = PathBuf::from(crate_dir)- .join("..")- .join("..")- .join("proto")- .join("success_rate.proto");- // Compile the .proto file- tonic_build::compile_protos(proto_file).expect("Failed to compile protos ");+ #[cfg(feature = "dynamic_routing")]+ {+ // Get the directory of the current crate+ let proto_file = router_env::workspace_path()+ .join("proto")+ .join("success_rate.proto");+ // Compile the .proto file+ tonic_build::compile_protos(proto_file).expect("Failed to compile success rate proto file");+ }Ok(())}diff --git a/crates/external_services/src/grpc_client/dynamic_routing.rs b/crates/external_services/src/grpc_client/dynamic_routing.rsindex 17bd43ca3a..2681bffb0c 100644--- a/crates/external_services/src/grpc_client/dynamic_routing.rs+++ b/crates/external_services/src/grpc_client/dynamic_routing.rs@@ -112,12 +112,12 @@ impl SuccessBasedDynamicRouting for SuccessRateCalculatorClient<Channel> {let params = success_rate_based_config.params.map(|vec| {- vec.into_iter().fold(String::new(), |mut acc_vec, params| {- if !acc_vec.is_empty() {- acc_vec.push(':')+ vec.into_iter().fold(String::new(), |mut acc_str, params| {+ if !acc_str.is_empty() {+ acc_str.push(':')}- acc_vec.push_str(params.to_string().as_str());- acc_vec+ acc_str.push_str(params.to_string().as_str());+ acc_str})}).get_required_value("params")@@ -177,12 +177,12 @@ impl SuccessBasedDynamicRouting for SuccessRateCalculatorClient<Channel> {let params = success_rate_based_config.params.map(|vec| {- vec.into_iter().fold(String::new(), |mut acc_vec, params| {- if !acc_vec.is_empty() {- acc_vec.push(':')+ vec.into_iter().fold(String::new(), |mut acc_str, params| {+ if !acc_str.is_empty() {+ acc_str.push(':')}- acc_vec.push_str(params.to_string().as_str());- acc_vec+ acc_str.push_str(params.to_string().as_str());+ acc_str})}).get_required_value("params")