Skip to content

Commit

Permalink
Upgrade to Aspire Preview 5 (#41)
Browse files Browse the repository at this point in the history
* Warning ASPIRE002: AppHost is an Aspire AppHost project but necessary dependencies aren't present. Are you missing an Aspire.Hosting PackageReference?

* Update to preview 5
  • Loading branch information
ElanHasson committed Apr 16, 2024
1 parent 0f62425 commit c06b999
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 32 deletions.
4 changes: 2 additions & 2 deletions sample/Api/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:53494",
"applicationUrl": "https://localhost:53494",
"sslPort": 44374
}
},
Expand All @@ -14,7 +14,7 @@
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "say-hello",
"applicationUrl": "http://localhost:5195",
"applicationUrl": "https://localhost:5195",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
Expand Down
2 changes: 1 addition & 1 deletion sample/AppHost/AppHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting" Version="8.0.0-preview.5.24201.12" />
<PackageReference Include="Aspire.Hosting.AppHost" Version="8.0.0-preview.5.24201.12" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions sample/AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Aspire.Hosting;

using InfinityFlow.Aspire.Temporal;

var builder = DistributedApplication.CreateBuilder(args);
Expand Down
8 changes: 5 additions & 3 deletions sample/AppHost/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15264",
"applicationUrl": "https://localhost:15264",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16224"
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:16224",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:17037",
"DOTNET_ASPIRE_SHOW_DASHBOARD_RESOURCES": "true"
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions sample/ServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu
http.AddStandardResilienceHandler();
// Turn on service discovery by default
http.UseServiceDiscovery();
http.AddServiceDiscovery();
});

return builder;
Expand All @@ -43,12 +43,9 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati
});

