Skip to content

Make a few changes in prepartion for deeper cleanup of the remote protocols#8547

Merged
roberth merged 5 commits intoNixOS:masterfrom
obsidiansystems:proto-cleanup-prep
Jun 19, 2023
Merged

Make a few changes in prepartion for deeper cleanup of the remote protocols#8547
roberth merged 5 commits intoNixOS:masterfrom
obsidiansystems:proto-cleanup-prep

Conversation

@Ericson2314
Copy link
Member

Motivation

#6223 is approved pending some investigations of whether a few things can be done differently. This is the first few commits of that for which there were no major issues.

There is still a fair bit of code churn, however, so it is nice to merge this sooner to get that out of the way.

Context

#8365 and #8360 were previous rounds of cleanup that were also broken off and separated from #6223 to make things easier.

Checklist for maintainers

Maintainers: tick if completed or explain if not relevant

  • agreed on idea
  • agreed on implementation strategy
  • tests, as appropriate
    • functional tests - tests/**.sh
    • unit tests - src/*/tests
    • integration tests - tests/nixos/*
  • documentation in the manual
  • documentation in the internal API docs
  • code and comments are self-explanatory
  • commit message explains why the change was made
  • new feature or incompatible change: updated release notes

Priorities

Add 👍 to pull requests you find important.

This is generally a fine practice: Putting implementations in headers
makes them harder to read and slows compilation. Unfortunately it is
necessary for templates, but we can ameliorate that by putting them in a
separate header. Only files which need to instantiate those templates
will need to include the header with the implementation; the rest can
just include the declaration.

This is now documenting in the contributing guide.

Also, it just happens that these polymorphic serializers are the
protocol agnostic ones. (Worker and serve protocol have the same logic
for these container types.) This means by doing this general template
cleanup, we are also getting a head start on better indicating which
code is protocol-specific and which code is shared between protocols.
@github-actions github-actions bot added new-cli Relating to the "nix" command store Issues and pull requests concerning the Nix store labels Jun 19, 2023
Ericson2314 and others added 3 commits June 19, 2023 12:08
See API docs on that struct for why. The pasing as as template argument
doesn't yet happen in that commit, but will instead happen in later
commit.

Also make `WorkerOp` (now `Op`) and enum struct. This led us to catch
that two operations were not handled!

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
The motivation is exactly the same as for the last commit. In addition,
this anticipates us formally defining separate serialisers for the serve
protocol.
Pass this around instead of `Source &` and `Sink &` directly. This will
give us something to put the protocol version on once the time comes.

To do this ergonomically, we need to expose `RemoteStore::Connection`,
so do that too. Give it some more API docs while we are at it.
Copy link
Member Author

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

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

Noted items from #6223 now fixed here

/**
* Convenience for debugging.
*
* @todo Perhaps render known opcodes more nicely.
Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed spelling

* Convenience for debugging.
*
* We specialize the struct merely to indicate that we are implementing
* @todo Perhaps render known opcodes more nicely.
Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed spelling

Comment on lines +82 to +97
// This is the definition of `Serialise` we *want* to put here, but
// do not do so.
//
// The problem is that if we do so, C++ will think we have
// seralisers for *all* types. We don't, of course, but that won't
// cause an error until link time. That makes for long debug cycles
// when there is a missing serialiser.
//
// By not defining it globally, and instead letting individual
// serialisers specialise the type, we get back the compile-time
// errors we would like. When no serialiser exists, C++ sees an
// abstract "incomplete" type with no definition, and any attempt to
// use `to` or `from` static methods is a compile-time error because
// they don't exist on an incomplete type.
//
// This makes for a quicker debug cycle, as desired.
Copy link
Member Author

Choose a reason for hiding this comment

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

Longer comment explaining what is going on.

These were never needed for this file, and date back to before this was
split from `derivation-goal.cc`.
Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

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

As discussed earlier today.

@roberth roberth enabled auto-merge June 19, 2023 16:53
@roberth roberth merged commit 3ee8630 into NixOS:master Jun 19, 2023
@Ericson2314 Ericson2314 deleted the proto-cleanup-prep branch June 20, 2023 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-cli Relating to the "nix" command store Issues and pull requests concerning the Nix store

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants