update
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
module NATSBridge
|
||||
|
||||
using NATS, JSON, Arrow, HTTP, UUIDs, Dates
|
||||
using NATS, JSON, Arrow, HTTP, UUIDs, Dates, Base64
|
||||
# ---------------------------------------------- 100 --------------------------------------------- #
|
||||
|
||||
# Constants
|
||||
@@ -155,7 +155,7 @@ env = smartsend("large.data", data, "arrow")
|
||||
# In another process, retrieve and deserialize:
|
||||
# msg = subscribe(nats_url, "my.subject")
|
||||
# env = json_to_envelope(msg.data)
|
||||
# data = _deserialize_data(base64decode(env.payload), env.type)
|
||||
# data = _deserialize_data(Base64.decode(env.payload), env.type)
|
||||
```
|
||||
"""
|
||||
function smartsend(
|
||||
@@ -183,7 +183,7 @@ function smartsend(
|
||||
# Decision: Direct vs Link
|
||||
if payload_size < size_threshold # Check if payload is small enough for direct transport
|
||||
# Direct path - Base64 encode and send via NATS
|
||||
payload_b64 = base64encode(payload_bytes) # Encode bytes as base64 string
|
||||
payload_b64 = Base64.encode(payload_bytes) # Encode bytes as base64 string
|
||||
log_trace(cid, "Using direct transport for $payload_size bytes") # Log transport choice
|
||||
|
||||
env = MessageEnvelope( # Create envelope for direct transport
|
||||
@@ -354,7 +354,7 @@ function smartreceive(
|
||||
log_trace(env.correlation_id, "Direct transport - decoding payload") # Log direct transport handling
|
||||
|
||||
# Decode Base64 payload
|
||||
payload_bytes = base64decode(env.payload) # Decode base64 payload to bytes
|
||||
payload_bytes = Base64.decode(env.payload) # Decode base64 payload to bytes
|
||||
|
||||
# Deserialize based on type
|
||||
data = _deserialize_data(payload_bytes, env.type, env.correlation_id, env.metadata) # Convert bytes to Julia data
|
||||
@@ -456,19 +456,19 @@ function _deserialize_data(
|
||||
end
|
||||
|
||||
|
||||
""" Decode base64 string to bytes
|
||||
This internal function decodes a base64-encoded string back to binary data.
|
||||
It's a wrapper around Base64.decode for consistency in the module.
|
||||
# """ Decode base64 string to bytes
|
||||
# This internal function decodes a base64-encoded string back to binary data.
|
||||
# It's a wrapper around Base64.decode for consistency in the module.
|
||||
|
||||
Arguments:
|
||||
- `str::String` - Base64-encoded string to decode
|
||||
# Arguments:
|
||||
# - `str::String` - Base64-encoded string to decode
|
||||
|
||||
Return:
|
||||
- Vector{UInt8} - Decoded binary data
|
||||
"""
|
||||
function base64decode(str::String)
|
||||
return Base64.decode(str) # Decode base64 string to bytes using Julia's Base64 module
|
||||
end
|
||||
# Return:
|
||||
# - Vector{UInt8} - Decoded binary data
|
||||
# """
|
||||
# function base64decode(str::String)
|
||||
# return Base64.decode(str) # Decode base64 string to bytes using Julia's Base64 module
|
||||
# end
|
||||
|
||||
|
||||
""" plik_oneshot_upload - Upload a single file to a plik server using one-shot mode
|
||||
|
||||
Reference in New Issue
Block a user