builder.Services.AddOpenTelemetry()
.WithMetrics(metrics =>
{
metrics.AddRuntimeInstrumentation()
.WithMetrics(metrics => metrics.AddRuntimeInstrumentation()
.AddBuiltInMeters()
.AddMeter("Temporal.Client");
})
.AddMeter("Temporal.Client"))
.WithTracing(tracing =>
{
if (builder.Environment.IsDevelopment())
Expand Down
2 changes: 1 addition & 1 deletion sample/ServiceDefaults/ServiceDefaults.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.8.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.8.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.7.0-beta.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.8.0-beta.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.8.0" />
<PackageReference Include="Temporalio.Extensions.DiagnosticSource" Version="1.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="Aspire.Hosting" Version="8.0.0-preview.5.24201.12" />
<PackageReference Include="Aspire.Hosting.AppHost" Version="8.0.0-preview.5.24201.12" />
<PackageReference Include="Docker.DotNet" Version="3.125.15" />
<PackageReference Include="Testcontainers" Version="3.8.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using DotNet.Testcontainers.Builders;

using Aspire.Hosting.ApplicationModel;
using DotNet.Testcontainers.Builders;
using InfinityFlow.Aspire.Temporal;

namespace Aspire.Hosting;
Expand Down Expand Up @@ -78,21 +78,21 @@ private static async Task<IResourceBuilder<TemporalServerContainerResource>> Add
var resourceBuilder = builder.AddResource(container)
.WithAnnotation(new ContainerImageAnnotation() { Image = "aspire-temporal-server-helper", Tag = "latest" })
.WithArgs(args.GetArgs())
.WithHttpEndpoint(name: "server", hostPort: args.Port, containerPort: 7233).AsHttp2Service(); // Internal port is always 7233
.WithHttpsEndpoint(name: "server", targetPort: args.Port, port: 7233).AsHttp2Service(); // Internal port is always 7233

if (args.Headless is not true)
{
resourceBuilder.WithHttpEndpoint(name: "ui", hostPort: args.UiPort, containerPort: 8233); // Internal port is always 8233
resourceBuilder.WithHttpEndpoint(name: "ui", targetPort: args.UiPort, port: 8233); // Internal port is always 8233
}

if (args.MetricsPort is not null)
{
resourceBuilder.WithHttpEndpoint(name: "metrics", hostPort: args.MetricsPort, containerPort: 7235); // Internal port is always 7235
resourceBuilder.WithHttpEndpoint(name: "metrics", targetPort: args.MetricsPort, port: 7235); // Internal port is always 7235
}

if (args.HttpPort is not null)
{
resourceBuilder.WithHttpEndpoint(name: "http", hostPort: args.HttpPort, containerPort: 7234); // Internal port is always 7234
resourceBuilder.WithHttpEndpoint(name: "http", targetPort: args.HttpPort, port: 7234); // Internal port is always 7234
}

return resourceBuilder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using InfinityFlow.Aspire.Temporal;
using Aspire.Hosting.ApplicationModel;

using InfinityFlow.Aspire.Temporal;

namespace Aspire.Hosting;
public static class TemporalServerExecutableBuilderExtensions
Expand Down Expand Up @@ -36,21 +38,21 @@ public static IResourceBuilder<TemporalServerExecutableResource> AddTemporalServ
{
var resourceBuilder = builder.AddResource(new TemporalServerExecutableResource(name, args));

resourceBuilder.WithHttpEndpoint(hostPort: args.Port, name: "server").AsHttp2Service();
resourceBuilder.WithHttpEndpoint(port: args.Port, name: "server").AsHttp2Service();

if (args.Headless is not true)
{
resourceBuilder.WithHttpEndpoint(hostPort: args.UiPort ?? args.Port + 1000, name: "ui");
resourceBuilder.WithHttpEndpoint(port: args.UiPort ?? args.Port + 1000, name: "ui");
}

if (args.MetricsPort is not null)
{
resourceBuilder.WithHttpEndpoint(hostPort: args.MetricsPort?? 9000, name: "metrics");
resourceBuilder.WithHttpEndpoint(port: args.MetricsPort?? 9000, name: "metrics");
}

if (args.HttpPort is not null)
{
resourceBuilder.WithHttpEndpoint(hostPort: args.HttpPort ?? 8080, name: "http");
resourceBuilder.WithHttpEndpoint(port: args.HttpPort ?? 8080, name: "http");
}

return resourceBuilder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
using InfinityFlow.Aspire.Temporal;
using Aspire.Hosting.ApplicationModel;


namespace Aspire.Hosting;

public class TemporalServerExecutableResource(string name, TemporalServerResourceArguments arguments) : ExecutableResource(name, command: "temporal", workingDirectory: "", args: arguments.GetArgs()), IResourceWithConnectionString
public class TemporalServerExecutableResource(string name, TemporalServerResourceArguments arguments) : ExecutableResource(name, command: "temporal", workingDirectory: ""), IResourceWithConnectionString

Check warning on line 7 in src/InfinityFlow.Aspire.Temporal/TemporalServerExecutableResource.cs

View workflow job for this annotation

GitHub Actions / build

Parameter 'arguments' is unread.

Check warning on line 7 in src/InfinityFlow.Aspire.Temporal/TemporalServerExecutableResource.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Parameter 'arguments' is unread.
{
public ReferenceExpression ConnectionStringExpression => ReferenceExpression.Create($"{GetConnectionString()}");

public string? GetConnectionString()
{
if (!this.TryGetAllocatedEndPoints(out var endpoints))
var endpoints = this.GetEndpoints().Where(e => e.IsAllocated).ToList();
if (endpoints.Count==0)
{
throw new DistributedApplicationException("Expected allocated endpoints!");
}

var server = endpoints.Single(x => x.Name == "server");
var server = endpoints.SingleOrDefault(x => x.EndpointName == "server");

return server.EndPointString;
return $"{server?.Host}:{server?.Port}";
}
}

public class TemporalServerContainerResource(string name, TemporalServerResourceArguments arguments) : ContainerResource(name,entrypoint: "/temporal"), IResourceWithConnectionString, IResourceWithEnvironment
{
public ReferenceExpression ConnectionStringExpression => ReferenceExpression.Create($"{GetConnectionString()}");

public TemporalServerResourceArguments Arguments { get; } = arguments;

public string? GetConnectionString()
{
if (!this.TryGetAllocatedEndPoints(out var endpoints))
var endpoints = this.GetEndpoints().Where(e => e.IsAllocated).ToList();
if (endpoints.Count == 0)
{
throw new DistributedApplicationException("Expected allocated endpoints!");
}

var server = endpoints.Single(x => x.Name == "server");
var server = endpoints.SingleOrDefault(x => x.EndpointName == "server");

return server.EndPointString;
return $"{server?.Host}:{server?.Port}";
}
}

0 comments on commit c06b999

Please sign in to comment.