Loading
Commits on Source 7
-
Hal Blackburn authored
This function creates default_factory functions that source values from `ContextVar`s. Pydantic models and dataclasses can use these default factory functions to automatically set properties from their environment.
-
Hal Blackburn authored
This decorator takes care of the common functionality that typical event-handler functions need when they process CloudEvents. It provides support for: - Validating the type of incoming CloudEvents - Parsing/validating the data payload of CloudEvents - Recording the CloudEvent's metadata in the function's ExecutionInfo result Handler functions can focus on processing a primary data value without needing to do their own parsing and validation or event metadata logging/reporting. To use this module, handler functions are wrapped with this module's `@cloud_event_handler(...)` decorator. The decorator takes a parser function that is responsible for validating CloudEvent values, and extracting their data payload. Handler functions receive the primary value from the parser function, and also have access to the the full CloudEvent via the `CLOUD_EVENT_HANDLER_CONTEXT` `ContextVar`. Metadata from the CloudEvent is automatically included in `CloudEventHandlerExecutionInfo` values created within the handler function's scope.
-
Hal Blackburn authored
Contextual event handler functions receive a primary value as an argument, with additional context value provided to implicitly using a `ContextVar`. This separation allows a handler function to act primarily on an important subset of incoming event data, but still access the wider event metadata when needed, and automatically include metadata in `ExecutionInfo` result values (using the `contextual_default_factory()` pattern). Incoming events are separated into the primary value and context value by a parser function that receives the incoming event value from the parent handler. The `@contextual_handler(...)` decorator is the interface to this functionality.
-
Hal Blackburn authored
The doctest example we had in the @cloud_event_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.
-
Hal Blackburn authored
High-level handlers MR2: Contextual handlers See merge request !50
-
Hal Blackburn authored
High-level handlers MR3: CloudEvent handlers Closes #26 See merge request !51
-
lib-bot authored