Skip to content

Commit

Permalink
feat: Add minimal webhook back off retries similar to Stripe
Browse files Browse the repository at this point in the history
  • Loading branch information
danh91 committed Dec 17, 2024
1 parent 95414d2 commit c75a6db
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ OIDC_RSA_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nMIIJKQIBAAKCAgEA92+93Tyg6

# Worker config
# WORKER_IMMEDIATE_MODE=True
TRACKING_PULSE=120
TRACKING_PULSE=1200

## Email auth
# EMAIL_PORT=1025
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ def _run(**kwargs):
_run()


@db_task()
@db_task(retries=5, retry_delay=60)
@utils.tenant_aware
def notify_webhooks(*args, **kwargs):
from karrio.server.events.task_definitions.base import webhook
try:
from karrio.server.events.task_definitions.base import webhook

utils.failsafe(
lambda: webhook.notify_webhook_subscribers(*args, **kwargs),
"An error occured during webhook notification: $error",
)
webhook.notify_webhook_subscribers(*args, **kwargs)

except Exception as e:
logger.error(f"An error occured during webhook notification: {e}")
raise e


@db_periodic_task(crontab(hour=f"*/{DATA_ARCHIVING_SCHEDULE}"))
Expand All @@ -54,6 +56,7 @@ def _run(**kwargs):

_run()


TASK_DEFINITIONS = [
background_trackers_update,
periodic_data_archiving,
Expand Down

0 comments on commit c75a6db

Please sign in to comment.