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

Use gRPC to communicate data from app host to dashboard #1476

Merged
merged 57 commits into from
Jan 5, 2024

Conversation

drewnoakes
Copy link
Member

@drewnoakes drewnoakes commented Dec 21, 2023

Includes PR #1415, with feedback from that PR addressed here.

This is another step towards #1003. Ultimately the dashboard will run in a separate process to the app host. That will require a network connection between the processes for data.

This PR splits the front and back end to use separate types, with a gRPC channel between them.

The .proto defined in #1274 is used here, with some modifications following the integration.

Contributes to #436.

Microsoft Reviewers: Open in CodeFlow

The UI will have a single object type for all resources, treating the uniformly. That object has both a fixed set of fields, and now its own extensible metadata.

In the protocol between ResourceService and Dashboard, we'll need an extensible way to model these resource data. This allows the UI to work with resource types it hasn't seen before.
We are moving towards removing `Aspire.Hosting`'s reference to `Aspire.Dashboard`. In this new model we will have different types on the back end and front end.

- DCP has its own types (e.g. `CustomResource`), which remain untouched, and exist only on the back end.
- `ResourceSnapshot` is a new abstract base class for `ContainerSnapshot`, `ExecutableSnapshot` and `ProjectSnapshot`. These are immutable, have no view-specific data, and will only be used on the back end. In the near future, these objects will be used to populate gRPC messages.
- `ResourceViewModel` remains, though only on the front end. It no longer has subclasses. We are designing the dashboard to support arbitrary resource types. In the near future, these objects will be constructed and updated in response to gRPC messages.

As the front end no longer has subclasses of `ResourceViewModel`, some of the hard-coded resource-specific logic has been changed to work on the additional data within a resource.

We also introduce a `KnownResourceTypes` static class with consts for known resource type names (e.g. "Container").
Uses the gRPC `.proto` file added in a previous commit (with some small changes) to model data sent between the back end (app host) and front end (dashboard). Currently this occurs within the same process, but future work will split the dashboard out of the app host.

- Object flow is now "DCP -> snapshots -> gRPC messages -> view models".
- Move `DashboardWebApplication` initialization out of `DcpHostService` and into the new `DashboardWebApplicationHost` in preparation for future split.
- Split `ResourceSubscription`/`ResourceChange`/`ResourceChangeType` into both snapshot and view model versions, for use on back/front ends respectively.
This was missed in a previous commit where we renamed ResourceDataKeys to KnownProperties.
We don't use this consistently throughout. Plenty of places still require a unique resource name as a key. If we want to change this later, we should do it wholesale across the system in future work.
@drewnoakes
Copy link
Member Author

@JamesNK PTAL

@JamesNK
Copy link
Member

JamesNK commented Jan 4, 2024

I got your branch and ran the app. Projects aren't displaying a PID or project file on resources page:

image

This prevents corruption from concurrent updates of a non-concurrent dictionary.
Copy link
Member

@karolz-ms karolz-ms left a comment

Choose a reason for hiding this comment

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

Overall LGTM, just a couple questions

@kvenkatrajan kvenkatrajan self-requested a review January 5, 2024 01:19
Copy link
Member

@kvenkatrajan kvenkatrajan left a comment

Choose a reason for hiding this comment

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

approved

@drewnoakes
Copy link
Member Author

Projects aren't displaying a PID or project file on resources page

Fixed:

image

Copy link
Member

@JamesNK JamesNK left a comment

Choose a reason for hiding this comment

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

Some improvements are available to make in comments, but they can be done later. LGTM

@drewnoakes drewnoakes merged commit 40ebf07 into dotnet:main Jan 5, 2024
8 checks passed
@drewnoakes drewnoakes deleted the add-grpc branch January 5, 2024 04:29
@davidfowl
Copy link
Member

Excellent work everyone!

drewnoakes added a commit to drewnoakes/aspire that referenced this pull request Jan 5, 2024
Follows comments on dotnet#1476. Uses a component for the application name, which might not be available during the first render, and may require an additional render once the client has connected to the server and retrieved the name.
drewnoakes added a commit that referenced this pull request Jan 8, 2024
* Use component for application name

Follows comments on #1476. Uses a component for the application name, which might not be available during the first render, and may require an additional render once the client has connected to the server and retrieved the name.

* Use OnInitializedAsync

* Prefix field name with underscore

* Cancel wait on connection if component disposed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants