Skip to content

Commit beafb5a

Browse files
authored
Deprecate HTTP client with warning. (dapr#824)
Signed-off-by: Artur Souza <[email protected]> Signed-off-by: Artur Souza <[email protected]>
1 parent 81591b9 commit beafb5a

File tree

8 files changed

+30
-4
lines changed

8 files changed

+30
-4
lines changed

sdk-actors/src/main/java/io/dapr/actors/client/ActorClient.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@
2121
import io.grpc.Channel;
2222
import io.grpc.ManagedChannel;
2323
import io.grpc.ManagedChannelBuilder;
24+
import org.slf4j.Logger;
25+
import org.slf4j.LoggerFactory;
2426
import reactor.core.publisher.Mono;
2527

2628
/**
2729
* Holds a client for Dapr sidecar communication. ActorClient should be reused.
2830
*/
2931
public class ActorClient implements AutoCloseable {
3032

33+
private static final Logger LOGGER = LoggerFactory.getLogger(ActorClient.class);
34+
3135
/**
3236
* gRPC channel for communication with Dapr sidecar.
3337
*/
@@ -118,7 +122,10 @@ private static ManagedChannel buildManagedChannel(DaprApiProtocol apiProtocol) {
118122
private static DaprClient buildDaprClient(DaprApiProtocol apiProtocol, Channel grpcManagedChannel) {
119123
switch (apiProtocol) {
120124
case GRPC: return new DaprGrpcClient(DaprGrpc.newStub(grpcManagedChannel));
121-
case HTTP: return new DaprHttpClient(new DaprHttpBuilder().build());
125+
case HTTP: {
126+
LOGGER.warn("HTTP client protocol is deprecated and will be removed in Dapr's Java SDK version 1.10.");
127+
return new DaprHttpClient(new DaprHttpBuilder().build());
128+
}
122129
default: throw new IllegalStateException("Unsupported protocol: " + apiProtocol.name());
123130
}
124131
}

sdk-actors/src/main/java/io/dapr/actors/client/DaprHttpClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818

1919
/**
2020
* DaprClient over HTTP for actor client.
21-
*
21+
* @deprecated This class will be deleted at SDK release version 1.10.
2222
* @see DaprHttp
2323
*/
24+
@Deprecated
2425
class DaprHttpClient implements DaprClient {
2526

2627
/**

sdk/src/main/java/io/dapr/client/DaprApiProtocol.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515

1616
/**
1717
* Transport protocol for Dapr's API.
18+
* @deprecated This class will be deleted at SDK version 1.10.
1819
*/
20+
@Deprecated
1921
public enum DaprApiProtocol {
2022

2123
GRPC,

sdk/src/main/java/io/dapr/client/DaprClientBuilder.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import io.dapr.v1.DaprGrpc;
2121
import io.grpc.ManagedChannel;
2222
import io.grpc.ManagedChannelBuilder;
23+
import org.slf4j.Logger;
24+
import org.slf4j.LoggerFactory;
2325

2426
import java.io.Closeable;
2527

@@ -29,6 +31,8 @@
2931
*/
3032
public class DaprClientBuilder {
3133

34+
private static final Logger LOGGER = LoggerFactory.getLogger(DaprClientBuilder.class);
35+
3236
/**
3337
* Determine if this builder will create GRPC clients instead of HTTP clients.
3438
*/
@@ -111,6 +115,10 @@ public DaprClientBuilder withStateSerializer(DaprObjectSerializer stateSerialize
111115
* @throws java.lang.IllegalStateException if any required field is missing
112116
*/
113117
public DaprClient build() {
118+
if (this.apiProtocol == DaprApiProtocol.HTTP) {
119+
LOGGER.warn("HTTP client protocol is deprecated and will be removed in Dapr's Java SDK version 1.10.");
120+
}
121+
114122
if (this.apiProtocol != this.methodInvocationApiProtocol) {
115123
return new DaprClientProxy(buildDaprClient(this.apiProtocol), buildDaprClient(this.methodInvocationApiProtocol));
116124
}

sdk/src/main/java/io/dapr/client/DaprClientHttp.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@
6666

6767
/**
6868
* An adapter for the HTTP Client.
69-
*
69+
* @deprecated This class will be deleted at SDK release version 1.10.
7070
* @see io.dapr.client.DaprHttp
7171
* @see io.dapr.client.DaprClient
7272
*/
73+
@Deprecated
7374
public class DaprClientHttp extends AbstractDaprClient {
7475
/**
7576
* Header for the conditional operation.

sdk/src/main/java/io/dapr/client/DaprClientProxy.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@
3737

3838
/**
3939
* Class that delegates to other implementations.
40-
*
40+
* @deprecated This class will be deleted at SDK release version 1.10.
4141
* @see DaprClient
4242
* @see DaprClientGrpc
4343
* @see DaprClientHttp
4444
*/
45+
@Deprecated
4546
class DaprClientProxy implements DaprClient {
4647

4748
/**

sdk/src/main/java/io/dapr/client/DaprHttpBuilder.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323

2424
/**
2525
* A builder for the DaprHttp.
26+
* @deprecated Use {@link DaprClientBuilder} instead, this will be removed in a future release.
2627
*/
28+
@Deprecated
2729
public class DaprHttpBuilder {
2830

2931
/**

sdk/src/main/java/io/dapr/config/Properties.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ public class Properties {
101101

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

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

0 commit comments

Comments
 (0)