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

Make libfetchers Input an interface with virtual methods. #9578

Open
roberth opened this issue Dec 10, 2023 · 1 comment
Open

Make libfetchers Input an interface with virtual methods. #9578

roberth opened this issue Dec 10, 2023 · 1 comment
Assignees
Labels
fetching Networking with the outside (non-Nix) world, input locking

Comments

@roberth
Copy link
Member

roberth commented Dec 10, 2023

Is your feature request related to a problem? Please describe.

The way libfetchers currently works is by making changes to an Input object, which is a mutable attrset-like map.

This makes the behavior of each fetcher somewhat harder to understand, because there's no overview of the states an Input can be in.

Describe the solution you'd like

By modeling the state of the input with actual C++ types, we - by default - canonicalize the state; reduce the entropy; making a function like fetchTree behave more predictably.

Step 1. Change Input type usages. s/Input/InputRef; and e.g. typedef ref<Input> InputRef;
Step 2. Move methods from InputScheme to Input as appropriate. Default implementations are provided that still refer to InputScheme, but InputScheme itself is not considered to be the public interface for the method anymore.
Step 3a. Subclass Input so that individual fetchers implement the new architecture
Step 3b. Make individual methods more functional.

Describe alternatives you've considered

Make Input a state machine, and put virtual methods on an object contained in it. Changes less code, but I would prefer to also move the library to a more functional style.

Additional context

  • Important for stabilization because this is bound to create subtle changes to its behavior. (NB they should be subtle and generally not break too many existing flakes; possibly some changes can be compensated somewhat in the flakes layer, e.g. call-flake.nix.) I hope I can keep it simple.

Priorities

Add 👍 to issues you find important.

@roberth roberth added the fetching Networking with the outside (non-Nix) world, input locking label Dec 10, 2023
@roberth roberth self-assigned this Dec 10, 2023
@roberth
Copy link
Member Author

roberth commented Jan 9, 2024

Change of strategy discussed very briefly in an earlier meeting, is to add types more gradually, "bottom up", without changing Input.

@thufschmitt thufschmitt removed this from the fetchTree stabilisation milestone Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fetching Networking with the outside (non-Nix) world, input locking
Projects
Status: Defined work
Status: Done
Development

No branches or pull requests

3 participants