Skip to content

Sled agent views/params shuffling #386

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

Merged
merged 12 commits into from
Nov 18, 2021
Merged

Conversation

david-crespo
Copy link
Contributor

@david-crespo david-crespo commented Nov 12, 2021

DiskEnsureBody is a request body expected by a sled agent endpoint, so it should live in sled agent. When Nexus wants to talk about these types, it should refer to the generated client.

Doing this as its own PR because it would be incredibly confusing in combination with the other one.

To me this simplifies things a lot and is a good example of the kind of complication we currently have that makes things hard to reason about.

}
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ahl because nexus refers to the generated type all the time, there is no more conversion

Copy link
Contributor

Choose a reason for hiding this comment

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

awesome

@david-crespo david-crespo force-pushed the complicated-internal-params branch from b5abcbe to 469d6c6 Compare November 15, 2021 05:01
Copy link
Contributor

@ahl ahl left a comment

Choose a reason for hiding this comment

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

Other than that distinction between "views" and "params" which I'm not so sure about, this looks great!

}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

awesome

@@ -1,15 +1,8 @@
//! APIs exposed by the bootstrap agent
//! Response types for the bootstrap agent
Copy link
Contributor

Choose a reason for hiding this comment

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

Why pull apart inputs and outputs?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Related: I asked this on chat, but I'll ask it more publicly -

Are "views" supposed to be 1:1 with response types, or with DB representations?
This PR implies the former ("response types") but #374 implies the latter ("Views are public lenses onto the DB models.").

I'm especially curious about responses that do not represent data stored in a DB - does that still make sense to store in "view.rs"? If so, would it be more accurate to call these "requests.rs" and "responses.rs"? And in that case, I think Adam's question still applies - why split 'em?

Copy link
Contributor Author

@david-crespo david-crespo Nov 18, 2021

Choose a reason for hiding this comment

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

You're right to point out the disparity — I'll update #374 to say they're response bodies, most of which are lenses onto DB models.

I'm really just following a convention set by the big fullstack frameworks in various languages — Rails, Django, Phoenix, Laravel — which all call response bodies "views", though usually those are HTML responses. In Rails they call the JSON serializers "serializers". I guess they call them serializers in Django too. They distinguish views and serializers from controllers (route handlers) and models.

They're not as consistent about what they call request bodies, probably because in the dynamic languages the request bodies don't have to be defined anywhere outside of the request handler.

requests.rs and responses.rs would be fine names, though they may obscure that we're talking about the bodies in both cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to merge as-is because we can rearrange easily later. The hard part, as you'll see, is moving things out of common. Moving things around within sled-agent or within nexus is easy.

Base automatically changed from views-and-params to main November 18, 2021 04:18
@david-crespo david-crespo merged commit 91c5b7f into main Nov 18, 2021
@david-crespo david-crespo deleted the complicated-internal-params branch November 18, 2021 05:04
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.

3 participants