Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate HTTP client with warning. #824

Merged
merged 2 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@
import io.grpc.Channel;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.Mono;

/**
* Holds a client for Dapr sidecar communication. ActorClient should be reused.
*/
public class ActorClient implements AutoCloseable {

private static final Logger LOGGER = LoggerFactory.getLogger(ActorClient.class);

/**
* gRPC channel for communication with Dapr sidecar.
*/
Expand Down Expand Up @@ -118,7 +122,10 @@ private static ManagedChannel buildManagedChannel(DaprApiProtocol apiProtocol) {
private static DaprClient buildDaprClient(DaprApiProtocol apiProtocol, Channel grpcManagedChannel) {
switch (apiProtocol) {
case GRPC: return new DaprGrpcClient(DaprGrpc.newStub(grpcManagedChannel));
case HTTP: return new DaprHttpClient(new DaprHttpBuilder().build());
case HTTP: {
LOGGER.warn("HTTP client protocol is deprecated and will be removed in Dapr's Java SDK version 1.10.");
return new DaprHttpClient(new DaprHttpBuilder().build());
}
default: throw new IllegalStateException("Unsupported protocol: " + apiProtocol.name());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@

/**
* DaprClient over HTTP for actor client.
*
* @deprecated This class will be deleted at SDK release version 1.10.
* @see DaprHttp
*/
@Deprecated
class DaprHttpClient implements DaprClient {

/**
Expand Down
2 changes: 2 additions & 0 deletions sdk/src/main/java/io/dapr/client/DaprApiProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@

/**
* Transport protocol for Dapr's API.
* @deprecated This class will be deleted at SDK version 1.10.
*/
@Deprecated
public enum DaprApiProtocol {

GRPC,
Expand Down
8 changes: 8 additions & 0 deletions sdk/src/main/java/io/dapr/client/DaprClientBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import io.dapr.v1.DaprGrpc;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Closeable;

Expand All @@ -29,6 +31,8 @@
*/
public class DaprClientBuilder {

private static final Logger LOGGER = LoggerFactory.getLogger(DaprClientBuilder.class);

/**
* Determine if this builder will create GRPC clients instead of HTTP clients.
*/
Expand Down Expand Up @@ -111,6 +115,10 @@ public DaprClientBuilder withStateSerializer(DaprObjectSerializer stateSerialize
* @throws java.lang.IllegalStateException if any required field is missing
*/
public DaprClient build() {
if (this.apiProtocol == DaprApiProtocol.HTTP) {
LOGGER.warn("HTTP client protocol is deprecated and will be removed in Dapr's Java SDK version 1.10.");
}

if (this.apiProtocol != this.methodInvocationApiProtocol) {
return new DaprClientProxy(buildDaprClient(this.apiProtocol), buildDaprClient(this.methodInvocationApiProtocol));
}
Expand Down
3 changes: 2 additions & 1 deletion sdk/src/main/java/io/dapr/client/DaprClientHttp.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@

/**
* An adapter for the HTTP Client.
*
* @deprecated This class will be deleted at SDK release version 1.10.
* @see io.dapr.client.DaprHttp
* @see io.dapr.client.DaprClient
*/
@Deprecated
public class DaprClientHttp extends AbstractDaprClient {
/**
* Header for the conditional operation.
Expand Down
3 changes: 2 additions & 1 deletion sdk/src/main/java/io/dapr/client/DaprClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@

/**
* Class that delegates to other implementations.
*
* @deprecated This class will be deleted at SDK release version 1.10.
* @see DaprClient
* @see DaprClientGrpc
* @see DaprClientHttp
*/
@Deprecated
class DaprClientProxy implements DaprClient {

/**
Expand Down
2 changes: 2 additions & 0 deletions sdk/src/main/java/io/dapr/client/DaprHttpBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@

/**
* A builder for the DaprHttp.
* @deprecated Use {@link DaprClientBuilder} instead, this will be removed in a future release.
*/
@Deprecated
public class DaprHttpBuilder {

/**
Expand Down
4 changes: 4 additions & 0 deletions sdk/src/main/java/io/dapr/config/Properties.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ public class Properties {

/**
* Determines if Dapr client will use gRPC or HTTP to talk to Dapr's side car.
* @deprecated This attribute will be deleted at SDK version 1.10.
*/
@Deprecated
public static final Property<DaprApiProtocol> API_PROTOCOL = new GenericProperty<>(
"dapr.api.protocol",
"DAPR_API_PROTOCOL",
Expand All @@ -110,7 +112,9 @@ public class Properties {

/**
* Determines if Dapr client should use gRPC or HTTP for Dapr's service method invocation APIs.
* @deprecated This attribute will be deleted at SDK version 1.10.
*/
@Deprecated
public static final Property<DaprApiProtocol> API_METHOD_INVOCATION_PROTOCOL = new GenericProperty<>(
"dapr.api.methodInvocation.protocol",
"DAPR_API_METHOD_INVOCATION_PROTOCOL",
Expand Down