Message¶
Handler for non-HTTP interactions.
This module implements a very basic handler to handle JSON payloads which might be sent from Kafka, or some queueing system. Unlike a HTTP interaction, the handler is solely responsible for processing the message, and does not necessarily need to send a response.
Classes¶
Filesystem()
¶
Handler()
¶
Message queue handler.
This class is responsible for handling messages from the queue.
This ensures the underlying filesystem is ready to be used.
Source code in examples/src/message.py
Attributes¶
fs = Filesystem()
instance-attribute
¶
Functions¶
process(event: Dict[str, Any]) -> Union[str, None]
¶
Process an event from the queue.
The event is expected to be a dictionary with the following mandatory keys:
action
: The action to be performed, eitherREAD
orWRITE
.path
: The path to the file to be read or written.
The event may also contain an optional contents
key, which is the
contents to be written to the file. If the contents
key is not
present, an empty file will be written.
Source code in examples/src/message.py
validate_event(event: Union[Dict[str, Any], Any]) -> None
staticmethod
¶
Validates the event received from the queue.
The event is expected to be a dictionary with the following mandatory keys:
action
: The action to be performed, eitherREAD
orWRITe
.path
: The path to the file to be read or written.