Request only the Eio capabilities from env that are actually needed#220
Open
vog wants to merge 1 commit into
Open
Request only the Eio capabilities from env that are actually needed#220vog wants to merge 1 commit into
vog wants to merge 1 commit into
Conversation
This implements the recommendation "Passing env" from the Eio documentation: https://github.com/ocaml-multicore/eio#passing-env
Author
|
@anmonteiro I'm unsure how to deal with the failing CI tests, in particular, whether I'm supposed to do anything about these at all. All "failures" are simply suggestions by the formatter to reformat the code - most of which this PR doesn't even touch. |
Author
|
@anmonteiro Do you have any advice for me how to proceed here? Should I provide a separate PR that fixes the formatting in the existing code, then basing my PR on that one? Or, which approach would you prefer? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This implements the recommendation "Passing env" from the Eio documentation:
Among others, this makes Piaf easier to use in applications where only the actually required capabilities are passed around, avoiding the need to define dummy capabilities just to fulfill Piaf's interface.
To provide a specific example, it helps to reduce code like this:
to that:
Some remarks about the implementation:
required_env(client.ml) andclock(server.ml) simplify the type definition and casting required to put the Eio capabilities into a record.order_v4v6has been moved out ofConnection.resolve_hostto make the latter polymorphic in itsenvparameter. Otherwise, callingConnection.resolve_hostwould be more cumbersome, as each call would require an explicit downcast torequired_env(or a copy of that type inConnection).resolve_host env ~config ~port hostname =, but I kept the current style to avoid messing around with the indentation, which would make the PR harder to read.