This commit is contained in:
2026-08-28 07:31:29 +07:00
parent 3ddfbb73a9
commit 6ea0d12187
3 changed files with 449 additions and 100 deletions
+17 -3
View File
@@ -369,7 +369,7 @@ Transport publishing must be performed by the caller.
# Keyword Arguments:
- `broker_url::String = DEFAULT_BROKER_URL` - URL of the broker
- `fileserver_url = DEFAULT_FILESERVER_URL` - URL of the HTTP file server for large payloads
- `fileserver_upload_handler::Function = plik_oneshot_upload` - Function to handle fileserver uploads (must return Dict with "status", "uploadid", "fileid", "url" keys)
- `fileserver_upload_handler::Function = plik_oneshot_upload` - Custom upload handler with signature `handler(fileserver_url::String, dataname::String, data::Vector{UInt8})::Dict{String, Any}`. Must return a `Dict` with keys: `"status"` (Int/HTTP status code), `"uploadid"` (String), `"fileid"` (String), `"url"` (String - full download URL).
- `size_threshold::Int = DEFAULT_SIZE_THRESHOLD` - Threshold in bytes separating direct vs link transport
- `correlation_id::String = string(uuid4())` - Correlation ID for tracing (auto-generated UUID)
- `msg_purpose::String = "chat"` - Purpose of the message: "ACK", "NACK", "updateStatus", "shutdown", "chat", etc.
@@ -417,13 +417,27 @@ env, msg_json = smartpack("chat.subject", [
# Publish the JSON string directly via your transport (manual publish)
# conn = my_transport.connect(broker_url)
# my_transport.publish(conn, subject, env_json_str)
# Custom fileserver upload handler (e.g., for AWS S3)
function my_custom_upload(fileserver_url::String, dataname::String, data::Vector{UInt8})::Dict{String, Any}
# Upload `data` to your file server at `fileserver_url`, using `dataname` as the file name
# Return a Dict with required keys:
# "status" - HTTP status code (e.g. 200)
# "uploadid" - String ID of the upload session
# "fileid" - String ID of the uploaded file
# "url" - Full download URL for the uploaded file
# Example return:
# Dict("status" => 200, "uploadid" => "abc123", "fileid" => "file456", "url" => "http://my-server.com/abc123/file456/myfile.bin")
throw(NotImplementedError("implement upload logic here"))
end
env, msg_json = smartpack("my.subject", [("data", large_binary_data, "binary")], fileserver_upload_handler=my_custom_upload)
```
"""
""" #WORKING adding garage S3 support
function smartpack(
subject::String, # smartunpack's subject
data::AbstractArray{Tuple{String, T1, String}, 1}; # List of (dataname, data, type) tuples. Use data = Tuple{String, Any, String}[] for empty payloads
broker_url::String = DEFAULT_BROKER_URL, # Broker URL
fileserver_url = DEFAULT_FILESERVER_URL,
fileserver_url::String = DEFAULT_FILESERVER_URL,
fileserver_upload_handler::Function = plik_oneshot_upload, # a function to handle uploading data to specific HTTP fileserver
size_threshold::Int = DEFAULT_SIZE_THRESHOLD,