Skip to content

Commit

Permalink
remove unused http vars
Browse files Browse the repository at this point in the history
Signed-off-by: addjuarez <[email protected]>
  • Loading branch information
addjuarez committed Sep 26, 2022
1 parent f90d2ec commit d19061c
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 73 deletions.
6 changes: 0 additions & 6 deletions src/Dapr.Actors/Client/ActorProxyFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,8 @@ public ActorProxy Create(ActorId actorId, string actorType, ActorProxyOptions op
if (options.useGrpc) {
daprInteractor = new DaprInteractorBuilder()
.UseGrpcEndpoint(options.GrpcEndpoint)
.UseHttpEndpoint(options.HttpEndpoint)
.UseDaprApiToken(options.DaprApiToken)
.UseGrpcChannelOptions(options.GrpcChannelOptions)
.UseHandler(this.handler)
.UseRequestTimeout(options.RequestTimeout)
.Build();
} else {
daprInteractor = new DaprHttpInteractor(this.handler, options.HttpEndpoint, options.DaprApiToken, options.RequestTimeout);
Expand All @@ -93,11 +90,8 @@ public object CreateActorProxy(ActorId actorId, Type actorInterfaceType, string
if (options.useGrpc) {
daprInteractor = new DaprInteractorBuilder()
.UseGrpcEndpoint(options.GrpcEndpoint)
.UseHttpEndpoint(options.HttpEndpoint)
.UseDaprApiToken(options.DaprApiToken)
.UseGrpcChannelOptions(options.GrpcChannelOptions)
.UseHandler(this.handler)
.UseRequestTimeout(options.RequestTimeout)
.Build();
} else {
daprInteractor = new DaprHttpInteractor(this.handler, options.HttpEndpoint, options.DaprApiToken, options.RequestTimeout);
Expand Down
21 changes: 1 addition & 20 deletions src/Dapr.Actors/DaprGrpcInteractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ namespace Dapr.Actors
internal class DaprGrpcInteractor : IDaprInteractor
{
private readonly JsonSerializerOptions jsonSerializerOptions = JsonSerializerDefaults.Web;
private readonly string httpEndpoint;
private readonly static HttpMessageHandler defaultHandler = new HttpClientHandler();
private readonly HttpMessageHandler handler;
private HttpClient httpClient;
private bool disposed;
private string daprApiToken;
private readonly Autogenerated.Dapr.DaprClient client;
Expand All @@ -53,18 +49,11 @@ internal class DaprGrpcInteractor : IDaprInteractor
public DaprGrpcInteractor(
GrpcChannel channel,
Autogenerated.Dapr.DaprClient inner,
HttpMessageHandler clientHandler,
string httpEndpoint,
string apiToken,
TimeSpan? requestTimeout)
string apiToken)
{
this.channel = channel;
this.client = inner;
this.handler = clientHandler ?? defaultHandler;
this.httpEndpoint = httpEndpoint;
this.daprApiToken = apiToken;
this.httpClient = this.CreateHttpClient();
this.httpClient.Timeout = requestTimeout ?? this.httpClient.Timeout;
}

public async Task<string> GetStateAsync(string actorType, string actorId, string keyName, CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -180,7 +169,6 @@ public async Task<IActorResponseMessage> InvokeActorMethodWithRemotingAsync(Acto
out var remoteMethodException);
if (isDeserialzied)
{

throw new ActorMethodInvocationException(
"Remote Actor Method Exception, DETAILS: " + remoteMethodException.Message,
remoteMethodException,
Expand Down Expand Up @@ -352,8 +340,6 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{
this.httpClient.Dispose();
this.httpClient = null;
this.channel.Dispose();
}

Expand All @@ -374,10 +360,5 @@ private CallOptions CreateCallOptions(CancellationToken cancellationToken)
return options;
}

private HttpClient CreateHttpClient()
{
return new HttpClient(this.handler, false);
}

}
}
47 changes: 1 addition & 46 deletions src/Dapr.Actors/DaprInteractorBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public sealed class DaprInteractorBuilder
public DaprInteractorBuilder()
{
this.GrpcEndpoint = DaprDefaults.GetDefaultGrpcEndpoint();
this.HttpEndpoint = DaprDefaults.GetDefaultHttpEndpoint();

this.GrpcChannelOptions = new GrpcChannelOptions()
{
Expand All @@ -40,31 +39,9 @@ public DaprInteractorBuilder()

internal string GrpcEndpoint { get; private set; }

internal string HttpEndpoint { get; private set; }

internal GrpcChannelOptions GrpcChannelOptions { get; private set; }
internal string DaprApiToken { get; private set; }

internal TimeSpan? RequestTimeout { get; set; } = null;

internal HttpMessageHandler Handler { get; set; } = null;
/// <summary>
/// Overrides the HTTP endpoint used by <see cref="DaprGrpcInteractor" /> for communicating with the Dapr runtime.
/// </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.
/// </param>
/// <returns>The <see cref="DaprInteractorBuilder" /> instance.</returns>
public DaprInteractorBuilder UseHttpEndpoint(string httpEndpoint)
{
ArgumentVerifier.ThrowIfNullOrEmpty(httpEndpoint, nameof(httpEndpoint));
this.HttpEndpoint = httpEndpoint;
return this;
}


/// <summary>
/// Overrides the gRPC endpoint used by <see cref="DaprGrpcInteractor" /> for communicating with the Dapr runtime.
/// </summary>
Expand Down Expand Up @@ -104,28 +81,6 @@ public DaprInteractorBuilder UseDaprApiToken(string apiToken)
return this;
}

/// <summary>
/// Adds the provided <paramref name="handler" /> on every request to the Dapr runtime.
/// </summary>
/// <param name="handler">The token to be added to the request headers/>.</param>
/// <returns>The <see cref="DaprInteractorBuilder" /> instance.</returns>
public DaprInteractorBuilder UseHandler(HttpMessageHandler handler)
{
this.Handler = handler;
return this;
}

/// <summary>
/// Adds the provided <paramref name="requestTimeout" /> on every request to the Dapr runtime.
/// </summary>
/// <param name="requestTimeout">The token to be added to the request headers/>.</param>
/// <returns>The <see cref="DaprInteractorBuilder" /> instance.</returns>
public DaprInteractorBuilder UseRequestTimeout(TimeSpan? requestTimeout)
{
this.RequestTimeout = requestTimeout;
return this;
}

/// <summary>
/// Builds a <see cref="DaprGrpcInteractor" /> instance from the properties of the builder.
/// </summary>
Expand All @@ -148,7 +103,7 @@ internal DaprGrpcInteractor Build()
var channel = GrpcChannel.ForAddress(this.GrpcEndpoint, this.GrpcChannelOptions);
var client = new Autogenerated.Dapr.DaprClient(channel);

return new DaprGrpcInteractor(channel, client, this.Handler, this.HttpEndpoint, this.DaprApiToken, this.RequestTimeout);
return new DaprGrpcInteractor(channel, client, this.DaprApiToken);
}
}
}
1 change: 0 additions & 1 deletion src/Dapr.Actors/Runtime/ActorRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ internal ActorRuntime(ActorRuntimeOptions options, ILoggerFactory loggerFactory,
if (options.useGrpc) {
daprInteractor = new DaprInteractorBuilder()
.UseGrpcEndpoint(options.GrpcEndpoint)
.UseHttpEndpoint(options.HttpEndpoint)
.UseDaprApiToken(options.DaprApiToken)
.UseGrpcChannelOptions(options.GrpcChannelOptions)
.Build();
Expand Down

0 comments on commit d19061c

Please sign in to comment.