Skip to content

Commit

Permalink
Merge branch 'master' into cryptography
Browse files Browse the repository at this point in the history
  • Loading branch information
WhitWaldo authored Dec 23, 2023
2 parents 4a1d801 + 10ef818 commit b343e54
Show file tree
Hide file tree
Showing 48 changed files with 387 additions and 149 deletions.
6 changes: 6 additions & 0 deletions .github/holopin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
organization: dapr
defaultSticker: clmjkxscc122740fl0mkmb7egi
stickers:
-
id: clmjkxscc122740fl0mkmb7egi
alias: ghc2023
20 changes: 12 additions & 8 deletions .github/workflows/itests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: ['6.0', '7.0']
dotnet-version: ['6.0', '7.0', '8.0']
include:
- dotnet-version: '6.0'
display-name: '.NET 6.0'
Expand All @@ -31,17 +31,21 @@ jobs:
framework: 'net7'
prefix: 'net7'
install-version: '7.0.x'
- dotnet-version: '8.0'
display-name: '.NET 8.0'
framework: 'net8'
prefix: 'net8'
install-version: '8.0.x'
env:
NUPKG_OUTDIR: bin/Release/nugets
GOVER: 1.20.3
GOOS: linux
GOARCH: amd64
GOPROXY: https://proxy.golang.org
DAPR_CLI_VER: 1.9.1
DAPR_RUNTIME_VER: 1.10.5
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/3dacfb672d55f1436c249057aaebbe597e1066f3/install/install.sh
DAPR_CLI_VER: 1.12.0
DAPR_RUNTIME_VER: 1.12.0
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/release-1.12/install/install.sh
DAPR_CLI_REF: ''
DAPR_REF: '4181de0edc65fc98a836ae7abc6042c575c8fae5'
steps:
- name: Set up Dapr CLI
run: wget -q ${{ env.DAPR_INSTALL_URL }} -O - | /bin/bash -s ${{ env.DAPR_CLI_VER }}
Expand Down Expand Up @@ -101,11 +105,11 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ matrix.install-version }}
- name: Setup .NET 7.0 # net7 is always required.
- name: Setup .NET 8.0 # net8 is always required.
uses: actions/setup-dotnet@v1
if: ${{ matrix.install-version != '7.0.x' }}
if: ${{ matrix.install-version != '8.0.x' }}
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Build
# disable deterministic builds, just for test run. Deterministic builds break coverage for some reason
run: dotnet build --configuration release /p:GITHUB_ACTIONS=false
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/sdk_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Build
run: dotnet build --configuration release
- name: Generate Packages
Expand All @@ -42,7 +42,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: ['6.0', '7.0']
dotnet-version: ['6.0', '7.0', '8.0']
include:
- dotnet-version: '6.0'
install-3: false
Expand All @@ -56,6 +56,12 @@ jobs:
framework: 'net7'
prefix: 'net7'
install-version: '7.0.x'
- dotnet-version: '8.0'
install-3: false
display-name: '.NET 8.0'
framework: 'net8'
prefix: 'net8'
install-version: '8.0.x'
steps:
- uses: actions/checkout@v1
- name: Parse release version
Expand All @@ -64,11 +70,11 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ matrix.install-version }}
- name: Setup .NET 7.0 # net7 is always required.
- name: Setup .NET 8.0 # net8 is always required.
uses: actions/setup-dotnet@v1
if: ${{ matrix.install-version != '7.0.x' }}
if: ${{ matrix.install-version != '8.0.x' }}
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Build
# disable deterministic builds, just for test run. Deterministic builds break coverage for some reason
run: dotnet build --configuration release /p:GITHUB_ACTIONS=false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Run the following command to start a workflow.
{{% codetab %}}

```bash
curl -i -X POST http://localhost:3500/v1.0-alpha1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=12345678 \
curl -i -X POST http://localhost:3500/v1.0-beta1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=12345678 \
-H "Content-Type: application/json" \
-d '{"Name": "Paperclips", "TotalCost": 99.95, "Quantity": 1}'
```
Expand All @@ -93,7 +93,7 @@ curl -i -X POST http://localhost:3500/v1.0-alpha1/workflows/dapr/OrderProcessing
{{% codetab %}}

