-
Couldn't load subscription status.
- Fork 4
HTTPPlugin : Add a builder option to provide custom server (enables providing options like ssl etc) #185
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for custom server configuration in the HTTPPlugin by introducing a server_factory parameter. This enables users to provide their own pre-configured uvicorn server with custom options like SSL certificates, custom logging, or other server-level configurations.
Key Changes:
- Added optional
server_factoryparameter to HTTPPlugin constructor - Modified startup logic to use custom server when provided, with port conflict detection
- Added documentation for the new parameter
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| try: | ||
| config = uvicorn.Config(app=self.app, host="0.0.0.0", port=port, log_level="info") | ||
| self._server = uvicorn.Server(config) | ||
| if self._server and self._server.config.port != self._port: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we may want to move this port check into the constructor, so it fails earlier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not throwing an error for this, just a warning to say the port being used is from this builder fn and not the one provided by app.
Also the port is not available then I think, because it can be provided via app.start(port=..) too right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah thats true, it comes from the event itself- instead of saying 'plugin had requested' can we say the plugin start event?
| app_id: Optional[str], | ||
| logger: Optional[Logger] = None, | ||
| skip_auth: bool = False, | ||
| server_factory: Optional[Callable[[FastAPI], uvicorn.Server]] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these be more generic? Instead of FastAPI, can it just be ASGIApplication, and instead of uvicorn.Server, it should be whatever server is being used right? The whole point of this effort is that something other than uvicorn.Server should be returnable?
One option is to make this piece generic
Tested with code like (check running on and activities received on port 8000 )