Skip to content

Commit 2a8fc7f

Browse files
author
Carl Bordum Hansen
committed
Merge branch 'retry-on-unsilence' into 'master'
fix: [#64073] immediately retry events on unsilence See merge request rammearkitektur/os2mo!2609
2 parents c871910 + 91235a3 commit 2a8fc7f

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

backend/mora/graphapi/versions/latest/mutators.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# SPDX-License-Identifier: MPL-2.0
33
import asyncio
44
import logging
5+
from datetime import datetime
56
from textwrap import dedent
67
from typing import Annotated
78
from typing import Any
@@ -1930,7 +1931,16 @@ async def event_unsilence(
19301931

19311932
# coverage: pause
19321933
session: AsyncSession = info.context["session"]
1933-
await session.execute(update(db.Event).where(*clauses).values(silenced=False))
1934+
await session.execute(
1935+
update(db.Event)
1936+
.where(*clauses)
1937+
.values(
1938+
silenced=False,
1939+
# Update last_tried to override back-off and retry event
1940+
# immediately.
1941+
last_tried=datetime(1970, 1, 1),
1942+
)
1943+
)
19341944
return True
19351945
# coverage: unpause
19361946

backend/tests/test_events.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,28 @@ def test_event_unsilence(namespace: str, graphapi_post: GraphAPIPost) -> None:
600600
assert event["subject"] == "alice"
601601

602602

603+
@pytest.mark.integration_test
604+
@pytest.mark.usefixtures("empty_db")
605+
def test_event_unsilence_resends_immediately(
606+
namespace: str, graphapi_post: GraphAPIPost
607+
) -> None:
608+
routing_key = "rk"
609+
listener = declare_listener(graphapi_post, namespace, "uk", routing_key)
610+
send_event(graphapi_post, namespace, routing_key, "alice")
611+
612+
event = fetch_event(graphapi_post, listener)
613+
assert event is not None
614+
assert event["subject"] == "alice"
615+
616+
unsilence_event(
617+
graphapi_post, {"subjects": ["alice"], "listeners": {"uuids": [str(listener)]}}
618+
)
619+
620+
event = fetch_event(graphapi_post, listener)
621+
assert event is not None
622+
assert event["subject"] == "alice"
623+
624+
603625
@pytest.mark.integration_test
604626
@pytest.mark.usefixtures("empty_db")
605627
def test_event_deduplication(namespace: str, graphapi_post: GraphAPIPost) -> None:

0 commit comments

Comments
 (0)