-
Notifications
You must be signed in to change notification settings - Fork 147
feat(dapr): add IValueProvider support for component metadata configuration #810
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
feat(dapr): add IValueProvider support for component metadata configuration #810
Conversation
Implements IResourceWithWaitSupport for IDaprSidecarResource to enable proper service startup sequencing. This allows Dapr sidecars to wait for dependent services (like Redis for pubsub) to be ready before starting, preventing component loading failures during application startup. Fixes CommunityToolkit#604 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Added new WithMetadata overload that accepts EndpointReference parameter - Extracts URL from EndpointReference for metadata configuration - Added comprehensive tests for the new functionality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
…tern - Removed placeholder values from DaprDistributedApplicationLifecycleHook - Replaced with cleaner hasValueProviders flag for tracking value providers - Consolidated tests from EndpointReferenceTests into ResourceBuilderExtensionsTests - Deleted redundant EndpointReferenceTests.cs file - All tests pass with cleaner separation of concerns 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
| /// Represents a Dapr sidecar resource. | ||
| /// </summary> | ||
| public interface IDaprSidecarResource : IResource | ||
| public interface IDaprSidecarResource : IResource, IResourceWithWaitSupport |
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.
Did you implement the waiting? To make this work, the resource needs a lifecycle, see https://github.com/dotnet/aspire/blob/main/docs/specs/appmodel.md#built-in-resources--lifecycle.
When you implement IResourceWithWaitSupport, at some point you have to raise https://github.com/dotnet/aspire/blob/364382724b4cd3590ec75010525ce36ef0b5e769/src/Aspire.Hosting/ConnectionStringBuilderExtensions.cs#L92
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.
Implemented it, don't know if it's the correct approach but I followed the examples. Also implemented on the IDaprComponentResource as it seems it was missing support
…ation - Add comprehensive XML documentation for WithMetadata method explaining runtime value resolution - Implement DaprSidecarAvailableEvent for sidecar lifecycle tracking - Add automatic dependency detection and wait logic for value provider resources - Ensure sidecars wait for dependent resources before starting - Add proper state management for sidecar resources (NotStarted -> Starting -> Running) - Improve error handling with FailedToStart state on initialization errors This improves reliability when using dynamic endpoint references and ensures proper initialization order. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
…ifecycle - Add SetupComponentLifecycle method to configure WaitAnnotations for Dapr components - Extract resource dependencies from value provider annotations - Ensure components wait for their dependencies before becoming ready - Follow the same pattern as SetupSidecarLifecycle for consistency This ensures proper dependency ordering when Dapr components reference other resources through value providers, preventing initialization failures. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
…e parent resource
|
@gabynevada just checking the state of the PR - are you wanting this re-reviewed? is it ready to merge? |
…ations Instead of passing WaitAnnotations from components to the Dapr CLI, components now: - Manage their own lifecycle state (NotStarted -> Starting -> Running) - Wait directly for their dependencies via WaitAnnotations - CLI resources wait for component resources to be ready This provides clearer dependency semantics where resources wait for configuration resources, which in turn wait for their actual dependencies. The refactoring follows the established SetupSidecarLifecycle pattern for consistency. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Components are long-lived configuration resources that should reach "Running" state and stay there. Using WaitForCompletion was incorrect as it expected components to reach "Completed" state. Now using WaitType.WaitUntilHealthy which properly waits for resources to be in a healthy/running state, matching the component lifecycle. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
|
@FullStackChef was occupied on work so could not do the final changes. Pushed the final changes so that the dapr component resources have a lifecycle and thus other resources can wait for them to get to the running state. Let me know if anything needs to be changed! |
Summary
IValueProvider(includingEndpointReference) in Dapr component metadata configurationChanges
WithMetadataoverload acceptingIValueProviderfor flexible metadata configurationDaprComponentValueProviderAnnotationto track value providers requiring resolutionDaprComponentSchemawith async value resolution capabilitiesTest Plan
Example Usage
This allows Dapr components to dynamically reference Aspire resource endpoints that are only known at runtime.
Closes #604