Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
PR feedback
  • Loading branch information
davidfowl committed Jul 3, 2025
commit a6d7c4c89e6df7876afffb8eb901bd62a9dfe34e
28 changes: 13 additions & 15 deletions src/Aspire.Hosting/Orchestrator/ParameterProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ internal sealed class ParameterProcessor(
IInteractionService interactionService,
ILogger<ParameterProcessor> logger)
{
private readonly ResourceNotificationService _notificationService = notificationService;
private readonly ResourceLoggerService _loggerService = loggerService;
private readonly List<ParameterResource> _unresolvedParameters = [];

public async Task InitializeParametersAsync(IEnumerable<ParameterResource> parameterResources)
Copy link
Member

Choose a reason for hiding this comment

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

Should this take a cancellation token?

Expand Down Expand Up @@ -51,7 +49,7 @@ public async Task InitializeParametersAsync(IEnumerable<ParameterResource> param
}
catch (Exception ex)
{
logger.LogError(ex, "Failed to handle unresolved parameters");
logger.LogError(ex, "Failed to handle unresolved parameters.");
}
});
}
Expand All @@ -64,7 +62,7 @@ private async Task ProcessParameterAsync(ParameterResource parameterResource)
{
var value = parameterResource.Value ?? "";

await _notificationService.PublishUpdateAsync(parameterResource, s =>
await notificationService.PublishUpdateAsync(parameterResource, s =>
{
return s with
{
Expand All @@ -74,7 +72,7 @@ await _notificationService.PublishUpdateAsync(parameterResource, s =>
})
.ConfigureAwait(false);

parameterResource.WaitForValueTcs?.SetResult(value);
parameterResource.WaitForValueTcs?.TrySetResult(value);
}
catch (Exception ex)
{
Expand All @@ -85,23 +83,23 @@ await _notificationService.PublishUpdateAsync(parameterResource, s =>
// Add the parameter to unresolved parameters list.
_unresolvedParameters.Add(parameterResource);

_loggerService.GetLogger(parameterResource)
loggerService.GetLogger(parameterResource)
.LogWarning(ex, "Parameter resource {ResourceName} could not be initialized. Waiting for user input.", parameterResource.Name);
}
else
{
// If interaction service is not available, we log the error and set the state to error.
parameterResource.WaitForValueTcs?.SetException(ex);
parameterResource.WaitForValueTcs?.TrySetException(ex);

_loggerService.GetLogger(parameterResource)
.LogError(ex, "Failed to initialize parameter resource {ResourceName}", parameterResource.Name);
loggerService.GetLogger(parameterResource)
.LogError(ex, "Failed to initialize parameter resource {ResourceName}.", parameterResource.Name);
}

var stateText = ex is MissingParameterValueException ?
"Value missing" :
"Error initializing parameter";

await _notificationService.PublishUpdateAsync(parameterResource, s =>
await notificationService.PublishUpdateAsync(parameterResource, s =>
{
return s with
{
Expand All @@ -128,12 +126,12 @@ internal async Task HandleUnresolvedParametersAsync(IList<ParameterResource> unr
{
// First we show a notification that there are unresolved parameters.
var result = await interactionService.PromptMessageBarAsync(
"Unresolved Parameters",
"Unresolved parameters",
"There are unresolved parameters that need to be set. Please provide values for them.",
new MessageBarInteractionOptions
{
Intent = MessageIntent.Warning,
PrimaryButtonText = "Enter Values"
PrimaryButtonText = "Enter values"
})
.ConfigureAwait(false);

Expand All @@ -155,9 +153,9 @@ internal async Task HandleUnresolvedParametersAsync(IList<ParameterResource> unr
}

var valuesPrompt = await interactionService.PromptInputsAsync(
"Set Unresolved Parameters",
"Set unresolved parameters",
"Please provide values for the unresolved parameters.",
[.. inputs],
inputs,
new InputsDialogInteractionOptions
{
PrimaryButtonText = "Submit",
Expand All @@ -182,7 +180,7 @@ internal async Task HandleUnresolvedParametersAsync(IList<ParameterResource> unr
parameter.WaitForValueTcs?.TrySetResult(inputValue);

// Update the parameter resource state to active with the provided value.
await _notificationService.PublishUpdateAsync(parameter, s =>
await notificationService.PublishUpdateAsync(parameter, s =>
{
return s with
{
Expand Down
Loading