:py:mod:`flow.record.context` ============================= .. py:module:: flow.record.context Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: flow.record.context.AppContext Functions ~~~~~~~~~ .. autoapisummary:: :nosignatures: flow.record.context.get_app_context flow.record.context.fresh_app_context flow.record.context.match_record_with_context Attributes ~~~~~~~~~~ .. autoapisummary:: flow.record.context.APP_CONTEXT .. py:data:: APP_CONTEXT :type: contextvars.ContextVar[AppContext] .. py:function:: get_app_context() -> AppContext Retrieve the application context, creating it if it does not exist. :returns: The application context. .. py:function:: fresh_app_context() -> collections.abc.Generator[AppContext, None, None] Create a fresh application context for the duration of the with block. .. py:class:: AppContext Context for the application, holding metrics like amount of processed records. .. py:attribute:: read :type: int :value: 0 .. py:attribute:: matched :type: int :value: 0 .. py:attribute:: unmatched :type: int :value: 0 .. py:attribute:: source_count :type: int :value: 0 .. py:attribute:: source_total :type: int :value: 0 .. py:function:: match_record_with_context(record: flow.record.Record, selector: flow.record.selector.Selector | None, context: AppContext) -> bool Return True if ``record`` matches the ``selector``, also keeps track of relevant metrics in ``context``. If selector is None, it will always return True. When calling this function, it also increases the ``context.read`` property. :param record: The record to match against the selector. :param selector: The selector to use for matching. :param context: The context in which the record is being matched. :returns: True if record matches the selector, or if selector is None