Skip to content

Commit

Permalink
Merge branch 'master' into add-actor-serialization-options
Browse files Browse the repository at this point in the history
  • Loading branch information
halspang committed Jul 19, 2023
2 parents 8d25615 + 2449bcd commit 797b84c
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 21 deletions.
5 changes: 5 additions & 0 deletions daprdocs/content/en/dotnet-sdk-docs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ linkTitle: ".NET"
weight: 1000
description: .NET SDK packages for developing Dapr applications
no_list: true
cascade:
github_repo: https://github.com/dapr/dotnet-sdk
github_subdir: daprdocs/content/en/dotnet-sdk-docs
path_base_for_github_subdir: content/en/developing-applications/sdks/dotnet/
github_branch: master
---

Dapr offers a variety of packages to help with the development of .NET applications. Using them you can create .NET clients, servers, and virtual actors with Dapr.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,6 @@ namespace MyActorService
{
app.UseDeveloperExceptionPage();
}
else
{
// By default, ASP.Net Core uses port 5000 for HTTP. The HTTP
// redirection will interfere with the Dapr runtime. You can
// move this out of the else block if you use port 5001 in this
// example, and developer tooling (such as the VSCode extension).
app.UseHttpsRedirection();
}

app.UseRouting();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ The `DaprClientBuilder` contains settings for:

The SDK will read the following environment variables to configure the default values:

- `DAPR_HTTP_PORT`: used to find the HTTP endpoint of the Dapr sidecar
- `DAPR_GRPC_PORT`: used to find the gRPC endpoint of the Dapr sidecar
- `DAPR_HTTP_ENDPOINT`: used to find the HTTP endpoint of the Dapr sidecar, example: `https://dapr-api.mycompany.com`
- `DAPR_GRPC_ENDPOINT`: used to find the gRPC endpoint of the Dapr sidecar, example: `https://dapr-grpc-api.mycompany.com`
- `DAPR_HTTP_PORT`: if `DAPR_HTTP_ENDPOINT` is not set, this is used to find the HTTP local endpoint of the Dapr sidecar
- `DAPR_GRPC_PORT`: if `DAPR_GRPC_ENDPOINT` is not set, this is used to find the gRPC local endpoint of the Dapr sidecar
- `DAPR_API_TOKEN`: used to set the API Token

### Configuring gRPC channel options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.19.4" />
<PackageReference Include="Grpc.AspNetCore" Version="2.47.0" />
<PackageReference Include="Grpc.Net.Client" Version="2.47.0" />
<PackageReference Include="Grpc.Net.Client" Version="2.52.0" />
<PackageReference Include="Grpc.Tools" Version="2.47.0" PrivateAssets="All" />
<PackageReference Include="Google.Api.CommonProtos" Version="2.2.0" />
</ItemGroup>
Expand Down
5 changes: 3 additions & 2 deletions src/Dapr.Actors/Runtime/ActorRuntimeOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,9 @@ public int? RemindersStoragePartitions
/// </summary>
/// <remarks>
/// The URI endpoint to use for HTTP calls to the Dapr runtime. The default value will be
/// <c>http://127.0.0.1:DAPR_HTTP_PORT</c> where <c>DAPR_HTTP_PORT</c> represents the value of the
/// <c>DAPR_HTTP_PORT</c> environment variable.
/// <c>DAPR_HTTP_ENDPOINT</c> first, or <c>http://127.0.0.1:DAPR_HTTP_PORT</c> as fallback
/// where <c>DAPR_HTTP_ENDPOINT</c> and <c>DAPR_HTTP_PORT</c> represents the value of the
/// corresponding environment variables.
/// </remarks>
/// <value></value>
public string HttpEndpoint { get; set; } = DaprDefaults.GetDefaultHttpEndpoint();
Expand Down
2 changes: 1 addition & 1 deletion src/Dapr.Client/Dapr.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.15.0" />
<PackageReference Include="Grpc.Net.Client" Version="2.47.0" />
<PackageReference Include="Grpc.Net.Client" Version="2.52.0" />
<PackageReference Include="Grpc.Tools" Version="2.47.0" PrivateAssets="All" />
<PackageReference Include="Google.Api.CommonProtos" Version="2.2.0" />
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
Expand Down
5 changes: 3 additions & 2 deletions src/Dapr.Client/DaprClientBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ public DaprClientBuilder()
/// </summary>
/// <param name="httpEndpoint">
/// The URI endpoint to use for HTTP calls to the Dapr runtime. The default value will be
/// <c>http://127.0.0.1:DAPR_HTTP_PORT</c> where <c>DAPR_HTTP_PORT</c> represents the value of the
/// <c>DAPR_HTTP_PORT</c> environment variable.
/// <c>DAPR_HTTP_ENDPOINT</c> first, or <c>http://127.0.0.1:DAPR_HTTP_PORT</c> as fallback
/// where <c>DAPR_HTTP_ENDPOINT</c> and <c>DAPR_HTTP_PORT</c> represents the value of the
/// corresponding environment variables.
/// </param>
/// <returns>The <see cref="DaprClientBuilder" /> instance.</returns>
public DaprClientBuilder UseHttpEndpoint(string httpEndpoint)
Expand Down
6 changes: 6 additions & 0 deletions src/Dapr.Workflow/WorkflowServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ static bool TryGetGrpcAddress(out string address)
// 1. DaprDefaults.cs uses 127.0.0.1 instead of localhost, which prevents testing with Dapr on WSL2 and the app on Windows
// 2. DaprDefaults.cs doesn't compile when the project has C# nullable reference types enabled.
// If the above issues are fixed (ensuring we don't regress anything) we should switch to using the logic in DaprDefaults.cs.
string? daprEndpoint = Environment.GetEnvironmentVariable("DAPR_GRPC_ENDPOINT");
if (!String.IsNullOrEmpty(daprEndpoint)) {
address = daprEndpoint;
return true;
}

