mirror of https://github.com/dapr/java-sdk.git
Deprecate HTTP client with warning. (#824)
Signed-off-by: Artur Souza <asouza.pro@gmail.com> Signed-off-by: Artur Souza <asouza.pro@gmail.com>
This commit is contained in:
parent
81591b9f5b
commit
beafb5a5b3
|
@ -21,6 +21,8 @@ import io.dapr.v1.DaprGrpc;
|
||||||
import io.grpc.Channel;
|
import io.grpc.Channel;
|
||||||
import io.grpc.ManagedChannel;
|
import io.grpc.ManagedChannel;
|
||||||
import io.grpc.ManagedChannelBuilder;
|
import io.grpc.ManagedChannelBuilder;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +30,8 @@ import reactor.core.publisher.Mono;
|
||||||
*/
|
*/
|
||||||
public class ActorClient implements AutoCloseable {
|
public class ActorClient implements AutoCloseable {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(ActorClient.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gRPC channel for communication with Dapr sidecar.
|
* gRPC channel for communication with Dapr sidecar.
|
||||||
*/
|
*/
|
||||||
|
@ -118,7 +122,10 @@ public class ActorClient implements AutoCloseable {
|
||||||
private static DaprClient buildDaprClient(DaprApiProtocol apiProtocol, Channel grpcManagedChannel) {
|
private static DaprClient buildDaprClient(DaprApiProtocol apiProtocol, Channel grpcManagedChannel) {
|
||||||
switch (apiProtocol) {
|
switch (apiProtocol) {
|
||||||
case GRPC: return new DaprGrpcClient(DaprGrpc.newStub(grpcManagedChannel));
|
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());
|
default: throw new IllegalStateException("Unsupported protocol: " + apiProtocol.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,10 @@ import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DaprClient over HTTP for actor client.
|
* DaprClient over HTTP for actor client.
|
||||||
*
|
* @deprecated This class will be deleted at SDK release version 1.10.
|
||||||
* @see DaprHttp
|
* @see DaprHttp
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
class DaprHttpClient implements DaprClient {
|
class DaprHttpClient implements DaprClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,7 +15,9 @@ package io.dapr.client;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transport protocol for Dapr's API.
|
* Transport protocol for Dapr's API.
|
||||||
|
* @deprecated This class will be deleted at SDK version 1.10.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public enum DaprApiProtocol {
|
public enum DaprApiProtocol {
|
||||||
|
|
||||||
GRPC,
|
GRPC,
|
||||||
|
|
|
@ -20,6 +20,8 @@ import io.dapr.utils.Version;
|
||||||
import io.dapr.v1.DaprGrpc;
|
import io.dapr.v1.DaprGrpc;
|
||||||
import io.grpc.ManagedChannel;
|
import io.grpc.ManagedChannel;
|
||||||
import io.grpc.ManagedChannelBuilder;
|
import io.grpc.ManagedChannelBuilder;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
|
|
||||||
|
@ -29,6 +31,8 @@ import java.io.Closeable;
|
||||||
*/
|
*/
|
||||||
public class DaprClientBuilder {
|
public class DaprClientBuilder {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(DaprClientBuilder.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if this builder will create GRPC clients instead of HTTP clients.
|
* Determine if this builder will create GRPC clients instead of HTTP clients.
|
||||||
*/
|
*/
|
||||||
|
@ -111,6 +115,10 @@ public class DaprClientBuilder {
|
||||||
* @throws java.lang.IllegalStateException if any required field is missing
|
* @throws java.lang.IllegalStateException if any required field is missing
|
||||||
*/
|
*/
|
||||||
public DaprClient build() {
|
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) {
|
if (this.apiProtocol != this.methodInvocationApiProtocol) {
|
||||||
return new DaprClientProxy(buildDaprClient(this.apiProtocol), buildDaprClient(this.methodInvocationApiProtocol));
|
return new DaprClientProxy(buildDaprClient(this.apiProtocol), buildDaprClient(this.methodInvocationApiProtocol));
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,10 +66,11 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An adapter for the HTTP Client.
|
* 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.DaprHttp
|
||||||
* @see io.dapr.client.DaprClient
|
* @see io.dapr.client.DaprClient
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class DaprClientHttp extends AbstractDaprClient {
|
public class DaprClientHttp extends AbstractDaprClient {
|
||||||
/**
|
/**
|
||||||
* Header for the conditional operation.
|
* Header for the conditional operation.
|
||||||
|
|
|
@ -37,11 +37,12 @@ import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class that delegates to other implementations.
|
* Class that delegates to other implementations.
|
||||||
*
|
* @deprecated This class will be deleted at SDK release version 1.10.
|
||||||
* @see DaprClient
|
* @see DaprClient
|
||||||
* @see DaprClientGrpc
|
* @see DaprClientGrpc
|
||||||
* @see DaprClientHttp
|
* @see DaprClientHttp
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
class DaprClientProxy implements DaprClient {
|
class DaprClientProxy implements DaprClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,7 +23,9 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A builder for the DaprHttp.
|
* A builder for the DaprHttp.
|
||||||
|
* @deprecated Use {@link DaprClientBuilder} instead, this will be removed in a future release.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class DaprHttpBuilder {
|
public class DaprHttpBuilder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -101,7 +101,9 @@ public class Properties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if Dapr client will use gRPC or HTTP to talk to Dapr's side car.
|
* 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<>(
|
public static final Property<DaprApiProtocol> API_PROTOCOL = new GenericProperty<>(
|
||||||
"dapr.api.protocol",
|
"dapr.api.protocol",
|
||||||
"DAPR_API_PROTOCOL",
|
"DAPR_API_PROTOCOL",
|
||||||
|
@ -110,7 +112,9 @@ public class Properties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if Dapr client should use gRPC or HTTP for Dapr's service method invocation APIs.
|
* 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<>(
|
public static final Property<DaprApiProtocol> API_METHOD_INVOCATION_PROTOCOL = new GenericProperty<>(
|
||||||
"dapr.api.methodInvocation.protocol",
|
"dapr.api.methodInvocation.protocol",
|
||||||
"DAPR_API_METHOD_INVOCATION_PROTOCOL",
|
"DAPR_API_METHOD_INVOCATION_PROTOCOL",
|
||||||
|
|
Loading…
Reference in New Issue