```powershell
curl -i -X POST http://localhost:3500/v1.0-alpha1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=12345678 `
curl -i -X POST http://localhost:3500/v1.0-beta1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=12345678 `
-H "Content-Type: application/json" `
-d '{"Name": "Paperclips", "TotalCost": 99.95, "Quantity": 1}'
```
Expand All @@ -111,7 +111,7 @@ If successful, you should see a response like the following:
Send an HTTP request to get the status of the workflow that was started:

```bash
curl -i -X GET http://localhost:3500/v1.0-alpha1/workflows/dapr/12345678
curl -i -X GET http://localhost:3500/v1.0-beta1/workflows/dapr/12345678
```

The workflow is designed to take several seconds to complete. If the workflow hasn't completed when you issue the HTTP request, you'll see the following JSON response (formatted for readability) with workflow status as `RUNNING`:
Expand Down
5 changes: 2 additions & 3 deletions examples/Actor/ActorClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace ActorClient
using System.Threading.Tasks;
using Dapr.Actors;
using Dapr.Actors.Client;
using Dapr.Actors.Communication;
using IDemoActorInterface;

/// <summary>
Expand Down Expand Up @@ -69,7 +68,7 @@ public static async Task Main(string[] args)
}
catch (ActorMethodInvocationException ex)
{
if (ex.InnerException is NotImplementedException)
if (ex.InnerException is ActorInvokeException invokeEx && invokeEx.ActualExceptionType is "System.NotImplementedException")
{
Console.WriteLine($"Got Correct Exception from actor method invocation.");
}
Expand Down Expand Up @@ -111,7 +110,7 @@ public static async Task Main(string[] args)
await Task.Delay(5000);
Console.WriteLine("Getting details of the registered reminder");
reminder = await proxy.GetReminder();
Console.WriteLine($"Received reminder is {reminder}.");
Console.WriteLine($"Received reminder is {reminder?.ToString() ?? "None"} (expecting None).");
Console.WriteLine("Registering reminder with ttl and repetitions, i.e. reminder stops when either condition is met - The reminder will repeat 2 times.");
await proxy.RegisterReminderWithTtlAndRepetitions(TimeSpan.FromSeconds(5), 2);
Console.WriteLine("Getting details of the registered reminder");
Expand Down
15 changes: 12 additions & 3 deletions examples/Actor/DemoActor/DemoActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,18 @@ public async Task RegisterReminderWithTtlAndRepetitions(TimeSpan ttl, int repeti
await this.RegisterReminderAsync("TestReminder", null, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(1), repetitions, ttl);
}

public async Task<IActorReminder> GetReminder()
{
return await this.GetReminderAsync("TestReminder");
public async Task<ActorReminderData> GetReminder()
{
var reminder = await this.GetReminderAsync("TestReminder");

return reminder is not null
? new ActorReminderData
{
Name = reminder.Name,
Period = reminder.Period,
DueTime = reminder.DueTime
}
: null;
}

public Task UnregisterReminder()
Expand Down
16 changes: 15 additions & 1 deletion examples/Actor/IDemoActor/IDemoActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public interface IDemoActor : IActor
/// </summary>
/// <param name="reminderName">The name of the reminder.</param>
/// <returns>A task that returns the reminder after completion.</returns>
Task<IActorReminder> GetReminder();
Task<ActorReminderData> GetReminder();

/// <summary>
/// Unregisters the registered timer.
Expand Down Expand Up @@ -132,4 +132,18 @@ public override string ToString()
return $"PropertyA: {propAValue}, PropertyB: {propBValue}";
}
}

