in src/pubsub/pubsub_messages.py [0:0]
def get_pubsub_response(self, message_id, command, status, data=None):
'''
Retuens a well formatted PubSub RESPONSE Message.
Parameters
----------
message-id: str
Timestamp or other unique identifier for message tracking across request / response.
command : str
Name of the command, request or action to execute on the receiving component.
response: dict
status : int
200 OK COMPLETE, 202 ASYNC REQUEST ACCEPTED, 404 COMMAND NOT RECOGNISED, 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 a well formatted PubSub RESPONSE
return {
'message-id': message_id, # Should be reflected from the request to track response.
'reqres' : 'response', # Indicates is a RESPONSE 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
}
}