[add]: Timeout
This commit is contained in:
@@ -8,6 +8,7 @@ class EventServiceIntegration:
|
|||||||
EVENTS_SERVICE_BASE_URL = settings.EVENTS_SERVICE_BASE_URL
|
EVENTS_SERVICE_BASE_URL = settings.EVENTS_SERVICE_BASE_URL
|
||||||
ENDPOINT_DIRECT_LOAN = settings.ENDPOINT_DIRECT_LOAN
|
ENDPOINT_DIRECT_LOAN = settings.ENDPOINT_DIRECT_LOAN
|
||||||
ENDPOINT_DIRECT_REPAYMENT = settings.ENDPOINT_DIRECT_REPAYMENT
|
ENDPOINT_DIRECT_REPAYMENT = settings.ENDPOINT_DIRECT_REPAYMENT
|
||||||
|
TIMEOUT = settings.TIMEOUT
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def direct_loan(transaction_id: str):
|
def direct_loan(transaction_id: str):
|
||||||
@@ -23,7 +24,7 @@ class EventServiceIntegration:
|
|||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = httpx.post(url, json=payload, headers=headers, timeout=10.0)
|
response = httpx.post(url, json=payload, headers=headers, timeout=EventServiceIntegration.TIMEOUT)
|
||||||
logger.info(f"Loan Response: {response.text}")
|
logger.info(f"Loan Response: {response.text}")
|
||||||
return response
|
return response
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -44,7 +45,7 @@ class EventServiceIntegration:
|
|||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = httpx.post(url, json=payload, headers=headers, timeout=10.0)
|
response = httpx.post(url, json=payload, headers=headers, timeout=EventServiceIntegration.TIMEOUT)
|
||||||
logger.info(f"Repayment Response: {response.text}")
|
logger.info(f"Repayment Response: {response.text}")
|
||||||
return response
|
return response
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ class SimbrellaIntegration:
|
|||||||
HEALTH_ENDPOINT = settings.SIMBRELLA_HEALTH
|
HEALTH_ENDPOINT = settings.SIMBRELLA_HEALTH
|
||||||
AUTH_ENDPOINT = settings.BANK_CALL_AUTH_ENDPOINT
|
AUTH_ENDPOINT = settings.BANK_CALL_AUTH_ENDPOINT
|
||||||
SIMBRELLA_VERIFY_BALANCE_ENDPOINT = settings.SIMBRELLA_VERIFY_BALANCE_ENDPOINT
|
SIMBRELLA_VERIFY_BALANCE_ENDPOINT = settings.SIMBRELLA_VERIFY_BALANCE_ENDPOINT
|
||||||
|
TIMEOUT = settings.TIMEOUT
|
||||||
|
|
||||||
_access_token = None # cache token in memory
|
_access_token = None # cache token in memory
|
||||||
_token_expiry = 0
|
_token_expiry = 0
|
||||||
@@ -33,7 +34,7 @@ class SimbrellaIntegration:
|
|||||||
try:
|
try:
|
||||||
logger.info(f"Requesting Bank token from {url}")
|
logger.info(f"Requesting Bank token from {url}")
|
||||||
|
|
||||||
response = httpx.post(url, json=payload, headers=headers, timeout=10.0)
|
response = httpx.post(url, json=payload, headers=headers, timeout=SimbrellaIntegration.TIMEOUT)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
data = response.json()
|
data = response.json()
|
||||||
@@ -86,7 +87,7 @@ class SimbrellaIntegration:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
response = httpx.post(url, json=payload, headers=headers, timeout=10.0)
|
response = httpx.post(url, json=payload, headers=headers, timeout=SimbrellaIntegration.TIMEOUT)
|
||||||
|
|
||||||
logger.info(f"This is Response: {str(response)}", exc_info=True)
|
logger.info(f"This is Response: {str(response)}", exc_info=True)
|
||||||
|
|
||||||
@@ -122,7 +123,7 @@ class SimbrellaIntegration:
|
|||||||
url,
|
url,
|
||||||
json=payload,
|
json=payload,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
timeout=10.0,
|
timeout=SimbrellaIntegration.TIMEOUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
@@ -164,7 +165,7 @@ class SimbrellaIntegration:
|
|||||||
"Authorization": f"Bearer {access_token}"
|
"Authorization": f"Bearer {access_token}"
|
||||||
}
|
}
|
||||||
|
|
||||||
response = httpx.get(url, headers=headers, timeout=10.0)
|
response = httpx.get(url, headers=headers, timeout=SimbrellaIntegration.TIMEOUT)
|
||||||
logger.info(f"Bank Health Check Response: {response.text}")
|
logger.info(f"Bank Health Check Response: {response.text}")
|
||||||
return response
|
return response
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
+1
-1
@@ -52,7 +52,7 @@ class Config:
|
|||||||
BANK_CALL_AUTH_ENDPOINT = os.getenv("BANK_CALL_AUTH_ENDPOINT", "/api/Auth/generate-token")
|
BANK_CALL_AUTH_ENDPOINT = os.getenv("BANK_CALL_AUTH_ENDPOINT", "/api/Auth/generate-token")
|
||||||
BANK_CALL_USERNAME = os.getenv("BANK_CALL_USERNAME", "simbrella")
|
BANK_CALL_USERNAME = os.getenv("BANK_CALL_USERNAME", "simbrella")
|
||||||
BANK_CALL_PASSWORD = os.getenv("BANK_CALL_PASSWORD", "G7$k9@pL2!qR")
|
BANK_CALL_PASSWORD = os.getenv("BANK_CALL_PASSWORD", "G7$k9@pL2!qR")
|
||||||
|
TIMEOUT = os.getenv("TIMEOUT", 60.0)
|
||||||
|
|
||||||
|
|
||||||
EVENTS_SERVICE_BASE_URL = os.getenv("EVENTS_SERVICE_BASE_URL","https://event-core.simbrellang.net")
|
EVENTS_SERVICE_BASE_URL = os.getenv("EVENTS_SERVICE_BASE_URL","https://event-core.simbrellang.net")
|
||||||
|
|||||||
Reference in New Issue
Block a user