in src/pubsub/pubsub_messages.py [0:0]
def get_pubsub_update(self, command, status, data=None):
'''
Returns a well formatted PubSub UPDATE Message.
This message type is to identify unsolicited updates meaning it is not
in response to a specific REQUEST but instead to some external event or trigger.
Parameters
----------
command : str
Name of the command, request or action to execute on the receiving component.
response: dict
status : int
200 OK COMPLETE, 500 INTERNAL COMPONENT ERROR.
data : any (preferred dict), default=None
Dict, Array or any object able to be serialised containing data to be published with the response message.
'''
# Return well formatted PubSub UPDATE
return {
'message-id': datetime.now().strftime("%Y%m%d%H%M%S%f"), # Generated Timestamp / ID to track the request flow.
'reqres' : 'update', # Indicates is a unsolicited UPDATE message type to aid application routing.
'command': command, # Command responding too for message routing and application logic.
'response': { # Response Object. Expected to contain response data and mandatory status fields.
'data': data, # Response Data field None or customisable to data request.
'status': status # Response status code: 200, 202, 404, 500
}
}