Skip to content

Commit

Permalink
fix: handler wrapper on top of failure notification service helper calls
Browse files Browse the repository at this point in the history
  • Loading branch information
anomit committed Aug 17, 2023
1 parent b3d0a68 commit bcc245d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions snapshotter/utils/callback_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from abc import ABCMeta
from abc import abstractmethod
from abc import abstractproperty
import functools
from typing import Any
from typing import Dict
from typing import Union
Expand Down Expand Up @@ -68,7 +69,7 @@ def misc_notification_callback_result_handler(fut: asyncio.Future):
logger.debug('Callback or notification result:{}', r)


def sync_notification_callback_result_handler(f):
def sync_notification_callback_result_handler(f: functools.partial):
try:
result = f()
except Exception as exc:
Expand Down Expand Up @@ -104,14 +105,16 @@ async def send_failure_notifications_async(client: AsyncClient, message: BaseMod

def send_failure_notifications_sync(client: SyncClient, message: BaseModel):
if settings.reporting.service_url:
f = client.post(
f = functools.partial(
client.post,
url=urljoin(settings.reporting.service_url, '/reportIssue'),
json=message.dict(),
)
sync_notification_callback_result_handler(f)

if settings.reporting.slack_url:
f = client.post(
f = functools.partial(
client.post,
url=settings.reporting.slack_url,
json=message.dict(),
)
Expand Down

0 comments on commit bcc245d

Please sign in to comment.