From 6acae389ec4b85799110056f37b2a5769219ffe6 Mon Sep 17 00:00:00 2001 From: Harshit Chauhan Date: Thu, 2 Jul 2026 21:55:55 +0530 Subject: [PATCH] backend/enh/added-flag-for-runInMasterCloudApi --- .../src/Kernel/External/MasterCloudForward.hs | 9 +++++---- lib/mobility-core/test-integration/Main.hs | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/mobility-core/src/Kernel/External/MasterCloudForward.hs b/lib/mobility-core/src/Kernel/External/MasterCloudForward.hs index c63972f06..e8adc4e31 100644 --- a/lib/mobility-core/src/Kernel/External/MasterCloudForward.hs +++ b/lib/mobility-core/src/Kernel/External/MasterCloudForward.hs @@ -134,8 +134,9 @@ getRunApiInMasterCloud = do envVal <- lookupEnv "RUN_API_IN_MASTER_CLOUD" pure (fromMaybe False (readMaybe =<< envVal)) --- Drop-in replacement for @callAPI@. Triple-gated: env on + masterUrl set + --- masterSecret set → forwarded. Anything else → direct call. +-- Drop-in replacement for @callAPI@. Quad-gated: caller flag on + +-- masterUrl set + masterSecret set → forwarded. Anything else → direct call. +-- flag is for city specific forwarder. runThroughMasterCloud :: ( HasMasterCloudForwarder r, MonadReader r m, @@ -147,9 +148,9 @@ runThroughMasterCloud :: BaseUrl -> ET.EulerClient a -> Text -> + Bool -> m (Either ClientError a) -runThroughMasterCloud origBaseUrl eClient desc = do - shouldForward <- liftIO getRunApiInMasterCloud +runThroughMasterCloud origBaseUrl eClient desc shouldForward = do cfg <- asks masterCloudProxyConfig case (shouldForward, cfg.masterUrl, cfg.masterSecret) of (True, Just fwdUrl, Just secret) -> do diff --git a/lib/mobility-core/test-integration/Main.hs b/lib/mobility-core/test-integration/Main.hs index 5c1a809e1..7ef90422e 100644 --- a/lib/mobility-core/test-integration/Main.hs +++ b/lib/mobility-core/test-integration/Main.hs @@ -193,7 +193,7 @@ main = do setEnv "RUN_API_IN_MASTER_CLOUD" "True" rForwarded <- KFlow.runFlowR flowRt env $ - runThroughMasterCloud todoBaseUrl (getTodoClient 1) "getTodo-forwarded" + runThroughMasterCloud todoBaseUrl (getTodoClient 1) "getTodo-forwarded" True -- Compare. case (rDirect, rForwarded) of