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 handlers as FastAPI APIRoutes to allow for Depends injection,… #13

Merged
merged 7 commits into from
Jan 19, 2022

Conversation

pkucmus
Copy link
Collaborator

@pkucmus pkucmus commented Dec 12, 2021

… refactor

  • update deps
  • remove the need for the framework to have the apps Settings
  • deatach Manifest from settings
  • deatach development http/https handling from the debug setting (for unambiguity)
  • create APIRoutes for every webhook handler
  • introduce the Simple Saleor Client (potentially will land in a separate package in the future)
  • add url_for resololution in Manifest URLs
  • describe different verions of webhook payloads (with meta)

Add experimental SQS support, imporved resiency, add test coverage

  • add SQS targetUrl handling on installation
  • add the ability to not provide any handlers
  • stop using FastAPI app.extra
  • add lazy url loading on manifest definition
  • hide potentially sensitive logs to debug level
  • add dynamic webhook handler model definition (for easier maintenence)
  • add EXPERIMENTAL SQS worker (untested)

… refactor

- update deps
- remove the need for the framework to have the apps Settings
- deatach Manifest from settings
- deatach development http/https handling from the debug setting (for unambiguity)
- create APIRoutes for every webhook handler
- introduce the Simple Saleor Client (potentially will land in a separate package in the future)
- add url_for resololution in Manifest URLs
- describe different verions of webhook payloads (with meta)
@CLAassistant
Copy link

CLAassistant commented Dec 12, 2021

CLA assistant check
All committers have signed the CLA.

samples/simple_app/app.py Outdated Show resolved Hide resolved
samples/simple_app/app.py Outdated Show resolved Hide resolved
samples/simple_app/app.py Outdated Show resolved Hide resolved
samples/simple_app/app.py Outdated Show resolved Hide resolved
src/saleor_app/app.py Outdated Show resolved Hide resolved
src/saleor_app/app.py Outdated Show resolved Hide resolved
src/saleor_app/app.py Outdated Show resolved Hide resolved
src/saleor_app/endpoints.py Outdated Show resolved Hide resolved
src/saleor_app/endpoints.py Outdated Show resolved Hide resolved
src/saleor_app/http.py Outdated Show resolved Hide resolved
src/saleor_app/http.py Outdated Show resolved Hide resolved
src/saleor_app/install.py Outdated Show resolved Hide resolved
@pkucmus pkucmus marked this pull request as ready for review January 16, 2022 00:36
@pkucmus pkucmus requested a review from korycins January 16, 2022 00:36
@pkucmus pkucmus changed the title [POC] Webhook handlers as FastAPI APIRoutes to allow for Depends injection,… Webhook handlers as FastAPI APIRoutes to allow for Depends injection,… Jan 16, 2022
- add SQS targetUrl handling on installation
- add the ability to not provide any handlers
- stop using FastAPI app.extra
- add lazy url loading on manifest definition
- hide potentially sensitive logs to debug level
- add dynamic webhook handler model definition (for easier maintenence)
- add EXPERIMENTAL SQS worker (untested)
@pkucmus pkucmus force-pushed the feature/webhook_handler_improvements branch from 8ccf9e1 to 129e638 Compare January 16, 2022 00:48
docs/index.md Show resolved Hide resolved
docs/index.md Outdated Show resolved Hide resolved
docs/event_handlers/http.md Outdated Show resolved Hide resolved
docs/event_handlers/http.md Outdated Show resolved Hide resolved
docs/event_handlers/http.md Outdated Show resolved Hide resolved
src/saleor_app/saleor/utils.py Show resolved Hide resolved

# app.dependency_overrides[verify_saleor_domain] = lambda: True
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be removed, right?

src/saleor_app/workers/base.py Outdated Show resolved Hide resolved
src/saleor_app/workers/base.py Outdated Show resolved Hide resolved
src/saleor_app/workers/sqs.py Outdated Show resolved Hide resolved
samples/simple_app/app.py Show resolved Hide resolved
samples/simple_app/app.py Outdated Show resolved Hide resolved
src/saleor_app/deps.py Show resolved Hide resolved
src/saleor_app/deps.py Show resolved Hide resolved
src/saleor_app/endpoints.py Show resolved Hide resolved
src/saleor_app/tests/test_deps.py Show resolved Hide resolved
src/saleor_app/tests/test_deps.py Show resolved Hide resolved
src/saleor_app/app.py Outdated Show resolved Hide resolved
@pkucmus pkucmus requested a review from korycins January 17, 2022 22:11
@@ -39,7 +39,7 @@ async def get_webhook_details(domain_name: DomainName) -> WebhookData:
app = SaleorApp(
validate_domain=validate_domain,
save_app_data=store_app_data,
webhook_handlers=webhook_handlers,
http_webhook_handlers=webhook_handlers,
Copy link
Contributor

Choose a reason for hiding this comment

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

It is not needed anymore, right?

@@ -17,7 +17,7 @@ async def product_deleted(payload: Payload, saleor_domain: DomainName):
print(payload)


webhook_handlers = WebhookHandlers(
http_webhook_handlers = WebhookHandlers(
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe, everything with WebhookHandlers can be removed, right?

src/saleor_app/install.py Outdated Show resolved Hide resolved
src/saleor_app/endpoints.py Show resolved Hide resolved
src/saleor_app/endpoints.py Outdated Show resolved Hide resolved
"Unable to finish installation of app for %s. Received error: %s",
domain,
webhook_error,
logger.error("Unable to finish installation of app for %s.", saleor_domain)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should figure out how to treat an installation when some of the requests will pass successfully and the rest fail. But I don't think this is a scope of this PR, I just raise it to keep in mind

src/saleor_app/webhook.py Show resolved Hide resolved
@korycins korycins merged commit b8442bb into feature/extensions Jan 19, 2022
@korycins korycins deleted the feature/webhook_handler_improvements branch January 19, 2022 07:18
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.

5 participants