Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webhook Support for Task Queue #225

Merged
merged 13 commits into from
Feb 4, 2025
Merged

Webhook Support for Task Queue #225

merged 13 commits into from
Feb 4, 2025

Conversation

movchan74
Copy link
Contributor

@movchan74 movchan74 commented Jan 30, 2025

Add webhook support for Aana SDK, with events for the task queue.

  • Added CRUD endpoints for webhooks.
  • Added storage for webhooks.
  • Webhooks are signed with HMAC.
  • Webhooks can be triggered on task creation, processing start, and completion.
  • Each webhook can be set to all or some events.
  • Tests are added to ensure correct behavior.

Closes: #178

movchan74 and others added 2 commits January 30, 2025 11:18
Add webhook support for the task queue system.

* Add new endpoint `POST /webhooks` in `aana/api/app.py` to register webhooks and store webhook details in the database.
* Add logic in `aana/api/request_handler.py` to trigger webhooks on task status change, implement HMAC signature generation for webhook payloads, and add retry mechanism for webhook delivery using `tenacity`.
* Add settings for webhook retries and HMAC secrets in `aana/configs/settings.py`.
* Create a new model `WebhookEntity` in `aana/storage/models/webhook.py` for storing webhook details.
* Create a repository `WebhookRepository` in `aana/storage/repository/webhook.py` for managing webhook data.
* Add tests for webhook registration and triggering in `aana/tests/api/test_webhooks.py`.
* Add tests for webhook triggering on task status change in `aana/tests/api/test_task_status.py`.
* Add OpenAPI specifications for the new webhook endpoints and define multiple event types for tasks in `aana/api/api_generation.py`.
@movchan74 movchan74 changed the title Enhanced webhook support for task queue Webhook Support for Task Queue Jan 30, 2025
@movchan74 movchan74 requested a review from HRashidi February 3, 2025 17:51
Copy link
Contributor

@HRashidi HRashidi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments for now

aana/storage/models/__init__.py Show resolved Hide resolved
aana/api/webhook.py Outdated Show resolved Hide resolved
aana/api/webhook.py Outdated Show resolved Hide resolved
aana/core/models/api_service.py Show resolved Hide resolved
aana/api/webhook.py Show resolved Hide resolved
@movchan74 movchan74 requested a review from HRashidi February 4, 2025 10:25
Copy link
Contributor

@HRashidi HRashidi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@movchan74 movchan74 merged commit 533ab95 into main Feb 4, 2025
9 checks passed
@movchan74 movchan74 deleted the movchan74/webhook-support branch February 4, 2025 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST] Webhook Support for Task Queue
2 participants