stop if alert cannot be sent

This commit is contained in:
Alex Tau 2026-01-01 16:49:13 +03:00
parent 191839d30f
commit 6c8ae03b6a

View file

@ -40,14 +40,14 @@ def format_message(alert: Alert, note: str) -> str:
async def send_alert(alert: Alert, note: str = "") -> Success[None] | Failure[tenacity.RetryError]:
await log_errors_async(_send_alert(alert, note))
return await log_errors_async(_send_alert(alert, note))
async def send_healthchecks_status(alert: Alert) -> Success[None] | Failure[tenacity.RetryError]:
await log_errors_async(_send_healthchecks_status(alert))
return await log_errors_async(_send_healthchecks_status(alert))
@tenacity.retry(wait=tenacity.wait_random_exponential(multiplier=1, max=60))
@tenacity.retry(wait=tenacity.wait_random_exponential(multiplier=1, max=60), stop=tenacity.stop_after_attempt(3))
async def _send_alert(alert: Alert, note: str = "") -> None:
logging.debug(f"Sending {alert.alert_type} alert to Telegram")
tg_client = cvars.tg_client.get()
@ -57,7 +57,7 @@ async def _send_alert(alert: Alert, note: str = "") -> None:
await tg_client.send_message(entity=room_id, message=message)
@tenacity.retry(wait=tenacity.wait_random_exponential(multiplier=1, max=60))
@tenacity.retry(wait=tenacity.wait_random_exponential(multiplier=1, max=60), stop=tenacity.stop_after_attempt(3))
async def _send_healthchecks_status(alert: Alert) -> None:
def get_pinging_key(keys: dict[str, str]):
if alert.healthchecks_slug in keys: