FAQ | This is a LIVE service | Changelog

Add new decorator to parse message data using a supplied protobuf class

Description

Extend the added pubsub_messages function to add a new decorator which extracts the data in the MessagePublishedData.message.data field from the event, deserialises the data into a supplied protobuf message class, and returns that protobuf message instance to the handler.

Further details

This should be an overload of the original decorator, discriminated by an argument which is a protobuf message class.

We currently make use of betterproto for python protobuf client libraries - so there should be two overloads, one for the standard python protobuf library message classes and one for the betterproto message classes.

Task list

Acceptance criteria

  • Decorator overload(s) to perform message payload validation/parsing via
    • Support raw protobuf message classes
    • Support betterproto message classes
  • Validation errors should be caught and logged as exceptions, with a 400 response to the caller

Links/references

Edited by Mike Knee