Loading
Commits on Source 9
-
Hal Blackburn authored
ucam_faas.gcp_pubsub provides support for parsing/validating/serialising GCP Pub/Sub messages within CloudEvent envelopes. This is how `functions_framework` exposes Pub/Sub messages to handlers when a CloudRun function is subscribed to a Pub/Sub queue. The module contains constants for the CloudEvent type that identifies message events, and Pydantic data models for the data payload of these events.
-
Hal Blackburn authored
-
Hal Blackburn authored
The decorator supports event handler functions that process message events (currently GCP Pub/Sub messages, wrapped in CloudEvents). The functions receive messages as instances of a data type they choose, that represents the parsed payload of the message events they subscribe to. This decorator allows event handler functions to accept message data as a type representing the decoded payload of a message event. For example, a Pydantic model representing a JSON payload. - Validating incoming message metadata envelope - Parsing/validating the message payload - Recording the message envelope metadata in the function's `ExecutionInfo` result Handler functions can focus on processing decoded message data payloads, without needing to do their own parsing and validation or event metadata logging/reporting.
-
Hal Blackburn authored
This allows @message_handler(message_type=SomeModel) to parse a JSON Pub/Sub message with the SomeModel model, and have the decorated handler receive an instance of the model.
-
Hal Blackburn authored
This allows @message_handler(message_type=MyMessage) to parse a Pub/Sub message containing a Protobuf payload, where MyMessage is any Protobuf Message class generated by the protoc compiler. The decorated handler receives an instance of the message class.
-
Hal Blackburn authored
-
Hal Blackburn authored
The doctest example we had in the @message_handler docstring was trying to be a representative example of a real handler function, but this made it less easy to understand compared to a more minimal example. We now present a basic "Hello World" type handler that does very little, but should do enough to communicate the basics.
-
lib-bot authored