-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Update to Aspire 13 #916
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
Update to Aspire 13 #916
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,5 @@ | ||
| using eShop.EventBusRabbitMQ; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Microsoft.Extensions.Configuration; | ||
| using System.Diagnostics.CodeAnalysis; | ||
|
|
||
| namespace Microsoft.Extensions.Hosting; | ||
|
|
||
|
|
@@ -16,18 +14,11 @@ public static class RabbitMqDependencyInjectionExtensions | |
|
|
||
| private const string SectionName = "EventBus"; | ||
|
|
||
| [UnconditionalSuppressMessage("Trimming", "IL2026:RequiresUnreferencedCode", | ||
| Justification = "EventBusOptions is a simple POCO with public properties that are safe for trimming.")] | ||
| [UnconditionalSuppressMessage("AOT", "IL3050:RequiresDynamicCode", | ||
| Justification = "EventBusOptions is a simple POCO with public properties that are safe for AOT.")] | ||
| public static IEventBusBuilder AddRabbitMqEventBus(this IHostApplicationBuilder builder, string connectionName) | ||
| { | ||
| ArgumentNullException.ThrowIfNull(builder); | ||
|
|
||
| builder.AddRabbitMQClient(connectionName, configureConnectionFactory: factory => | ||
| { | ||
| ((ConnectionFactory)factory).DispatchConsumersAsync = true; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RabbitMQ v7 is all async now, so this property no longer exists. |
||
| }); | ||
| builder.AddRabbitMQClient(connectionName); | ||
|
|
||
| // RabbitMQ.Client doesn't have built-in support for OpenTelemetry, so we need to add it ourselves | ||
| builder.Services.AddOpenTelemetry() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| using Aspire.Hosting.Lifecycle; | ||
| using Aspire.Hosting.Eventing; | ||
| using Aspire.Hosting.Lifecycle; | ||
| using Aspire.Hosting.Yarp; | ||
| using Aspire.Hosting.Yarp.Transforms; | ||
| using Yarp.ReverseProxy.Configuration; | ||
|
|
@@ -20,21 +21,26 @@ internal static class Extensions | |
| /// </summary> | ||
| public static IDistributedApplicationBuilder AddForwardedHeaders(this IDistributedApplicationBuilder builder) | ||
| { | ||
| builder.Services.TryAddLifecycleHook<AddForwardHeadersHook>(); | ||
| builder.Services.TryAddEventingSubscriber<AddForwardHeadersSubscriber>(); | ||
| return builder; | ||
| } | ||
|
|
||
| private class AddForwardHeadersHook : IDistributedApplicationLifecycleHook | ||
| private class AddForwardHeadersSubscriber : IDistributedApplicationEventingSubscriber | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if we need this anymore.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like you added it in e77b039. I'm not sure what this does TBH. |
||
| { | ||
| public Task BeforeStartAsync(DistributedApplicationModel appModel, CancellationToken cancellationToken = default) | ||
| public Task SubscribeAsync(IDistributedApplicationEventing eventing, DistributedApplicationExecutionContext executionContext, CancellationToken cancellationToken) | ||
| { | ||
| foreach (var p in appModel.GetProjectResources()) | ||
| eventing.Subscribe<BeforeStartEvent>((@event, ct) => | ||
| { | ||
| p.Annotations.Add(new EnvironmentCallbackAnnotation(context => | ||
| foreach (var p in @event.Model.GetProjectResources()) | ||
| { | ||
| context.EnvironmentVariables["ASPNETCORE_FORWARDEDHEADERS_ENABLED"] = "true"; | ||
| })); | ||
| } | ||
| p.Annotations.Add(new EnvironmentCallbackAnnotation(context => | ||
| { | ||
| context.EnvironmentVariables["ASPNETCORE_FORWARDEDHEADERS_ENABLED"] = "true"; | ||
| })); | ||
| } | ||
|
|
||
| return Task.CompletedTask; | ||
| }); | ||
|
|
||
| return Task.CompletedTask; | ||
| } | ||
|
|
||
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 no longer needed now that we are on RabbitMQ.Client v7