Skip to content

Commit

Permalink
Readme updates (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
cretz committed Apr 24, 2024
1 parent 899672c commit 2bd9ed3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions src/Temporalio.Extensions.Hosting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ builder.Services.
AddScopedActivities<MyActivityClass>().
AddWorkflow<MyWorkflow>();

// 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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2bd9ed3

Please sign in to comment.