-
When setting up Temporalio as a aspire resource, I want to get the endpoint. Turns out temporalio main endpoint on port This is not supported by Aspire. /// <summary>
/// Provides extension methods for adding the Temporal executable resource to the application model.
/// </summary>
public static class TemporalBuilderExtensions
{
/// <summary>
/// Adds a Temporal executable resource to the application model.
/// </summary>
/// <param name="builder">The <see cref="IDistributedApplicationBuilder"/>.</param>
/// <param name="name">The name of the resource. This name will be used as the connection string name when referenced in a dependency.</param>
/// <param name="executablePath"></param>
/// <param name="args"></param>
public static IResourceBuilder<TemporalExecutableResource> AddTemporalDevelopmentServer(this IDistributedApplicationBuilder builder,
[ResourceName] string name, string? executablePath = null, string[]? args = null)
{
args = args ?? [];
string[] allArgs = args is { Length: > 0 }
? ["server", "start-dev", .. args]
: ["server", "start-dev"];
var temporal = new TemporalExecutableResource(name, executablePath);
return builder.AddResource(temporal)
.WithArgs(allArgs)
.WithEndpoint(port: 7233, scheme: string.Empty, name: TemporalExecutableResource.ServerEndpointName, isProxied: false)
.WithHttpEndpoint(port: 8233, name: "ui", isProxied: false)
.WithHttpEndpoint(port: 52723, name: "metrics", isProxied: false);
}
} I added var temporal = builder.AddTemporalDevelopmentServer("temporal");
var api = builder.AddProject<Projects.Torch_Api>("api")
.WithEnvironment("Temporal:Endpoint", temporal.GetEndpoint(TemporalExecutableResource.ServerEndpointName)) Am I doing something wrong? Or does Aspire need to support such scenario? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The scheme for grpc is http. Use var temporal = builder.AddTemporalDevelopmentServer("temporal");
var endpoint = temporal.GetEndpoint(TemporalExecutableResource.ServerEndpointName);
var hostAndPort = ReferenceExpression.Create($"{endpoint.Property(EndpointProperty.Host)}:{endpoint.Property(EndpointProperty.Port)}");
var api = builder.AddProject<Projects.Torch_Api>("api")
.WithEnvironment("Temporal:Endpoint", hostAndPort); In 9.2 there's HostAndPort enum value. |
Beta Was this translation helpful? Give feedback.
WithReference()
is highly opinionated in how it injects values - if those opinions don't work for you, you can inject your own environment variables. In your case you don't need to implementIResourceWithConnectionString
and can wire up the endpoint by itself: