From 2bd9ed3894adb290f78f4a4409797dc5d4ec82a0 Mon Sep 17 00:00:00 2001 From: Chad Retz Date: Wed, 24 Apr 2024 16:24:43 -0500 Subject: [PATCH] Readme updates (#230) --- README.md | 20 ++++++++++++++++++++ src/Temporalio.Extensions.Hosting/README.md | 7 +++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bee32046..c353d338 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ Extensions: - [Executing a Workflow](#executing-a-workflow) - [Usage](#usage) - [Clients](#clients) + - [Cloud Client Using MTLS](#cloud-client-using-mtls) - [Client Dependency Injection](#client-dependency-injection) - [Data Conversion](#data-conversion) - [Workers](#workers) @@ -249,6 +250,25 @@ Notes about the above code: * The `handle` above represents a `WorkflowHandle` which has specific workflow operations on it. For existing workflows, handles can be obtained via `client.GetWorkflowHandle`. +#### Cloud Client Using MTLS + +Assuming a client certificate is present at `my-cert.pem` and a client key is present at `my-key.pem`, this is how to +connect to Temporal Cloud: + +```csharp +using Temporalio.Client; + +var client = await TemporalClient.ConnectAsync(new("my-namespace.a1b2c.tmprl.cloud:7233") +{ + Namespace = "my-namespace.a1b2c", + Tls = new() + { + ClientCert = await File.ReadAllBytesAsync("my-cert.pem"), + ClientPrivateKey = await File.ReadAllBytesAsync("my-key.pem"), + }, +}); +``` + #### Client Dependency Injection To create clients for use with dependency injection, see the diff --git a/src/Temporalio.Extensions.Hosting/README.md b/src/Temporalio.Extensions.Hosting/README.md index 9fa5082c..2a686f8b 100644 --- a/src/Temporalio.Extensions.Hosting/README.md +++ b/src/Temporalio.Extensions.Hosting/README.md @@ -27,9 +27,9 @@ builder.Services. AddScopedActivities(). AddWorkflow(); -// Run var host = builder.Build(); -host.Run(); +// Make sure you use RunAsync and not Run, see https://github.com/temporalio/sdk-dotnet/issues/220 +await host.RunAsync(); ``` This creates a hosted Temporal worker which returns a builder. Then `MyActivityClass` is added to the service collection @@ -91,6 +91,9 @@ are available as parameters that can be configured. `TemporalWorkerServiceOption `TemporalWorkerOptions` with an added property for optional client options that can be set to connect a client on worker start instead of expecting a `ITemporalClient` to be present on the service collection. +⚠️WARNING: Make sure you use host `RunAsync()` and not `Run()` (see +[this](https://github.com/temporalio/sdk-dotnet/issues/220) issue) + ## Activity Dependency Injection without Worker Services Some users may prefer to manually create the `TemporalWorker` without using host support, but still make their