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

Service enhancement prerequisites for XFR support #369

Merged
merged 19 commits into from
Sep 3, 2024

Conversation

ximon18
Copy link
Member

@ximon18 ximon18 commented Aug 6, 2024

Taken from the xfr branch in order to split PR #335 into several smaller PRs.

This PR makes changes, some of which are breaking (i.e. not backward compatible with earlier unstable server functionality without minor adjustments to existing consumer code, e.g. see the changes to examples/serve-zone.rs), including:

  • Adds support for indicating to downstream Service impls that a certain number of bytes should be reserved (to make space for adding a TSIG RR or EDNS options during middleware post-processing).

  • Adds support for strongly typed passing of arbitrary metadata between middleware that produces a type and middleware that consumes the type (e.g. passing the used TSIG key name from TSIG middleware to XFR middleware).

  • Replaces the blanket impl Service for Arc with a more general impl Service for Deref.

  • Removes the blanket impl Service for fn as I have multiple times been blocked from defining some other Service impl because the fn one matches, because its presence can cause very confusing compiler error messages if your impl Service for T is not quite in sync with the signature of your other impl T blocks, and because Hyper doesn't need it so why do we?

  • Adds an "enabled" flag to the CookiesMiddlewareSvc (and later the TsigMiddlewareSvc will have it as well) making it easier to create a service stack with optionally enabled layers based on runtime configuration.

There was some internal discussion today with @Philip-NLnetLabs about passing data between middleware layers instead as a map of string key to some value pairs, or adding an enum to Request with things that a middleware might need (e.g. TSIG key name, or other arbitrary T), but that isn't reflected (yet?) in this PR.

The upside of the approach in this PR is it allows a producing middleware to express the metadata type it produces and a consuming middleware to express compatibility with a certain metadata type (e.g. via a trait impl, see 88a8f02) and to then have compile time checking that the middleware are compatible with each other, without having to express up front every possible data that might need to be passed around with a request or else as some arbitrary Other(T). But I'm undecided about the best way to do this ...

The changes in this PR currently lack RustDocs, and testing (as the consuming and testing is done at the point of use in the xfr branch).

ximon18 added 5 commits August 6, 2024 23:34
…tain number of bytes should be reserved (to make space for post-processing adding EDNS options to the response), and (b) strongly typed passing of arbitrary metadata between middleware that produces a type and middleware that consumes the type (e.g. a TSIG key name).
@ximon18 ximon18 requested a review from a team August 6, 2024 21:54
@ximon18 ximon18 changed the title Service (middleware) request metadata and byte reservation. Service extensions to support XFR Aug 7, 2024
@ximon18 ximon18 changed the title Service extensions to support XFR Service enhancement prerequisites for XFR support Aug 7, 2024
@ximon18 ximon18 changed the title Service enhancement prerequisites for XFR support Service enhancement pre-requisites for XFR support Aug 8, 2024
@ximon18 ximon18 changed the title Service enhancement pre-requisites for XFR support Service enhancement prerequisites for XFR support Aug 8, 2024
Copy link
Member

@Philip-NLnetLabs Philip-NLnetLabs left a comment

Choose a reason for hiding this comment

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

Looks good to me except for start_error.

@ximon18 ximon18 merged commit ce74445 into main Sep 3, 2024
26 checks passed
@ximon18 ximon18 deleted the service-request-metadata-and-byte-reservation branch September 3, 2024 20:45
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.

2 participants