"""Downstream catalog for this service: the Resource enum + its DownstreamPolicy values. Service-specific (the set of downstreams ows-royalties calls and their tuned timeouts). The generic policy TYPE lives in `policy.py`; the inbound rate-limit policy lives in `rate_policy.py`. """ from enum import Enum from core.hardening.policy import DownstreamPolicy class Resource(Enum): """Downstream dependencies this service calls out to.""" OWS_COLLABORATOR = 'ows-collaborator' OWS_ABACUS_ACCOUNT = 'ows-abacus-account' AIRFLOW_MWAA = 'airflow-mwaa' SNOWFLAKE = 'snowflake' DOWNSTREAMS: dict[Resource, DownstreamPolicy] = { Resource.OWS_COLLABORATOR: DownstreamPolicy(3.05, 30, fail_max=5, reset_timeout=30), Resource.OWS_ABACUS_ACCOUNT: DownstreamPolicy( 3.05, 30, fail_max=5, reset_timeout=30 ), Resource.AIRFLOW_MWAA: DownstreamPolicy(3.05, 10, fail_max=3, reset_timeout=60), # read_timeout 50s: prod p99 is ~2s and the slowest observed request is ~27s. # The LB caps requests at 60s, so a higher value is unreachable. 50s sits below # uWSGI harakiri so the breaker (not worker kill) handles stalled Snowflake reads Resource.SNOWFLAKE: DownstreamPolicy(5.0, 50, fail_max=5, reset_timeout=120), }