Closed mitchdenny closed 1 month ago
This would be a DCP change no?
Probably in the CAB-DCP bridge code in the Aspire repo. The way things are implemented right now we call CreateAsync for container/executable services in the bridge code so in theory that is where we would need to honor the dependencies.
We could probably short circuit it a bit by doing a topological sort on the graph of components before giving it to DCP so that that assuming it executes in sorted order it is fine. A DependsOnAnnotation
would just be used to define the edges of the graph.
What I don't quite know how we would handle is how to pick out those edges automatically from a WithEnvironment(...)
call where we are just capturing dependencies from the Program.cs
scope.
I think we should let dcp to the topo sort instead of trying to hack this into the client.
Sure. So, we still have the same problem though. We need to collect those dependencies for DCP since by the time we get to it all that context is lost (in DCP proper they just have a bunch of service bindings and environment variables).
It's not the same problem as in, we don't have to toposort, we just the ability to declare dependencies.
This will come in handy for things as simple as drawing a diagram of dependencies in the dashboard so we should add it.
Is there any plan to add this?
I want to migrate the database when the application starts but because the database is not already up, the application start failed.
see this.
Here I just created a delay for a temporary fix.
A lot of scenarios need this feature to work.
@Alirexaa we are working on this. In Aspire 8.1 we are adding a WaitForResourceAsync(...)
extension for use in testing scenarios which is very similar to what we need here. We just need to figure out how we want this API to work outside of test scenarios.
It's in our list of day-0 issues that we want to fix :)
@mitchdenny Can we expect it in a prerelease package any time soon?
If my DB is not up and running, the application does not crash (as it should), but a background process keeps failing in a loop. This is a third-party component I have no control over, so this WaitForResourceAsync seems exactly what I need..
This didn't make the cut for 8.1 I'm afraid. It is still high on the priority list and will be considered for 8.2
I'm using the sample code by @davidfowl for now, which worked like a breeze btw 🥇
Closing this in favor of: https://github.com/dotnet/aspire/issues/5275
We should expose a way to express dependencies between resources. This won't have any immediate impact on startup order but will come in handy for other things (diagrams and the manifest).
Original
Do we need to implement depends on like relationships between components. Right now, we've just added
AddExecutable(...)
to support things like running arbitrary executables as part of bringing up the dev host. But it has been pointed out that for things like migrations we might want to hold starting a project until the executable finishes running (kind of like an init container).For other dependencies (between projects) we might want to express startup dependencies, but because they are long running we would probably need to introduce the concept of health probes.