-
I'm new to creating custom resources in Aspire. Not even sure whether the below code is correct way of doing it.
public class TemporalExecutableResource(string name, string? executablePath) :
ExecutableResource(name, executablePath ?? "temporal", string.Empty), IResourceWithEndpoints{}
public static class TemporalBuilderExtensions
{
public static IResourceBuilder<TemporalExecutableResource> AddTemporalDevelopmentServer(this IDistributedApplicationBuilder builder, 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: "grpc", name: "server", isProxied: false, isExternal: true)
.WithHttpEndpoint(port: 8233, name: "ui", isProxied: false)
.WithHttpEndpoint(port: 52723, name: "metrics", isProxied: false);
}
} This does not work as it should, but I'll figure out later, my question is more basic: How can I reference these endpoints in the client app? options.ClientOptions = new Temporalio.Client.TemporalClientConnectOptions("HOW TO REFERENCE the SERVER ENDPOINT HERE?")
{
Namespace = "default",
DataConverter = DataConverter.Default with { PayloadConverter = new DefaultPayloadConverter(NetFlowJsonSerializerOptions.Definition) }
}; |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
First, there's a working temporal hosting integration on NuGet: NuGet - https://www.nuget.org/packages/InfinityFlow.Aspire.Temporal
Have you read
Most integrations implement There're extensive comments on what these APIs do and what they inject into the target application: ExecutableResource already implemets IResourceWithEndpoints, so adding it to your resouce implementation is not useful. At a lower level, you can get an endpoint by name by calling GetEndpoint and you can pass it to another resource (this example shows passing it to a project resource): var builder = DistributedApplication.CreateBuilder(args);
var temporal = builder.AddTemporalDevelopmentServer("temporal");
builder.AddProject<Projects.Api>("api")
.WithReference(temporal.GetEndpoint("grpc"));
builder.Build().Run(); This will pass the resolved URL (at the appropriate time) to the target project using the service discovery format described here. OR you can set environment variables directly: var builder = DistributedApplication.CreateBuilder(args);
var temporal = builder.AddTemporalDevelopmentServer("temporal");
builder.AddProject<Projects.Api>("api")
.WithEnvironment("TemporalDevUrl", temporal.GetEndpoint("grpc"));
builder.Build().Run(); |
Beta Was this translation helpful? Give feedback.
First, there's a working temporal hosting integration on NuGet:
NuGet - https://www.nuget.org/packages/InfinityFlow.Aspire.Temporal
Github - https://github.com/InfinityFlowApp/aspire-temporal
Have you read
Most integrations implement
IResourceWithConnectionString
and create a connection string expression that will get passed t…