FAQ | This is a LIVE service | Changelog

Commits on Source 7

  • Hal Blackburn's avatar
    feat: add contextual_default_factory() · 08f97beb
    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.
    08f97beb
  • Hal Blackburn's avatar
    feat: add @cloud_event_handler() decorator · 44ab0b74
    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.
    44ab0b74
  • Hal Blackburn's avatar
    feat: add contextual_handler() decorator · f9c36ab4
    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.
    f9c36ab4
  • Hal Blackburn's avatar
    docs: make @cloud_event_handler docstring simpler · 3f49a380
    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.
    3f49a380
  • Hal Blackburn's avatar
    Merge branch '19-hlh-mr2-contextual-handler' into 'main' · 99a84440
    Hal Blackburn authored
    High-level handlers MR2: Contextual handlers
    
    See merge request !50
    99a84440
  • Hal Blackburn's avatar
    Merge branch '19-hlh-mr3-cloud-event-handler' into 'main' · f5bd5a90
    Hal Blackburn authored
    High-level handlers MR3: CloudEvent handlers
    
    Closes #26
    
    See merge request !51
    f5bd5a90
  • lib-bot's avatar
    chore(release): 0.19.0 · 9882e40f
    lib-bot authored
    9882e40f
Loading
Loading