string? daprPortStr = Environment.GetEnvironmentVariable("DAPR_GRPC_PORT");
if (int.TryParse(daprPortStr, out int daprGrpcPort))
{
Expand Down
20 changes: 16 additions & 4 deletions src/Shared/DaprDefaults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,19 @@ public static string GetDefaultAppApiToken()
}

/// <summary>
/// Get the value of environment variable DAPR_HTTP_PORT
/// Get the value of HTTP endpoint based off environment variables
/// </summary>
/// <returns>The value of environment variable DAPR_HTTP_PORT</returns>
/// <returns>The value of HTTP endpoint based off environment variables</returns>
public static string GetDefaultHttpEndpoint()
{
if (httpEndpoint == null)
{
var endpoint = Environment.GetEnvironmentVariable("DAPR_HTTP_ENDPOINT");
if (!string.IsNullOrEmpty(endpoint)) {
httpEndpoint = endpoint;
return httpEndpoint;
}

var port = Environment.GetEnvironmentVariable("DAPR_HTTP_PORT");
port = string.IsNullOrEmpty(port) ? "3500" : port;
httpEndpoint = $"http://127.0.0.1:{port}";
Expand All @@ -73,13 +79,19 @@ public static string GetDefaultHttpEndpoint()
}

/// <summary>
/// Get the value of environment variable DAPR_GRPC_PORT
/// Get the value of gRPC endpoint based off environment variables
/// </summary>
/// <returns>The value of environment variable DAPR_GRPC_PORT</returns>
/// <returns>The value of gRPC endpoint based off environment variables</returns>
public static string GetDefaultGrpcEndpoint()
{
if (grpcEndpoint == null)
{
var endpoint = Environment.GetEnvironmentVariable("DAPR_GRPC_ENDPOINT");
if (!string.IsNullOrEmpty(endpoint)) {
grpcEndpoint = endpoint;
return grpcEndpoint;
}

var port = Environment.GetEnvironmentVariable("DAPR_GRPC_PORT");
port = string.IsNullOrEmpty(port) ? "50001" : port;
grpcEndpoint = $"http://127.0.0.1:{port}";
Expand Down
2 changes: 1 addition & 1 deletion test/Dapr.Client.Test/Dapr.Client.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="FluentAssertions" Version="5.9.0" />
<PackageReference Include="Google.Protobuf" Version="3.15.8" />
<PackageReference Include="Grpc.Core.Testing" Version="2.46.3" />
<PackageReference Include="Grpc.Net.Client" Version="2.47.0" />
<PackageReference Include="Grpc.Net.Client" Version="2.52.0" />
<PackageReference Include="Grpc.Tools" Version="2.47.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="moq" Version="4.14.7" />
Expand Down

0 comments on commit 797b84c

Please sign in to comment.