Coverage for /usr/local/lib/python3.10/site-packages/opal_common-0.0.0-py3.10.egg/opal_common/fetcher/events.py: 100%
14 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 11:54 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 11:54 +0000
1from typing import ClassVar, List, Optional, Set
3from opal_common.logging_utils.redaction import RedactedReprMixin
4from pydantic import BaseModel, Field
7class FetcherConfig(RedactedReprMixin, BaseModel):
8 """The configuration of a fetcher, used as part of a FetchEvent Fetch
9 Provider's have their own unique events and configurations.
11 Configurations
13 Note: subclasses commonly carry credentials (e.g. auth headers). They must
14 list any secret-bearing fields in ``_redacted_repr_fields`` so they never
15 leak into logs - see ``RedactedReprMixin``.
16 """
18 fetcher: Optional[str] = Field(
19 None,
20 description="indicates to OPAL client that it should use a custom FetcherProvider to fetch the data",
21 )
24class FetchEvent(RedactedReprMixin, BaseModel):
25 """Event used to describe an queue fetching tasks Design note -
27 By using a Pydantic model - we can create a potentially transfer FetchEvents to be handled by other network nodes (perhaps via RPC)
28 """
30 # ``config`` may carry a FetcherConfig with credentials - mask it in repr/str.
31 _redacted_repr_fields: ClassVar[Set[str]] = {"config"}
32 # ``url`` can embed credentials (``user:token@host`` / ``?token=``); strip
33 # them via redact_url while keeping host/path visible for debugging.
34 _redacted_url_fields: ClassVar[Set[str]] = {"url"}
36 # Event id to be filled by the engine
37 id: str = None
38 # optional name of the specific event
39 name: str = None
40 # A string identifying the fetcher class to use (as registered in the fetcher register)
41 fetcher: str
42 # The url the event targets for fetching
43 url: str
44 # Specific fetcher configuration (overridden by deriving event classes (FetcherConfig)
45 config: dict = None
46 # Tenacity.retry - Override default retry configuration for this event
47 retry: dict = None