Skip to content

Commit

Permalink
Updated syntax, package version, and error handling in Temporal Server (
Browse files Browse the repository at this point in the history
#46)

* Updated the syntax for adding an interceptor in `Program.cs` and for retrieving the "temporal" connection string. 
* Swapped the order of `port` and `targetPort` parameters in `TemporalServerContainerBuilderExtensions.cs` for improved readability. 
* Changed the behavior in `TemporalServerExecutableResource.cs` and `TemporalServerContainerResource.cs` to return `null` instead of throwing an exception when no endpoints are allocated.
* Upgraded `InfinityFlow.Aspire.Temporal` package version from `0.4.3` to `0.5.1`.
  • Loading branch information
ElanHasson committed Apr 16, 2024
1 parent cc3b159 commit 3910c9d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion sample/Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{
opts.TargetHost = builder.Configuration["ConnectionStrings:temporal"];
opts.Namespace = Constants.Namespace;
opts.Interceptors = new[] { new TracingInterceptor() };
opts.Interceptors = [new TracingInterceptor()];
opts.Runtime = runtime;
});

Expand Down
2 changes: 1 addition & 1 deletion sample/Worker/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
builder.Services
.AddTemporalClient(opts =>
{
opts.TargetHost = builder.Configuration["ConnectionStrings:temporal"];
opts.TargetHost = builder.Configuration.GetConnectionString("temporal");
opts.Namespace = Constants.Namespace;
opts.Interceptors = new[] { new TracingInterceptor() };
opts.Runtime = runtime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<IsPackable>true</IsPackable>
<EnablePackageValidation>true</EnablePackageValidation>
<PackageId>InfinityFlow.Aspire.Temporal</PackageId>
<PackageVersion>0.5.0</PackageVersion>
<PackageVersion>0.5.1</PackageVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
Expand Down
Original file line number Diff line number Diff line change
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())
.WithHttpsEndpoint(name: "server", targetPort: args.Port, port: 7233).AsHttp2Service(); // Internal port is always 7233
.WithHttpsEndpoint(name: "server", port: args.Port, targetPort: 7233).AsHttp2Service(); // Internal port is always 7233

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

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

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

return resourceBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class TemporalServerExecutableResource(string name, TemporalServerResourc
var endpoints = this.GetEndpoints().Where(e => e.IsAllocated).ToList();
if (endpoints.Count==0)
{
throw new DistributedApplicationException("Expected allocated endpoints!");
return null;
}

var server = endpoints.SingleOrDefault(x => x.EndpointName == "server");
Expand All @@ -33,7 +33,7 @@ public class TemporalServerContainerResource(string name, TemporalServerResource
var endpoints = this.GetEndpoints().Where(e => e.IsAllocated).ToList();
if (endpoints.Count == 0)
{
throw new DistributedApplicationException("Expected allocated endpoints!");
return null;
}

var server = endpoints.SingleOrDefault(x => x.EndpointName == "server");
Expand Down

0 comments on commit 3910c9d

Please sign in to comment.