ci: expand CI checks and make consumer sync opt-in
- Add Go, npm, Python, and Java validation to CI - Run Go tests against PostgreSQL - Record performance fixes in the report
This commit is contained in:
1 parent
199a5efaef
commit
22887fef03
100 files changed
+9740
-429
No files matched your search
@@ -15,6 +15,24 @@ from .config import DatabaseConfig
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
# The same connection failures that database.js treats as transient: refused,
|
||||
# reset and broken sockets, an administrative shutdown, a dropped connection
|
||||
# (SQLSTATE class 08) and a connect timeout. Other errors, such as bad
|
||||
# credentials or a missing database, are raised at once instead of retried.
|
||||
_TRANSIENT_CONNECTION_ERRORS = (
|
||||
ConnectionRefusedError,
|
||||
ConnectionResetError,
|
||||
BrokenPipeError,
|
||||
TimeoutError,
|
||||
asyncpg.exceptions.AdminShutdownError,
|
||||
asyncpg.exceptions.PostgresConnectionError,
|
||||
)
|
||||
|
||||
|
||||
def is_transient_connection_error(exc: BaseException) -> bool:
|
||||
"""Return True for connection failures that a startup retry can recover from."""
|
||||
return isinstance(exc, _TRANSIENT_CONNECTION_ERRORS)
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class StartupRetryOptions:
|
||||
@@ -50,7 +68,11 @@ async def retry_startup(
|
||||
operation: Callable[[], Awaitable[Any]],
|
||||
options: StartupRetryOptions | None = None,
|
||||
) -> Any:
|
||||
"""Retry a startup operation until it succeeds or the context is cancelled."""
|
||||
"""Retry a startup operation on transient connection errors only.
|
||||
|
||||
Any other exception is raised immediately, so a wrong password or a missing
|
||||
database does not spin until the process is stopped.
|
||||
"""
|
||||
policy = options or startup_retry_options_from_env()
|
||||
attempt = 0
|
||||
|
||||
@@ -61,6 +83,8 @@ async def retry_startup(
|
||||
except asyncio.CancelledError:
|
||||
raise
|
||||
except Exception as exc:
|
||||
if not is_transient_connection_error(exc):
|
||||
raise
|
||||
if policy.max_attempts and attempt >= policy.max_attempts:
|
||||
raise
|
||||
_logger.warning(
|
||||
|
||||
Reference in new issue
Block a user