Skip to content
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/itests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ jobs:
prefix: 'net6'
env:
NUPKG_OUTDIR: bin/Release/nugets
GOVER: 1.17
GOVER: 1.19
GOOS: linux
GOARCH: amd64
GOPROXY: https://proxy.golang.org
DAPR_CLI_VER: 1.8.0
DAPR_RUNTIME_VER: 1.8.0
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/3dacfb672d55f1436c249057aaebbe597e1066f3/install/install.sh
DAPR_CLI_REF: ''
DAPR_REF: ''
DAPR_REF: '25213183ab8fd20f85f74591ee6ec3a00822adf7'
steps:
- name: Set up Dapr CLI
run: wget -q ${{ env.DAPR_INSTALL_URL }} -O - | /bin/bash -s ${{ env.DAPR_CLI_VER }}
Expand Down
23 changes: 20 additions & 3 deletions src/Dapr.Actors/Client/ActorProxyFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,16 @@ public ActorProxy Create(ActorId actorId, string actorType, ActorProxyOptions op
options ??= this.DefaultOptions;

var actorProxy = new ActorProxy();
var daprInteractor = new DaprHttpInteractor(this.handler, options.HttpEndpoint, options.DaprApiToken, options.RequestTimeout);
IDaprInteractor daprInteractor;
if (options.useGrpc) {
daprInteractor = new DaprInteractorBuilder()
.UseGrpcEndpoint(options.GrpcEndpoint)
.UseDaprApiToken(options.DaprApiToken)
.UseGrpcChannelOptions(options.GrpcChannelOptions)
.Build();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: These should be indented.

} else {
daprInteractor = new DaprHttpInteractor(this.handler, options.HttpEndpoint, options.DaprApiToken, options.RequestTimeout);
}
var nonRemotingClient = new ActorNonRemotingClient(daprInteractor);
actorProxy.Initialize(nonRemotingClient, actorId, actorType, options);

Expand All @@ -77,8 +86,16 @@ public ActorProxy Create(ActorId actorId, string actorType, ActorProxyOptions op
public object CreateActorProxy(ActorId actorId, Type actorInterfaceType, string actorType, ActorProxyOptions options = null)
{
options ??= this.DefaultOptions;

var daprInteractor = new DaprHttpInteractor(this.handler, options.HttpEndpoint, options.DaprApiToken, options.RequestTimeout);
IDaprInteractor daprInteractor;
if (options.useGrpc) {
daprInteractor = new DaprInteractorBuilder()
.UseGrpcEndpoint(options.GrpcEndpoint)
.UseDaprApiToken(options.DaprApiToken)
.UseGrpcChannelOptions(options.GrpcChannelOptions)
.Build();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

} else {
daprInteractor = new DaprHttpInteractor(this.handler, options.HttpEndpoint, options.DaprApiToken, options.RequestTimeout);
}
var remotingClient = new ActorRemotingClient(daprInteractor);
var proxyGenerator = ActorCodeBuilder.GetOrCreateProxyGenerator(actorInterfaceType);
var actorProxy = proxyGenerator.CreateActorProxy();
Expand Down
21 changes: 21 additions & 0 deletions src/Dapr.Actors/Client/ActorProxyOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace Dapr.Actors.Client
{
using System;
using System.Text.Json;
using Grpc.Net.Client;

/// <summary>
/// The class containing customizable options for how the Actor Proxy is initialized.
Expand Down Expand Up @@ -58,9 +59,29 @@ public JsonSerializerOptions JsonSerializerOptions
/// <value></value>
public string HttpEndpoint { get; set; } = DaprDefaults.GetDefaultHttpEndpoint();

/// <summary>
/// Gets or sets the Grpc endpoint URI used to communicate with the Dapr sidecar.
/// </summary>
/// <remarks>
/// The URI endpoint to use for Grpc calls to the Dapr runtime. The default value will be
/// <c>http://127.0.0.1:DAPR_GRPC_PORT</c> where <c>DAPR_GRPC_PORT</c> represents the value of the
/// <c>DAPR_GRPC_PORT</c> environment variable.
/// </remarks>
/// <value></value>
public string GrpcEndpoint { get; set; } = DaprDefaults.GetDefaultGrpcEndpoint();

/// <summary>
/// The timeout allowed for an actor request. Can be set to System.Threading.Timeout.InfiniteTimeSpan to disable any timeouts.
/// </summary>
public TimeSpan? RequestTimeout { get; set; } = null;
/// <summary>
/// Option to use GRPC or HTTP
/// </summary>
public bool useGrpc { get; set; } = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Missing whitespace at the top and public members are capitalized. useGrpc -> UseGrpc.


/// <summary>
/// Options for grpc channel
/// </summary>
public GrpcChannelOptions GrpcChannelOptions { get; set; } = new GrpcChannelOptions(){ThrowOperationCanceledOnCancellation = true,};
}
}
Loading