InfinityFlow.Aspire.Temporal 0.5.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package InfinityFlow.Aspire.Temporal --version 0.5.5                
NuGet\Install-Package InfinityFlow.Aspire.Temporal -Version 0.5.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="InfinityFlow.Aspire.Temporal" Version="0.5.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add InfinityFlow.Aspire.Temporal --version 0.5.5                
#r "nuget: InfinityFlow.Aspire.Temporal, 0.5.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install InfinityFlow.Aspire.Temporal as a Cake Addin
#addin nuget:?package=InfinityFlow.Aspire.Temporal&version=0.5.5

// Install InfinityFlow.Aspire.Temporal as a Cake Tool
#tool nuget:?package=InfinityFlow.Aspire.Temporal&version=0.5.5                

InfinityFlow.Aspire.Temporal

NuGet

Discord

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

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

Aspire dashboard temporal exe

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

If done correctly, you should tracing and metrics on the Aspire dashboard:

Tracing

aspire dashboard temporal tracing

Metrics

aspire dashboard temporal 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 1,411 10/8/2024
0.5.11 7,093 9/4/2024
0.5.10 125 8/28/2024
0.5.9 338 8/10/2024
0.5.8 664 5/22/2024
0.5.7 124 5/15/2024
0.5.6 89 5/14/2024
0.5.5 75 5/13/2024
0.5.4 141 5/9/2024
0.5.3 261 4/24/2024
0.5.2 417 4/18/2024
0.5.1 111 4/16/2024
0.5.0 82 4/16/2024
0.4.2 279 4/5/2024
0.4.1 139 3/27/2024
0.4.0 90 3/17/2024
0.3.0 287 2/20/2024