Search code examples
pythontypesvolttron

data type of message in volttron pubsub


What is the data type for "message" in pubsub used by volttron? I have checked the documentation but there is nothing mentioned about this. When checking the source I found this function comment source :

param headers: header info for the message,
type headers: None or dict,
param message: actual message,
type message: None or any

Are the above info correct? Does that "any" type refer to this: typing.Any?


Solution

  • The message can be any Python object that can be serialized into JSON. Typically this will be something specifically defined by the Agent publishing the message that aligns with the purpose of the message. Usually this will be a dictionary or list, but occasionally messages will be numbers or strings. VOLTTRON does not place any restrictions on the structure of the data as long as it can be serialized.

    It is up to agents define the datatype of the message and document it for use by other agents.

    Nested data structures are allowed as they are in JSON.