-
Notifications
You must be signed in to change notification settings - Fork 418
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
Add WithPgWeb
#5098
Merged
Merged
Add WithPgWeb
#5098
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
71a52a1
Add `WithPgWeb`
Alirexaa 4af040b
Minor changes, still not working
Alirexaa f66c597
Merge branch 'main' into WithPgweb
Alirexaa 4fbf82c
fix build
Alirexaa f86de7f
Merge branch 'WithPgweb' of https://github.com/Alirexaa/aspire into W…
Alirexaa 0bbc106
fix connection error in pgweb
Alirexaa 105e258
Merge branch 'main' into WithPgweb
Alirexaa b7849b3
add unit tests
Alirexaa 3f32a8b
add more unit test
Alirexaa 149f1d4
Add functional test
Alirexaa ecec448
minor change
Alirexaa 1d8bc29
try fix WithPgwebProducesValidBookmarkFiles test
Alirexaa c1cd930
Merge branch 'dotnet:main' into WithPgweb
Alirexaa 5fd5e2f
Address PR feedback
Alirexaa d17220a
Merge branch 'dotnet:main' into WithPgweb
Alirexaa 5c51e3c
Merge branch 'main' into WithPgweb
Alirexaa f55e6d9
Address PR feedback
Alirexaa f82446f
fix build
Alirexaa 84e63fd
disable test
Alirexaa c1cfecc
Merge branch 'dotnet:main' into WithPgweb
Alirexaa bb5ca32
PR feedback
eerhardt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,3 +62,4 @@ upsert | |
uris | ||
urls | ||
kubernetes | ||
Pgweb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Aspire.Hosting.ApplicationModel; | ||
|
||
namespace Aspire.Hosting.Postgres; | ||
|
||
/// <summary> | ||
/// Represents a container resource for pgweb. | ||
/// </summary> | ||
/// <param name="name">The name of the container resource.</param> | ||
public sealed class PgWebContainerResource(string name) : ContainerResource(name) | ||
{ | ||
internal const string PrimaryEndpointName = "http"; | ||
|
||
private EndpointReference? _primaryEndpoint; | ||
|
||
/// <summary> | ||
/// Gets the primary endpoint for the pgweb. | ||
/// </summary> | ||
public EndpointReference PrimaryEndpoint => _primaryEndpoint ??= new(this, PrimaryEndpointName); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
#nullable enable | ||
Aspire.Hosting.Postgres.PgWebContainerResource | ||
Aspire.Hosting.Postgres.PgWebContainerResource.PgWebContainerResource(string! name) -> void | ||
Aspire.Hosting.Postgres.PgWebContainerResource.PrimaryEndpoint.get -> Aspire.Hosting.ApplicationModel.EndpointReference! | ||
static Aspire.Hosting.PostgresBuilderExtensions.WithHostPort(this Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Postgres.PgWebContainerResource!>! builder, int? port) -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Postgres.PgWebContainerResource!>! | ||
static Aspire.Hosting.PostgresBuilderExtensions.WithPgWeb(this Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.PostgresServerResource!>! builder, System.Action<Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Postgres.PgWebContainerResource!>!>? configureContainer = null, string? containerName = null) -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.PostgresServerResource!>! | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this directory get cleaned up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have a hook or event when a resource stopped/finished?
I think we should add one API for that in
IDistributedApplicationLifecycleHook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually a problem right now. @karolz-ms interested in your thoughts here. We sometimes drop temporary files in disk and I'd like to be able to try and ensure that they are cleaned up. We can probably have some kind of temporary file register that goes and does clean up but its highly likely that some of those files/directories are going to be locked because things like containers are spinning down.
This might be one of those things that DCP could help with?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think DCP would be a good place for logic that deals with "cleanup" tasks like removing temporary log files.
There are probably many ways to do this, but the simplest one that will work today, is to put them inside the DCP session folder (which the app host runtime knows about). That folder is automatically deleted when DCP is shutting down. Just make sure the name is reasonably unique when creating the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(we might be missing an API for the extensions that will tell them what the "temporary folder for the current application run" is)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do that too. Feel free to open an issue and we can add it to our backlog for DCP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is our approach for cleanup temp files for this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mitchdenny - would this be a good usage of the new Eventing API? We could have an event that fires when the resource is shut down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we already have the same issue with pgadmin:
aspire/src/Aspire.Hosting.PostgreSQL/PostgresBuilderExtensions.cs
Lines 101 to 111 in 4b4ebce
I'd be fine with continuing here to just create temp files and leave them, for now, until we get the clean up capability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes ... although it wouldn't be 100%. If someone kills the process via the debugger (most common scenario) I don't think we guarantee that this is run. But better than nothing I guess.