Skip to content

Commit

Permalink
Merge into release (#565)
Browse files Browse the repository at this point in the history
*Merge master into release branch

Co-authored-by: Ryan Nowak <nowakra@gmail.com>

Co-authored-by: Ryan Nowak <nowakra@gmail.com>
Co-authored-by: Carlos Mendible <cmendible@gmail.com>
Co-authored-by: Arghya Sadhu <arghya88@gmail.com>
Co-authored-by: Per Ökvist <perokvist@users.noreply.github.com>
Co-authored-by: Sander Molenkamp <a.molenkamp@gmail.com>
Co-authored-by: LukePammant <Luke.pammant@gmail.com>
  • Loading branch information
7 people authored Jan 27, 2021
1 parent 191fd65 commit a4f6f04
Show file tree
Hide file tree
Showing 150 changed files with 6,424 additions and 3,797 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/sdk_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,20 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.301
dotnet-version: 3.1.x
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Test solution - release
run: |
unset GITHUB_ACTIONS #disable deterministic builds, just for test run. Deterministic builds break coverage for some reason
dotnet test test/test.sln --configuration release /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
# disable deterministic builds, just for test run. Deterministic builds break coverage for some reason
dotnet test --configuration release /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:GITHUB_ACTIONS=false
dotnet clean # remove the artifacts so they can be rebuild with deterministic builds enabled
- name: Build solution - release
run: dotnet build all.sln --configuration release
run: dotnet build --configuration release
- name: Generate Nuget Packages - release
run: dotnet pack src/prod.sln --configuration release
run: dotnet pack --configuration release
- name: upload artifacts
uses: actions/upload-artifact@master
with:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,6 @@ bld/
.vscode/

# coverlet code coverage results
coverage.json
coverage.json
.fake
.ionide
14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This repo builds the following packages:

### Prerequesites

Each project is a normal C# project. At minimum, you need [.NET Core SDK 3.1](https://dotnet.microsoft.com/download/dotnet-core/3.1) to build, test, and generate NuGet packages.
Each project is a normal C# project. At minimum, you need [.NET Core SDK 5.0](https://dotnet.microsoft.com/download/dotnet-core/5.0) to build, test, and generate NuGet packages.

**macOS/Linux:**

Expand All @@ -39,14 +39,6 @@ On Windows, we recommend installing [the latest Visual Studio 2019](https://www.
Make sure you [update Visual Studio to the most recent release](https://docs.microsoft.com/visualstudio/install/update-visual-studio).



### Solution Files
The repo currently has 4 solution files:
- *all.sln*: This includes all the sdk product, test and samples project files.
- *src/prod.sln*: This includes all the product project files.
- *samples/samples.sln*: This includes all the sample projects files dependencies project files.
- *test/test.sln*: This includes all the test projects and dependencies project files.

### Build

To build everything and generate NuGet packages, run dotnet cli commands. Binaries and NuGet packages will be dropped in a *bin* directory at the repo root.
Expand All @@ -56,10 +48,10 @@ To build everything and generate NuGet packages, run dotnet cli commands. Binari
dotnet build -c Debug # for release, -c Release

# Run unit-test
dotnet test test/test.sln
dotnet test

# Generate nuget packages in /bin/Debug/nugets
dotnet pack src/prod.sln
dotnet pack
```

Each project can also be built individually directly through the CLI or your editor/IDE. You can open the solution file all.sln in repo root to load all sdk, samples and test projects.
Expand Down
103 changes: 0 additions & 103 deletions azure-pipelines.yml

This file was deleted.

48 changes: 48 additions & 0 deletions docs/api-tokens.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
## Configure API token for authentication

Dapr runtime supports token based authentication wherein it requires every incoming API request to include an authentication token in the request headers. For more information, refer [here](https://docs.dapr.io/operations/security/api-token/).

Dotnet Sdk supports this by providing a mechanism to allow the user to specify a token.

# Dapr Client
You can use the code below to specify an api token:-
```
var daprClient = new DaprClientBuilder()
.UseGrpcChannelOptions(new GrpcChannelOptions { HttpClient = httpClient })
.UseDaprApiToken("your_token")
.Build();
```

# Actors
With actors, you can specify the api token using ActorProxyOptions as below:-
```
var actorId = new ActorId("abc");
var factory = new ActorProxyFactory();
factory.DefaultOptions.DaprApiToken = "your_token";
// Make strongly typed Actor calls with Remoting.
var remotingProxy = factory.CreateActorProxy<IDemoActor>(actorId, "DemoActor");
// Making calls without Remoting, this shows method invocation using InvokeMethodAsync methods, the method name and its payload is provided as arguments to InvokeMethodAsync methods.
var nonRemotingProxy = factory.Create(actorId, "DemoActor");
```
You need to configure the token in the actor itself as below:-
```
.....
public void ConfigureServices(IServiceCollection services)
{
....
services.AddActors(options =>
{
options.DaprApiToken = "your_token";
options.Actors.RegisterActor<YourActor>();
});
....
}
```

The calls made using the proxy created with the above code will have the request headers with:-
"dapr-api-token":"your_token"

Alternatively, the user can set an environment variable "DAPR_API_TOKEN" with the token value. In case the user has specified the token using code as well as the environment variable is set, the value set via code will be used.
9 changes: 9 additions & 0 deletions docs/cancellation-tokens.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Working with cancellation tokens

Asynchronous APIs exposed by `DaprClient` accept a cancellation token and by default, if the operation is canceled, you will get an OperationCanceledException. However, if you choose to initialize and pass in your own GrpcChannelOptions to the client builder, then unless you enable the [ThrowOperationCanceledOnCancellation setting](https://grpc.github.io/grpc/csharp-dotnet/api/Grpc.Net.Client.GrpcChannelOptions.html#Grpc_Net_Client_GrpcChannelOptions_ThrowOperationCanceledOnCancellation), the exception thrown would be an RpcException with StatusCode as Cancelled. To get an OperationCanceledException instead, refer to the code below:-
```c#
var httpClient = new HttpClient();
var daprClient = new DaprClientBuilder()
.UseGrpcChannelOptions(new GrpcChannelOptions { HttpClient = httpClient, ThrowOperationCanceledOnCancellation = true })
.Build();
```
Loading

0 comments on commit a4f6f04

Please sign in to comment.