update
This commit is contained in:
95
etc.jl
95
etc.jl
@@ -1,95 +0,0 @@
|
||||
|
||||
|
||||
|
||||
const DEFAULT_NATS_URL = "nats://localhost:4222"
|
||||
|
||||
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
|
||||
|
||||
# constructor
|
||||
function msgPayload_v1(
|
||||
id::String = "";
|
||||
dataname::String = "",
|
||||
type::String = "text",
|
||||
transport::String = "direct",
|
||||
encoding::String = "none",
|
||||
size::Integer = 0,
|
||||
data::Any = nothing,
|
||||
metadata::Dict{String, Any} = Dict{String, Any}()
|
||||
)
|
||||
return msgPayload_v1(
|
||||
id,
|
||||
dataname,
|
||||
type,
|
||||
transport,
|
||||
encoding,
|
||||
size,
|
||||
data,
|
||||
metadata
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
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::String # purpose of this message e.g. "ACK | NACK | updateStatus | shutdown | ..."
|
||||
senderName::String # 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::AbstractArray{msgPayload_v1} # multiple payload store here
|
||||
end
|
||||
|
||||
# constructor
|
||||
function msgEnvelope_v1(
|
||||
correlationId::String = "";
|
||||
msgId::String = "",
|
||||
timestamp::String = "",
|
||||
sendTo::String = "",
|
||||
msgPurpose::String = "",
|
||||
senderName::String = "",
|
||||
senderId::String = "",
|
||||
receiverName::String = "",
|
||||
receiverId::String = "",
|
||||
replyTo::String = "",
|
||||
replyToMsgId::String = "",
|
||||
BrokerURL::String = DEFAULT_NATS_URL,
|
||||
note::Dict{String, Any} = Dict{String, Any}(),
|
||||
payloads::AbstractArray{msgPayload_v1} = msgPayload_v1[]
|
||||
)
|
||||
return msgEnvelope_v1(
|
||||
correlationId,
|
||||
msgId,
|
||||
timestamp,
|
||||
sendTo,
|
||||
msgPurpose,
|
||||
senderName,
|
||||
senderId,
|
||||
receiverName,
|
||||
receiverId,
|
||||
replyTo,
|
||||
replyToMsgId,
|
||||
BrokerURL,
|
||||
note,
|
||||
payloads
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ struct msgEnvelope_v1
|
||||
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
|
||||
metadata::Dict{String, Any}
|
||||
payloads::AbstractArray{msgPayload_v1} # multiple payload store here
|
||||
end
|
||||
|
||||
@@ -84,7 +84,7 @@ function msgEnvelope_v1(
|
||||
replyTo::String = "",
|
||||
replyToMsgId::String = "",
|
||||
BrokerURL::String = DEFAULT_NATS_URL,
|
||||
note::Dict{String, Any} = Dict{String, Any}(),
|
||||
metadata::Dict{String, Any} = Dict{String, Any}(),
|
||||
payloads::AbstractArray{msgPayload_v1} = msgPayload_v1[]
|
||||
)
|
||||
return msgEnvelope_v1(
|
||||
@@ -100,7 +100,7 @@ function msgEnvelope_v1(
|
||||
replyTo,
|
||||
replyToMsgId,
|
||||
BrokerURL,
|
||||
note,
|
||||
metadata,
|
||||
payloads
|
||||
)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user