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

Introduce ResourceCreatingEvent #5359

Merged
merged 7 commits into from
Aug 22, 2024

Conversation

mitchdenny
Copy link
Member

@mitchdenny mitchdenny commented Aug 20, 2024

Description

This PR introduces a new eventing event ResourceCreatingEvent. This work is related to enabling WaitFor` support.

Fixes # (issue)

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?
Microsoft Reviewers: Open in CodeFlow

@mitchdenny mitchdenny requested a review from davidfowl August 20, 2024 07:51
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Aug 20, 2024
@mitchdenny mitchdenny requested a review from eerhardt August 20, 2024 07:51
@mitchdenny mitchdenny self-assigned this Aug 20, 2024
@mitchdenny mitchdenny added this to the 8.2 milestone Aug 20, 2024
@mitchdenny mitchdenny changed the title Introduce ResourceCreatingEvents and ResourceCreatedEvents. Introduce ResourceCreatingEvent Aug 21, 2024
/// Resources that are created by orchestrators may not yet be ready to handle requests.
/// </remarks>
[Experimental("ASPIREEVENTING001", UrlFormat = "https://aka.ms/dotnet/aspire/diagnostics#{0}")]
public class BeforeResourceStartedEvent(IResource resource, IServiceProvider services) : IDistributedApplicationResourceEvent
Copy link
Member

Choose a reason for hiding this comment

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

I think this name still violates the naming guidelines.

https://learn.microsoft.com/en-us/dotnet/standard/design-guidelines/names-of-type-members#names-of-events

✔️ DO give events names with a concept of before and after, using the present and past tenses.

For example, a close event that is raised before a window is closed would be called Closing, and one that is raised after the window is closed would be called Closed.

❌ DO NOT use "Before" or "After" prefixes or postfixes to indicate pre- and post-events. Use present and past tenses as just described.

Suggested change
public class BeforeResourceStartedEvent(IResource resource, IServiceProvider services) : IDistributedApplicationResourceEvent
public class ResourceStartingEvent(IResource resource, IServiceProvider services) : IDistributedApplicationResourceEvent

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree these names aren't 100% right. But we will be doing a follow up.

@@ -217,6 +220,9 @@ private async Task ProvisionAzureResources(

private async Task ProcessResourceAsync(IConfiguration configuration, Lazy<Task<ProvisioningContext>> provisioningContextLazy, IAzureResource resource, CancellationToken cancellationToken)
{
var beforeResourceStartedEvent = new BeforeResourceStartedEvent(resource, serviceProvider);
await eventing.PublishAsync(beforeResourceStartedEvent, cancellationToken).ConfigureAwait(false);
Copy link
Member

Choose a reason for hiding this comment

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

Are there tests that can be written for the Azure provisioning event?

Copy link
Member

Choose a reason for hiding this comment

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

That component isn't currently testable

Copy link
Member

Choose a reason for hiding this comment

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

😢

Copy link
Member

@davidfowl davidfowl left a comment

Choose a reason for hiding this comment

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

@eerhardt we're going to rename in the follow up

@mitchdenny mitchdenny merged commit 16953c4 into main Aug 22, 2024
11 checks passed
@mitchdenny mitchdenny deleted the mitchdenny/resource-creating-created-events branch August 22, 2024 03:53
@github-actions github-actions bot locked and limited conversation to collaborators Sep 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants