InfinityFlow.Aspire.Temporal
0.5.12
dotnet add package InfinityFlow.Aspire.Temporal --version 0.5.12
NuGet\Install-Package InfinityFlow.Aspire.Temporal -Version 0.5.12
<PackageReference Include="InfinityFlow.Aspire.Temporal" Version="0.5.12" />
paket add InfinityFlow.Aspire.Temporal --version 0.5.12
#r "nuget: InfinityFlow.Aspire.Temporal, 0.5.12"
// Install InfinityFlow.Aspire.Temporal as a Cake Addin #addin nuget:?package=InfinityFlow.Aspire.Temporal&version=0.5.12 // Install InfinityFlow.Aspire.Temporal as a Cake Tool #tool nuget:?package=InfinityFlow.Aspire.Temporal&version=0.5.12
InfinityFlow.Aspire.Temporal
Aspire extension to start the temporal cli dev server as an container or executable resource. Note: Only container works as expected. See https://github.com/dotnet/aspire/issues/1637 and https://github.com/temporalio/cli/issues/316
Contents:
Pre-requisites
- Temporal CLI (ensure the binary is in your PATH)
- An Aspire project. See Aspire docs to get started.
Getting Started
1. Install the nuget package
dotnet add package InfinityFlow.Aspire.Temporal
2. Add Temporal dev server to your Aspire AppHost Program.cs
// AppHost/Program.cs
using Aspire.Temporal.Server;
var builder = DistributedApplication.CreateBuilder(args);
// Use the default server options
var temporal = await builder.AddTemporalServerContainer("temporal")
// OR customise server options with builder
// see config section for details
var temporal = await builder.AddTemporalServerContainer("temporal", x => x
.WithLogFormat(LogFormat.Json)
.WithLogLevel(LogLevel.Info)
.WithNamespace("test1", "test2"));
3. Run the Aspire application
You should see Temporal running under the Executables tab.
Temporal will be available on its default ports:
- Server: http://localhost:7233
- UI: http://localhost:8233
4. Configure Client/Worker Applications
The Temporal client can then be added to a .NET project as normal using the instructions from the temporal dotnet sdk repo
It can be included in Aspire orchestration like below and can optionally take a reference to the Temporal resource.
// ./samples/AppHost/Program.cs
// ...
var temporal = builder.AddTemporalServerExecutable("temporal");
builder.AddProject<Projects.Worker>("worker") // my custom project
.WithReference(temporal);
// ...
If using Temporalio.Extensions.Hosting the client registration might look something like below. If we took the reference to the Temporal Aspire resource, then the TargetHost property is automatically injected under the key ConnectionStrings:<Aspire Resource Name>
. (e.g., this will be builder.Configuration["ConnectionStrings:temporal"]
for a resource named "temporal" as above)
// register a client - ./samples/Api/Program.cs
builder.Services
.AddTemporalClient(opts =>
{
opts.TargetHost = builder.Configuration["ConnectionStrings:temporal"]; // or just self-configure localhost:7233
opts.Namespace = "default";
})
// or
// register a worker - ./samples/Worker/Program.cs
builder.Services
.AddTemporalClient(opts =>
{
opts.TargetHost = builder.Configuration["ConnectionStrings:temporal"]; // or just self-configure localhost:7233
opts.Namespace = "default";
})
.AddHostedTemporalWorker("my-task-queue")
.AddScopedActivities<MyActivities>()
.AddWorkflow<MyWorkflow>();
Observability
The extension doesn't provide any setup for observability, but you can follow Temporalio.Extensions.DiagnosticSource and Temporalio.Extensions.Hosting to configure this on the temporal client. If using the Aspire Service Defaults, you'll need to configure the metrics and tracing accordingly.
The sample folder has an example for configuring this with the Aspire Dashboard
- sample/Api/Program.cs for an example client
- sample/Worker/Program.cs for an example worker
- sample/ServiceDefaults/Extensions.cs for an example of adding the custom meter and tracing sources to the service defaults.
If done correctly, you should tracing and metrics on the Aspire dashboard:
Tracing
Metrics
Configuration
The dev server can be configured with a fluent builder
await builder.AddTemporalServerContainer("temporal", builder => builder.WithPort(1234))
You can run temporal server start-dev --help
to get more information about the CLI flags on the dev server. All available flags are mapped to a method on the builder.
Available methods:
builder
.WithDbFileName("/location/of/persistent/file") // --db-filename
.WithNamespace("namespace-name", ...) // --namespace
.WithPort(7233) // --port
.WithHttpPort(7234) // --http-port
.WithMetricsPort(7235) // --metrics-port
.UiPort(8233) // --ui-port
.WithHeadlessUi(true) // --headless
.WithIp("127.0.0.1") // --ip
.WithUiIp("127.0.0.1") // --ui-ip
.WithUiAssetPath("/location/of/custom/assets") // --ui-asset-path
.WithUiCodecEndpoint("http://localhost:8080") // --ui-codec-endpoint
.WithLogFormat(LogFormat.Pretty) // --log-format
.WithLogLevel(LogLevel.Info) // --log-level
.WithSQLitePragma(SQLitePragma.JournalMode) // --sqlite-pragma
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Aspire.Hosting.AppHost (>= 8.2.1)
- Docker.DotNet (>= 3.125.15)
- Testcontainers (>= 3.10.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.5.12 | 2,132 | 10/8/2024 |
0.5.11 | 7,134 | 9/4/2024 |
0.5.10 | 128 | 8/28/2024 |
0.5.9 | 341 | 8/10/2024 |
0.5.8 | 667 | 5/22/2024 |
0.5.7 | 127 | 5/15/2024 |
0.5.6 | 92 | 5/14/2024 |
0.5.5 | 78 | 5/13/2024 |
0.5.4 | 144 | 5/9/2024 |
0.5.3 | 264 | 4/24/2024 |
0.5.2 | 420 | 4/18/2024 |
0.5.1 | 114 | 4/16/2024 |
0.5.0 | 85 | 4/16/2024 |
0.4.2 | 282 | 4/5/2024 |
0.4.1 | 142 | 3/27/2024 |
0.4.0 | 93 | 3/17/2024 |
0.3.0 | 290 | 2/20/2024 |