-
-
Notifications
You must be signed in to change notification settings - Fork 199
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: add service package and start splitting HTTP handling #1427
base: main
Are you sure you want to change the base?
Conversation
Package service exposes types to abstract services from the networking. The idea is that we build a set of services and a set of network endpoints (Listener). The services are then assigned to endpoints based on the address(es) they were configured for. Actual service to endpoint binding is not handled by the abstractions in this package as it is protocol specific. The general pattern is to make a "server" that wraps a service, and can then be started on an endpoint using a `Serve` method, similar to `http.Server`. To support exposing multiple compatible services on a single endpoint (example: DoH + metrics on a single port), services can implement `Merger`.
I still need to write tests for the new package, and the various new "services", but besides that it's in a reviewable state :) |
Skimmed over your PR and it looks very good! 👍 |
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.
Read through it and I think you did an amazing job. 👍
This approach looks like a really good foundation for a step wise implementation without end-user obstruction.
Progress for #1206.
No user visible changes in this PR: it's just refactoring and the new config cannot be set from the YAML file.
Instead the new config structs are filled with the info from
ports:
until we're ready to deprecateports
fully.The first part of the commits refactor how we setup the HTTP listeners.
The second part adds a new
service
package with interfaces used to split upserver.Server
.The commits after adding that package refactor the DoH, metrics, and API to be services.
Here's the docs that package as an overview of the design:
This doesn't touch DNS listener/server code (besides moving the TLS config to a single spot), but I think we'll be able to re-use the same code to setup DNS listeners, and split the DNS server logic into a bunch of services + one server.
The follow-up work is to continue removing things from
configureHTTPRouter
until it's empty and we can remove the transitionalhttpMiscService
.At that point we'll be ready to deprecate
ports
and switch to the newservices
config format under discussion in #1206.