public class ActorReminderData
{
public string Name { get; set; }

public TimeSpan DueTime { get; set; }

public TimeSpan Period { get; set; }

public override string ToString()
{
return $"Name: {this.Name}, DueTime: {this.DueTime}, Period: {this.Period}";
}
}
}
24 changes: 16 additions & 8 deletions examples/Workflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,22 @@ This Dapr workflow example shows how to create a Dapr workflow (`Workflow`) and


## Optional Setup
Dapr workflow, as well as this example program, now support authentication through the use of API tokens. For more information on this, view the following document: [API Token](https://github.com/dapr/dotnet-sdk/docs/api-token.md)
Dapr workflow, as well as this example program, now support authentication through the use of API tokens. For more information on this, view the following document: [API Token](https://github.com/dapr/dotnet-sdk/blob/master/docs/api-tokens.md)

## Projects in sample

This sample contains a single [WorkflowConsoleApp](./WorkflowConsoleApp) .NET project.
It utilizes the workflow SDK as well as the workflow management API for starting and querying workflows instances.
The main `Program.cs` file contains the main setup of the app, including the registration of the workflow and workflow activities.
The workflow definition is found in the `Workflows` directory and the workflow activity definitions are found in the `Activities` directory.
It utilizes the workflow SDK as well as the workflow management API for simulating inventory management and sale of goods in a store.
The main `Program.cs` file contains the main setup of the app, the registration of the workflow and its activities, and interaction with the user. The workflow definition is found in the `Workflows` directory and the workflow activity definitions are found in the `Activities` directory.

There are five activities in the directory that could be called by the workflows:
- `NotifyActivity`: printing logs as notifications
- `ProcessPaymentActivity`: printing logs and delaying for simulating payment processing
- `RequestApprovalActivity`: printing logs to indicate that the order has been approved
- `ReserveInventoryActivity`: checking if there are enough items for purchase
- `UpdateInventoryActivity`: updating the statestore according to purchasing

The `OrderProcessingWorkflow.cs` in `Workflows` directory implements the running logic of the workflow. Based on the purchase stage and outcome, it calls different activities and waits for the corresponding events to trigger interaction with the user.

This sample also contains a [WorkflowUnitTest](./WorkflowUnitTest) .NET project that utilizes [xUnit](https://xunit.net/) and [Moq](https://github.com/moq/moq) to test the workflow logic.
It works by creating an instance of the `OrderProcessingWorkflow` (defined in the `WorkflowConsoleApp` project), mocking activity calls, and testing the inputs and outputs.
Expand Down Expand Up @@ -53,15 +61,15 @@ For the workflow API option, two identical `curl` commands are shown, one for Li
Make note of the "1234" in the commands below. This represents the unique identifier for the workflow run and can be replaced with any identifier of your choosing.

```bash
curl -i -X POST http://localhost:3500/v1.0-alpha1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=1234 \
curl -i -X POST http://localhost:3500/v1.0-beta1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=1234 \
-H "Content-Type: application/json" \
-d '{"Name": "Paperclips", "TotalCost": 99.95, "Quantity": 1}'
```

On Windows (PowerShell):

```powershell
curl -i -X POST http://localhost:3500/v1.0-alpha1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=1234 `
curl -i -X POST http://localhost:3500/v1.0-beta1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=1234 `
-H "Content-Type: application/json" `
-d '{"Name": "Paperclips", "TotalCost": 99.95, "Quantity": 1}'
```
Expand All @@ -75,7 +83,7 @@ If successful, you should see a response like the following:
Next, send an HTTP request to get the status of the workflow that was started:

```bash
curl -i -X GET http://localhost:3500/v1.0-alpha1/workflows/dapr/1234
curl -i -X GET http://localhost:3500/v1.0-beta1/workflows/dapr/1234
```

The workflow is designed to take several seconds to complete. If the workflow hasn't completed yet when you issue the previous command, you should see the following JSON response (formatted for readability):
Expand Down Expand Up @@ -124,4 +132,4 @@ info: WorkflowConsoleApp.Activities.NotifyActivity[0]
Order 1234 processed successfully!
```

If you have Zipkin configured for Dapr locally on your machine, then you can view the workflow trace spans in the Zipkin web UI (typically at http://localhost:9411/zipkin/).
If you have Zipkin configured for Dapr locally on your machine, then you can view the workflow trace spans in the Zipkin web UI (typically at http://localhost:9411/zipkin/).
9 changes: 8 additions & 1 deletion examples/Workflow/WorkflowConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@
// Start the input loop
using (daprClient)
{
while (true)
bool quit = false;
Console.CancelKeyPress += delegate
{
quit = true;
Console.WriteLine("Shutting down the example.");
};

while (!quit)
{
// Get the name of the item to order and make sure we have inventory
string items = string.Join(", ", baseInventory.Select(i => i.Name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<OutputType>Exe</OutputType>
<TargetFramework>net6</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
<NoWarn>612,618</NoWarn>
</PropertyGroup>

Expand Down
8 changes: 4 additions & 4 deletions examples/Workflow/WorkflowConsoleApp/demo.http
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
### Start order processing workflow - replace xxx with any id you like
POST http://localhost:3500/v1.0-alpha1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=xxx
POST http://localhost:3500/v1.0-beta1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=xxx
Content-Type: application/json

{"Name": "Paperclips", "TotalCost": 99.95, "Quantity": 1}

### Start order processing workflow - replace xxx with any id you like
POST http://localhost:3500/v1.0-alpha1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=xxx
POST http://localhost:3500/v1.0-beta1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=xxx
Content-Type: application/json

{"Name": "Cars", "TotalCost": 10000, "Quantity": 30}

### Query dapr sidecar - replace xxx with id from the workflow you've created above
GET http://localhost:3500/v1.0-alpha1/workflows/dapr/xxx
GET http://localhost:3500/v1.0-beta1/workflows/dapr/xxx

### Terminate the workflow - replace xxx with id from the workflow you've created above
POST http://localhost:3500/v1.0-alpha1/workflows/dapr/xxx/terminate
POST http://localhost:3500/v1.0-beta1/workflows/dapr/xxx/terminate
1 change: 0 additions & 1 deletion examples/Workflow/WorkflowUnitTest/WorkflowUnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>10</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion properties/dapr_managed_netcore.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Import Project="dapr_common.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<LangVersion>9.0</LangVersion>
<LangVersion>10.0</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private static IEndpointConventionBuilder MapActorMethodEndpoint(this IEndpointR
if (header != string.Empty)
{
// exception case
context.Response.Headers.Add(Constants.ErrorResponseHeaderName, header); // add error header
context.Response.Headers[Constants.ErrorResponseHeaderName] = header; // add error header
}
await context.Response.Body.WriteAsync(body, 0, body.Length); // add response message body
Expand All @@ -118,7 +118,7 @@ private static IEndpointConventionBuilder MapActorMethodEndpoint(this IEndpointR
{
var (header, body) = CreateExceptionResponseMessage(ex);
context.Response.Headers.Add(Constants.ErrorResponseHeaderName, header);
context.Response.Headers[Constants.ErrorResponseHeaderName] = header;
await context.Response.Body.WriteAsync(body, 0, body.Length);
}
finally
Expand Down
3 changes: 0 additions & 3 deletions src/Dapr.Actors.AspNetCore/Dapr.Actors.AspNetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6</TargetFramework>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<!--
Expand Down
4 changes: 0 additions & 4 deletions src/Dapr.Actors/Dapr.Actors.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6</TargetFramework>
</PropertyGroup>

<!-- Additional Nuget package properties. -->
<PropertyGroup>
<Description>This package contains the reference assemblies for developing Actor services using Dapr.</Description>
Expand Down
4 changes: 0 additions & 4 deletions src/Dapr.AspNetCore/Dapr.AspNetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6</TargetFramework>
</PropertyGroup>

<!-- Additional Nuget package properties. -->
<PropertyGroup>
<Description>This package contains the reference assemblies for developing services using Dapr and AspNetCore.</Description>
Expand Down
Loading

0 comments on commit b343e54

Please sign in to comment.