From e7f50e899d3e29cf232e8f6a1e2e29965140dbab Mon Sep 17 00:00:00 2001 From: narawat Date: Fri, 13 Feb 2026 20:16:22 +0700 Subject: [PATCH] add new struct --- src/NATSBridge.jl | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/NATSBridge.jl b/src/NATSBridge.jl index 027016d..40b1421 100644 --- a/src/NATSBridge.jl +++ b/src/NATSBridge.jl @@ -15,6 +15,41 @@ const DEFAULT_NATS_URL = "nats://localhost:4222" # Default NATS server URL const DEFAULT_FILESERVER_URL = "http://localhost:8080/upload" # Default HTTP file server URL for link transport +struct msgEnvelope_v1 + correlationId::String # Unique identifier to track messages across systems. Many senders can talk about the same topic. + msgId::String # this message id + timestamp::String # message published timestamp. string(Dates.now()) + + sendTo::String # topic/subject the sender sends to e.g. "/agent/wine/api/v1/prompt" + msgPurpose::Sting # purpose of this message e.g. "ACK | NACK | updateStatus | shutdown | ..." + senderName::Sting # sender name (String) e.g. "agent-wine-web-frontend" + senderId::String # sender id e.g. uuid4snakecase() + receiverName::String # msg receiver name (String) e.g. "agent-backend" + receiverId::String # msg receiver id, nothing means everyone in the topic e.g. uuid4snakecase() + + replyTo::String # sender ask receiver to reply to this topic + replyToMsgId::String # the message id this message is replying to + BrokerURL::String # mqtt/NATS server address + + note::Dict{String, Any} # used to store additional info + payloads::Dict{String, Any} # +end + +#[WORKING] +struct msgPayload_v1 + id::String # id of this payload + dataname::String # name of this payload + type::String # "text | json | table | image | audio | video | binary" + transport::String # "direct | link" + encoding::String # "none | json | base64 | arrow-ipc" + size::Integer # data size in bytes e.g. 15433 + data::Any # payload data in case of direct transport or URL in case of link + metadata::Dict{String, Any} # Dict("checksum=> "sha256_hash", ...) +end + + + + """ Struct for the unified JSON envelope This struct represents a standardized message format that can carry either direct payload data or a URL reference, allowing flexible transport strategies