This commit is contained in:
2026-02-17 18:02:43 +07:00
parent 6b49fa68c0
commit ad87934abf
2 changed files with 29 additions and 11 deletions

View File

@@ -56,8 +56,8 @@ struct msgPayload_v1
end end
# constructor # constructor
function msgPayload_v1( function msgPayload_v1(;
id::String = ""; id::String = "",
dataname::String = "", dataname::String = "",
type::String = "text", type::String = "text",
transport::String = "direct", transport::String = "direct",
@@ -100,8 +100,8 @@ struct msgEnvelope_v1
end end
# constructor # constructor
function msgEnvelope_v1( function msgEnvelope_v1(;
correlationId::String = ""; correlationId::String = "",
msgId::String = "", msgId::String = "",
timestamp::String = "", timestamp::String = "",
sendTo::String = "", sendTo::String = "",
@@ -547,7 +547,7 @@ payloads = smartreceive(msg, fileserverDownloadHandler, max_retries, base_delay,
""" """
function smartreceive( function smartreceive(
msg::NATS.Message, msg::NATS.Message,
fileserverDownloadHandler::Function; fileserverDownloadHandler::Function=_fetch_with_backoff;
max_retries::Int = 5, max_retries::Int = 5,
base_delay::Int = 100, base_delay::Int = 100,
max_delay::Int = 5000 max_delay::Int = 5000
@@ -588,8 +588,8 @@ function smartreceive(
# Extract URL from the payload # Extract URL from the payload
url = String(payload_data["data"]) url = String(payload_data["data"])
# Fetch with exponential backoff using the download handler #[WORKING] Fetch with exponential backoff using the download handler
downloaded_data = fileserverDownloadHandler(DEFAULT_FILESERVER_URL, url, max_retries, base_delay, max_delay) downloaded_data = fileserverDownloadHandler(json_data["data"], max_retries, base_delay, max_delay,json_data["correlationId"])
# Deserialize based on type # Deserialize based on type
data_type = String(payload_data["type"]) data_type = String(payload_data["type"])
@@ -851,4 +851,22 @@ function plik_oneshot_upload(fileServerURL::String, filepath::String)
end end
end # module end # module