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

refactor plugin protocol #1176

Merged
merged 6 commits into from Feb 9, 2023
Merged

refactor plugin protocol #1176

merged 6 commits into from Feb 9, 2023

Conversation

Goldziher
Copy link
Contributor

PR Checklist

  • Have you followed the guidelines in CONTRIBUTING.rst?
  • Have you got 100% test coverage on new code?
  • Have you updated the prose documentation?
  • Have you updated the reference documentation?

@Goldziher Goldziher requested a review from a team as a code owner February 8, 2023 18:56
CHANGELOG.rst Outdated Show resolved Hide resolved
CHANGELOG.rst Outdated Show resolved Hide resolved
@sonarcloud
Copy link

sonarcloud bot commented Feb 8, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

97.7% 97.7% Coverage
0.0% 0.0% Duplication

Copy link
Contributor

@peterschutt peterschutt left a comment

Choose a reason for hiding this comment

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

OK, plugins are now generic on both the source data type and the transform type.

I assume this is to allow us to make plugins that transform into msgspec structs?

I know that I'd prefer my DTOs to be msgspec structs and parsed directly from the request buffer, but this will allow users to have a choice.

This plays into a redesign I was already considering for the DTO refactor. At the moment, DTO instances are pydantic models, but they probably need to be their own type, and hold a reference to a thing that does the ser/de and validation, be that a pydantic model, or msgspec struct or whatever, and what that thing is will depend on the type of plugin the dto factory is given.

E.g, if a DTO factory type is given a plugin that is narrowed to pydantic base model, then it will produce a ser/de object that is a pydantic model, if it is given a plugin narrowed to msgspec structs, then it will produce a struct for its ser/de object.

Before this, I was not confident about meeting the 20th deadline (not just for the DTO refactor, but for everything I want to have in 2.0), but I think will be a positive redesign.

docs/usage/plugins/index.rst Outdated Show resolved Hide resolved
starlite/plugins/base.py Outdated Show resolved Hide resolved
peterschutt added a commit that referenced this pull request Feb 9, 2023
Base automatically changed from 1118-enhancement-support-returning-token-in-response-body-with-jwtauth to 1132-enhancement-completely-overwriting-the-operationid February 9, 2023 06:45
Base automatically changed from 1132-enhancement-completely-overwriting-the-operationid to main February 9, 2023 06:46
@Goldziher Goldziher merged commit be60e69 into main Feb 9, 2023
@Goldziher Goldziher deleted the cleanup-plugin-protocols branch February 9, 2023 06:57
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.

None yet

2 participants