From e75ff261dd94b82dabed6409cc6833d8cd9388ce Mon Sep 17 00:00:00 2001 From: Pravin Pushkar Date: Thu, 27 Jan 2022 16:30:49 +0530 Subject: [PATCH 01/13] Adding javadocs to some Domain classes (#673) * Adding javadocs to some Domain classes Signed-off-by: pravinpushkar * Fixing code coverage Signed-off-by: pravinpushkar * Incorporating review comments Signed-off-by: pravinpushkar Signed-off-by: Subash Gamage --- .../io/dapr/client/domain/DeleteStateRequest.java | 6 ++++++ .../client/domain/ExecuteStateTransactionRequest.java | 8 ++++++++ .../io/dapr/client/domain/GetBulkSecretRequest.java | 5 +++++ .../io/dapr/client/domain/GetBulkStateRequest.java | 6 ++++++ .../dapr/client/domain/GetConfigurationRequest.java | 6 ++++++ .../java/io/dapr/client/domain/GetSecretRequest.java | 6 ++++++ .../java/io/dapr/client/domain/GetStateRequest.java | 6 ++++++ .../io/dapr/client/domain/InvokeBindingRequest.java | 6 ++++++ .../io/dapr/client/domain/InvokeMethodRequest.java | 6 ++++++ .../java/io/dapr/client/domain/SaveStateRequest.java | 5 +++++ .../main/java/io/dapr/client/domain/StateOptions.java | 9 +++++++++ .../client/domain/SubscribeConfigurationRequest.java | 6 ++++++ .../client/domain/TransactionalStateOperation.java | 7 +++++++ .../dapr/client/domain/TransactionalStateRequest.java | 4 ++++ .../io/dapr/client/DaprPreviewClientGrpcTest.java | 11 +++++++++++ 15 files changed, 97 insertions(+) diff --git a/sdk/src/main/java/io/dapr/client/domain/DeleteStateRequest.java b/sdk/src/main/java/io/dapr/client/domain/DeleteStateRequest.java index ffdacde29..ec623a3e6 100644 --- a/sdk/src/main/java/io/dapr/client/domain/DeleteStateRequest.java +++ b/sdk/src/main/java/io/dapr/client/domain/DeleteStateRequest.java @@ -31,6 +31,12 @@ public class DeleteStateRequest { private StateOptions stateOptions; + /** + * Constructor for DeleteStateRequest. + * + * @param storeName Name of the state store + * @param key Key present in the state store + */ public DeleteStateRequest(String storeName, String key) { this.stateStoreName = storeName; this.key = key; diff --git a/sdk/src/main/java/io/dapr/client/domain/ExecuteStateTransactionRequest.java b/sdk/src/main/java/io/dapr/client/domain/ExecuteStateTransactionRequest.java index 988f1d988..91615b26e 100644 --- a/sdk/src/main/java/io/dapr/client/domain/ExecuteStateTransactionRequest.java +++ b/sdk/src/main/java/io/dapr/client/domain/ExecuteStateTransactionRequest.java @@ -17,6 +17,9 @@ import java.util.List; import java.util.Map; +/** + * A request for executing state transaction operations. + */ public class ExecuteStateTransactionRequest { /** @@ -34,6 +37,11 @@ public class ExecuteStateTransactionRequest { */ private Map metadata; + /** + * Constructor for ExecuteStateTransactionRequest. + * + * @param stateStoreName Name of the state store + */ public ExecuteStateTransactionRequest(String stateStoreName) { this.stateStoreName = stateStoreName; } diff --git a/sdk/src/main/java/io/dapr/client/domain/GetBulkSecretRequest.java b/sdk/src/main/java/io/dapr/client/domain/GetBulkSecretRequest.java index f950eb559..45289ff56 100644 --- a/sdk/src/main/java/io/dapr/client/domain/GetBulkSecretRequest.java +++ b/sdk/src/main/java/io/dapr/client/domain/GetBulkSecretRequest.java @@ -25,6 +25,11 @@ public class GetBulkSecretRequest { private Map metadata; + /** + * Constructor for GetBulkSecretRequest. + * + * @param storeName Name of the secret store + */ public GetBulkSecretRequest(String storeName) { this.storeName = storeName; } diff --git a/sdk/src/main/java/io/dapr/client/domain/GetBulkStateRequest.java b/sdk/src/main/java/io/dapr/client/domain/GetBulkStateRequest.java index fa65eaf4a..47a20e2e0 100644 --- a/sdk/src/main/java/io/dapr/client/domain/GetBulkStateRequest.java +++ b/sdk/src/main/java/io/dapr/client/domain/GetBulkStateRequest.java @@ -31,6 +31,12 @@ public class GetBulkStateRequest { private int parallelism = 1; + /** + * Constructor for GetBulkStateRequest. + * + * @param storeName Name of the state store + * @param keys keys for the state objects + */ public GetBulkStateRequest(String storeName, List keys) { this.storeName = storeName; this.keys = keys == null ? null : Collections.unmodifiableList(keys); diff --git a/sdk/src/main/java/io/dapr/client/domain/GetConfigurationRequest.java b/sdk/src/main/java/io/dapr/client/domain/GetConfigurationRequest.java index 7e0d13c54..a8de2bd61 100644 --- a/sdk/src/main/java/io/dapr/client/domain/GetConfigurationRequest.java +++ b/sdk/src/main/java/io/dapr/client/domain/GetConfigurationRequest.java @@ -25,6 +25,12 @@ public class GetConfigurationRequest { private final List keys; private Map metadata; + /** + * Constructor for GetConfigurationRequest. + * + * @param storeName Name of the configuration store + * @param keys Keys for the configuration objects + */ public GetConfigurationRequest(String storeName, List keys) { this.storeName = storeName; this.keys = keys == null ? Collections.EMPTY_LIST : Collections.unmodifiableList(keys); diff --git a/sdk/src/main/java/io/dapr/client/domain/GetSecretRequest.java b/sdk/src/main/java/io/dapr/client/domain/GetSecretRequest.java index fa1a22b10..d0e9629ea 100644 --- a/sdk/src/main/java/io/dapr/client/domain/GetSecretRequest.java +++ b/sdk/src/main/java/io/dapr/client/domain/GetSecretRequest.java @@ -25,6 +25,12 @@ public class GetSecretRequest { private final String key; + /** + * Constructor for GetSecretRequest. + * + * @param storeName Name of the Secret Store + * @param key Key for retrieving the secret + */ public GetSecretRequest(String storeName, String key) { this.storeName = storeName; this.key = key; diff --git a/sdk/src/main/java/io/dapr/client/domain/GetStateRequest.java b/sdk/src/main/java/io/dapr/client/domain/GetStateRequest.java index f80034539..fdd5797ef 100644 --- a/sdk/src/main/java/io/dapr/client/domain/GetStateRequest.java +++ b/sdk/src/main/java/io/dapr/client/domain/GetStateRequest.java @@ -29,6 +29,12 @@ public class GetStateRequest { private StateOptions stateOptions; + /** + * Constructor for GetStateRequest. + * + * @param storeName Name of the state store + * @param key Key of the state object + */ public GetStateRequest(String storeName, String key) { this.storeName = storeName; this.key = key; diff --git a/sdk/src/main/java/io/dapr/client/domain/InvokeBindingRequest.java b/sdk/src/main/java/io/dapr/client/domain/InvokeBindingRequest.java index c45e31264..33bc72eba 100644 --- a/sdk/src/main/java/io/dapr/client/domain/InvokeBindingRequest.java +++ b/sdk/src/main/java/io/dapr/client/domain/InvokeBindingRequest.java @@ -29,6 +29,12 @@ public class InvokeBindingRequest { private Map metadata; + /** + * Constructor for InvokeBindingRequest. + * + * @param bindingName Name of the binding + * @param operation Name of the binding operation + */ public InvokeBindingRequest(String bindingName, String operation) { this.name = bindingName; this.operation = operation; diff --git a/sdk/src/main/java/io/dapr/client/domain/InvokeMethodRequest.java b/sdk/src/main/java/io/dapr/client/domain/InvokeMethodRequest.java index c6391a23a..6058363bb 100644 --- a/sdk/src/main/java/io/dapr/client/domain/InvokeMethodRequest.java +++ b/sdk/src/main/java/io/dapr/client/domain/InvokeMethodRequest.java @@ -28,6 +28,12 @@ public class InvokeMethodRequest { private String contentType; + /** + * Constructor for InvokeMethodRequest. + * + * @param appId ID of the Dapr application + * @param method Name of the method to be invoked + */ public InvokeMethodRequest(String appId, String method) { this.appId = appId; this.method = method; diff --git a/sdk/src/main/java/io/dapr/client/domain/SaveStateRequest.java b/sdk/src/main/java/io/dapr/client/domain/SaveStateRequest.java index 67bcd7ee5..39c0da1a3 100644 --- a/sdk/src/main/java/io/dapr/client/domain/SaveStateRequest.java +++ b/sdk/src/main/java/io/dapr/client/domain/SaveStateRequest.java @@ -26,6 +26,11 @@ public class SaveStateRequest { private List> states; + /** + * Constructor for SaveStateRequest. + * + * @param storeName Name of the state store + */ public SaveStateRequest(String storeName) { this.storeName = storeName; } diff --git a/sdk/src/main/java/io/dapr/client/domain/StateOptions.java b/sdk/src/main/java/io/dapr/client/domain/StateOptions.java index 356eb0899..136e47f7e 100644 --- a/sdk/src/main/java/io/dapr/client/domain/StateOptions.java +++ b/sdk/src/main/java/io/dapr/client/domain/StateOptions.java @@ -32,6 +32,9 @@ import java.util.Map; import java.util.Optional; +/** + * A class representing the state options for Dapr state API. + */ public class StateOptions { private final Consistency consistency; private final Concurrency concurrency; @@ -70,6 +73,9 @@ public Map getStateOptionsAsMap() { return Collections.unmodifiableMap(Optional.ofNullable(mapOptions).orElse(Collections.EMPTY_MAP)); } + /** + * Options for Consistency. + */ public enum Consistency { EVENTUAL("eventual"), STRONG("strong"); @@ -91,6 +97,9 @@ public static Consistency fromValue(String value) { } } + /** + * Options for Concurrency. + */ public enum Concurrency { FIRST_WRITE("first-write"), LAST_WRITE("last-write"); diff --git a/sdk/src/main/java/io/dapr/client/domain/SubscribeConfigurationRequest.java b/sdk/src/main/java/io/dapr/client/domain/SubscribeConfigurationRequest.java index 0684dce5e..25118c400 100644 --- a/sdk/src/main/java/io/dapr/client/domain/SubscribeConfigurationRequest.java +++ b/sdk/src/main/java/io/dapr/client/domain/SubscribeConfigurationRequest.java @@ -25,6 +25,12 @@ public class SubscribeConfigurationRequest { private final List keys; private Map metadata; + /** + * Constructor for SubscribeConfigurationRequest. + * + * @param storeName Name of the configuration store + * @param keys Keys of the configurations values to subscribe to + */ public SubscribeConfigurationRequest(String storeName, List keys) { this.storeName = storeName; this.keys = keys == null ? Collections.EMPTY_LIST : Collections.unmodifiableList(keys); diff --git a/sdk/src/main/java/io/dapr/client/domain/TransactionalStateOperation.java b/sdk/src/main/java/io/dapr/client/domain/TransactionalStateOperation.java index 8ec6a992a..1e613c746 100644 --- a/sdk/src/main/java/io/dapr/client/domain/TransactionalStateOperation.java +++ b/sdk/src/main/java/io/dapr/client/domain/TransactionalStateOperation.java @@ -17,6 +17,10 @@ import java.util.Objects; +/** + * Class to represent transactional state operations. + * @param Type of the state value + */ public class TransactionalStateOperation { /** @@ -73,6 +77,9 @@ public String toString() { + '}'; } + /** + * Options for type of operation. + */ public enum OperationType { @JsonProperty("upsert") UPSERT, @JsonProperty("delete") DELETE diff --git a/sdk/src/main/java/io/dapr/client/domain/TransactionalStateRequest.java b/sdk/src/main/java/io/dapr/client/domain/TransactionalStateRequest.java index a5fff1cf8..6eb5969fa 100644 --- a/sdk/src/main/java/io/dapr/client/domain/TransactionalStateRequest.java +++ b/sdk/src/main/java/io/dapr/client/domain/TransactionalStateRequest.java @@ -17,6 +17,10 @@ import java.util.List; import java.util.Map; +/** + * A class to represent request for transactional state. + * @param Type of state value in TransactionalStateOperation + */ public class TransactionalStateRequest { /** diff --git a/sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java b/sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java index a5ce0a592..2252074e3 100644 --- a/sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java +++ b/sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java @@ -15,6 +15,8 @@ import io.dapr.client.domain.ConfigurationItem; +import io.dapr.client.domain.GetConfigurationRequest; +import io.dapr.client.domain.SubscribeConfigurationRequest; import io.dapr.serializer.DefaultObjectSerializer; import io.dapr.v1.CommonProtos; import io.dapr.v1.DaprGrpc; @@ -73,6 +75,10 @@ public void getConfigurationTestErrorScenario() { assertThrows(IllegalArgumentException.class, () -> { previewClient.getConfiguration("", "key").block(); }); + GetConfigurationRequest req = new GetConfigurationRequest(CONFIG_STORE_NAME, null); + assertThrows(IllegalArgumentException.class, () -> { + previewClient.getConfiguration(req).block(); + }); } @Test @@ -223,6 +229,11 @@ public void subscribeConfigurationWithErrorTest() { assertThrows(IllegalArgumentException.class, () -> { previewClient.subscribeToConfiguration("", "key").blockFirst(); }); + + SubscribeConfigurationRequest req = new SubscribeConfigurationRequest(CONFIG_STORE_NAME, null); + assertThrows(IllegalArgumentException.class, () -> { + previewClient.subscribeToConfiguration(req).blockFirst(); + }); } private DaprProtos.GetConfigurationResponse getSingleMockResponse() { From 75d3bdda047d7eb2c727d3d07a75efa7308b764c Mon Sep 17 00:00:00 2001 From: Mukundan Sundararajan Date: Fri, 28 Jan 2022 00:30:40 +0530 Subject: [PATCH 02/13] fix github action for dapr comment analyzer bot (#680) Signed-off-by: Mukundan Sundararajan Co-authored-by: Artur Souza Signed-off-by: Subash Gamage --- .github/workflows/dapr_bot.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dapr_bot.yml b/.github/workflows/dapr_bot.yml index c1cb92306..0c2676c7a 100644 --- a/.github/workflows/dapr_bot.yml +++ b/.github/workflows/dapr_bot.yml @@ -20,7 +20,8 @@ jobs: if (!isFromPulls && commentBody && commentBody.indexOf("/assign") == 0) { if (!issue.assignees || issue.assignees.length === 0) { - await github.issues.addAssignees({ + // See https://github.com/actions/github-script#breaking-changes-in-v5 + await github.rest.issues.addAssignees({ owner: issue.owner, repo: issue.repo, issue_number: issue.number, From 2e9af80a45a88aa700cbfc1593ad0d921ccc4196 Mon Sep 17 00:00:00 2001 From: Subash Gamage Date: Wed, 23 Feb 2022 06:53:48 -0500 Subject: [PATCH 03/13] Provide custom grpc/http client for DaprClientBuilder Signed-off-by: Subash Gamage Signed-off-by: Subash Gamage --- README.md | 21 ++++++++++++++++ .../io/dapr/client/DaprClientBuilder.java | 24 +++++++++++++++++-- .../java/io/dapr/client/DaprHttpBuilder.java | 15 +++++++++++- .../io/dapr/client/DaprClientBuilderTest.java | 24 +++++++++++++++++++ 4 files changed, 81 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2479f730e..a56accecd 100644 --- a/README.md +++ b/README.md @@ -160,6 +160,27 @@ This SDK provides a basic serialization for request/response objects but also fo } ``` +#### How to provide custom grpc/http client for DaprClient + +When building dapr client, following api will allow you to provide your own managed grpc channel within the DaprClient. This allows users to define/maintain their own thread pools and tune grpc parameters. +Similarly you can override http client while building dapr client and tune http client parameters. + + * Override custom grpc managed channel for DaprClient + + ```java + DaprClientBuilder daprClientBuilder = new DaprClientBuilder(); + ManagedChannelBuilder managedChannelBuilder = Grpc.newChannelBuilder("localhost:8000", TlsChannelCredentials.create()) + .executor(Executors.newFixedThreadPool(20)); + DaprClient client = daprClientBuilder.withManagedGrpcChannel(managedChannelBuilder.build()).build(); + ``` + + * Override custom okhttpclient for DaprClient + + ```java + DaprClientBuilder daprClientBuilder = new DaprClientBuilder(); + DaprClient client = daprClientBuilder.withOkHttpClient(new OkHttpClient.Builder().readTimeout(5, TimeUnit.SECONDS)).build(); + ``` + #### Debug Java application or Dapr's Java SDK diff --git a/sdk/src/main/java/io/dapr/client/DaprClientBuilder.java b/sdk/src/main/java/io/dapr/client/DaprClientBuilder.java index 855c6013e..7b751ca80 100644 --- a/sdk/src/main/java/io/dapr/client/DaprClientBuilder.java +++ b/sdk/src/main/java/io/dapr/client/DaprClientBuilder.java @@ -19,6 +19,7 @@ import io.dapr.v1.DaprGrpc; import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; +import okhttp3.OkHttpClient; import java.io.Closeable; @@ -43,6 +44,11 @@ public class DaprClientBuilder { */ private final DaprHttpBuilder daprHttpBuilder; + /** + * Managed gRPC channel + */ + private ManagedChannel channel; + /** * Serializer used for request and response objects in DaprClient. */ @@ -103,6 +109,16 @@ public DaprClientBuilder withStateSerializer(DaprObjectSerializer stateSerialize return this; } + public DaprClientBuilder withManagedGrpcChannel(ManagedChannel channel){ + this.channel = channel; + return this; + } + + public DaprClientBuilder withOkHttpClient(OkHttpClient.Builder builder){ + this.daprHttpBuilder.withOkHttpClientBuilder(builder); + return this; + } + /** * Build an instance of the Client based on the provided setup. * @@ -157,8 +173,12 @@ private DaprClient buildDaprClientGrpc() { if (port <= 0) { throw new IllegalArgumentException("Invalid port."); } - ManagedChannel channel = ManagedChannelBuilder.forAddress( - Properties.SIDECAR_IP.get(), port).usePlaintext().build(); + + if(channel == null) { + channel = ManagedChannelBuilder.forAddress( + Properties.SIDECAR_IP.get(), port).usePlaintext().build(); + } + Closeable closeableChannel = () -> { if (channel != null && !channel.isShutdown()) { channel.shutdown(); diff --git a/sdk/src/main/java/io/dapr/client/DaprHttpBuilder.java b/sdk/src/main/java/io/dapr/client/DaprHttpBuilder.java index 5f71b0f7d..619278bca 100644 --- a/sdk/src/main/java/io/dapr/client/DaprHttpBuilder.java +++ b/sdk/src/main/java/io/dapr/client/DaprHttpBuilder.java @@ -33,6 +33,20 @@ public class DaprHttpBuilder { */ private static final Object LOCK = new Object(); + /** + * OKHttpClient builder + */ + private OkHttpClient.Builder builder; + + public DaprHttpBuilder() { + builder = new OkHttpClient.Builder(); + } + + public DaprHttpBuilder withOkHttpClientBuilder(OkHttpClient.Builder builder){ + this.builder = builder; + return this; + } + /** * Build an instance of the Http client based on the provided setup. * @@ -52,7 +66,6 @@ private DaprHttp buildDaprHttp() { if (OK_HTTP_CLIENT == null) { synchronized (LOCK) { if (OK_HTTP_CLIENT == null) { - OkHttpClient.Builder builder = new OkHttpClient.Builder(); Duration readTimeout = Duration.ofSeconds(Properties.HTTP_CLIENT_READ_TIMEOUT_SECONDS.get()); builder.readTimeout(readTimeout); OK_HTTP_CLIENT = builder.build(); diff --git a/sdk/src/test/java/io/dapr/client/DaprClientBuilderTest.java b/sdk/src/test/java/io/dapr/client/DaprClientBuilderTest.java index c543c1b93..9cf135244 100644 --- a/sdk/src/test/java/io/dapr/client/DaprClientBuilderTest.java +++ b/sdk/src/test/java/io/dapr/client/DaprClientBuilderTest.java @@ -14,8 +14,16 @@ package io.dapr.client; import io.dapr.serializer.DaprObjectSerializer; +import io.grpc.ChannelCredentials; +import io.grpc.Grpc; +import io.grpc.ManagedChannelBuilder; +import io.grpc.TlsChannelCredentials; +import okhttp3.OkHttpClient; import org.junit.Test; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -49,4 +57,20 @@ public void noStateSerializer() { new DaprClientBuilder().withStateSerializer(null); } + @Test + public void testBuilderWithManagedChannel(){ + DaprClientBuilder daprClientBuilder = new DaprClientBuilder(); + ManagedChannelBuilder managedChannelBuilder = Grpc.newChannelBuilder("localhost:8000", TlsChannelCredentials.create()) + .executor(Executors.newFixedThreadPool(20)); + DaprClient client = daprClientBuilder.withManagedGrpcChannel(managedChannelBuilder.build()).build(); + assertNotNull(client); + } + + @Test + public void testBuilderWithOkHttpClient(){ + DaprClientBuilder daprClientBuilder = new DaprClientBuilder(); + DaprClient client = daprClientBuilder.withOkHttpClient(new OkHttpClient.Builder().readTimeout(10, TimeUnit.SECONDS)).build(); + assertNotNull(client); + } + } From 888c1e72a3c4f0d4261ebc1c0e1b6c913467af28 Mon Sep 17 00:00:00 2001 From: Subash Gamage Date: Fri, 4 Mar 2022 17:02:31 -0500 Subject: [PATCH 04/13] Revert "Provide custom grpc/http client for DaprClientBuilder Signed-off-by: Subash Gamage " This reverts commit 1d88c7617c20ebe24765033a95b2e70b87a58bd7. Signed-off-by: Subash Gamage --- README.md | 21 ---------------- .../io/dapr/client/DaprClientBuilder.java | 24 ++----------------- .../java/io/dapr/client/DaprHttpBuilder.java | 15 +----------- .../io/dapr/client/DaprClientBuilderTest.java | 24 ------------------- 4 files changed, 3 insertions(+), 81 deletions(-) diff --git a/README.md b/README.md index a56accecd..2479f730e 100644 --- a/README.md +++ b/README.md @@ -160,27 +160,6 @@ This SDK provides a basic serialization for request/response objects but also fo } ``` -#### How to provide custom grpc/http client for DaprClient - -When building dapr client, following api will allow you to provide your own managed grpc channel within the DaprClient. This allows users to define/maintain their own thread pools and tune grpc parameters. -Similarly you can override http client while building dapr client and tune http client parameters. - - * Override custom grpc managed channel for DaprClient - - ```java - DaprClientBuilder daprClientBuilder = new DaprClientBuilder(); - ManagedChannelBuilder managedChannelBuilder = Grpc.newChannelBuilder("localhost:8000", TlsChannelCredentials.create()) - .executor(Executors.newFixedThreadPool(20)); - DaprClient client = daprClientBuilder.withManagedGrpcChannel(managedChannelBuilder.build()).build(); - ``` - - * Override custom okhttpclient for DaprClient - - ```java - DaprClientBuilder daprClientBuilder = new DaprClientBuilder(); - DaprClient client = daprClientBuilder.withOkHttpClient(new OkHttpClient.Builder().readTimeout(5, TimeUnit.SECONDS)).build(); - ``` - #### Debug Java application or Dapr's Java SDK diff --git a/sdk/src/main/java/io/dapr/client/DaprClientBuilder.java b/sdk/src/main/java/io/dapr/client/DaprClientBuilder.java index 7b751ca80..855c6013e 100644 --- a/sdk/src/main/java/io/dapr/client/DaprClientBuilder.java +++ b/sdk/src/main/java/io/dapr/client/DaprClientBuilder.java @@ -19,7 +19,6 @@ import io.dapr.v1.DaprGrpc; import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; -import okhttp3.OkHttpClient; import java.io.Closeable; @@ -44,11 +43,6 @@ public class DaprClientBuilder { */ private final DaprHttpBuilder daprHttpBuilder; - /** - * Managed gRPC channel - */ - private ManagedChannel channel; - /** * Serializer used for request and response objects in DaprClient. */ @@ -109,16 +103,6 @@ public DaprClientBuilder withStateSerializer(DaprObjectSerializer stateSerialize return this; } - public DaprClientBuilder withManagedGrpcChannel(ManagedChannel channel){ - this.channel = channel; - return this; - } - - public DaprClientBuilder withOkHttpClient(OkHttpClient.Builder builder){ - this.daprHttpBuilder.withOkHttpClientBuilder(builder); - return this; - } - /** * Build an instance of the Client based on the provided setup. * @@ -173,12 +157,8 @@ private DaprClient buildDaprClientGrpc() { if (port <= 0) { throw new IllegalArgumentException("Invalid port."); } - - if(channel == null) { - channel = ManagedChannelBuilder.forAddress( - Properties.SIDECAR_IP.get(), port).usePlaintext().build(); - } - + ManagedChannel channel = ManagedChannelBuilder.forAddress( + Properties.SIDECAR_IP.get(), port).usePlaintext().build(); Closeable closeableChannel = () -> { if (channel != null && !channel.isShutdown()) { channel.shutdown(); diff --git a/sdk/src/main/java/io/dapr/client/DaprHttpBuilder.java b/sdk/src/main/java/io/dapr/client/DaprHttpBuilder.java index 619278bca..5f71b0f7d 100644 --- a/sdk/src/main/java/io/dapr/client/DaprHttpBuilder.java +++ b/sdk/src/main/java/io/dapr/client/DaprHttpBuilder.java @@ -33,20 +33,6 @@ public class DaprHttpBuilder { */ private static final Object LOCK = new Object(); - /** - * OKHttpClient builder - */ - private OkHttpClient.Builder builder; - - public DaprHttpBuilder() { - builder = new OkHttpClient.Builder(); - } - - public DaprHttpBuilder withOkHttpClientBuilder(OkHttpClient.Builder builder){ - this.builder = builder; - return this; - } - /** * Build an instance of the Http client based on the provided setup. * @@ -66,6 +52,7 @@ private DaprHttp buildDaprHttp() { if (OK_HTTP_CLIENT == null) { synchronized (LOCK) { if (OK_HTTP_CLIENT == null) { + OkHttpClient.Builder builder = new OkHttpClient.Builder(); Duration readTimeout = Duration.ofSeconds(Properties.HTTP_CLIENT_READ_TIMEOUT_SECONDS.get()); builder.readTimeout(readTimeout); OK_HTTP_CLIENT = builder.build(); diff --git a/sdk/src/test/java/io/dapr/client/DaprClientBuilderTest.java b/sdk/src/test/java/io/dapr/client/DaprClientBuilderTest.java index 9cf135244..c543c1b93 100644 --- a/sdk/src/test/java/io/dapr/client/DaprClientBuilderTest.java +++ b/sdk/src/test/java/io/dapr/client/DaprClientBuilderTest.java @@ -14,16 +14,8 @@ package io.dapr.client; import io.dapr.serializer.DaprObjectSerializer; -import io.grpc.ChannelCredentials; -import io.grpc.Grpc; -import io.grpc.ManagedChannelBuilder; -import io.grpc.TlsChannelCredentials; -import okhttp3.OkHttpClient; import org.junit.Test; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -57,20 +49,4 @@ public void noStateSerializer() { new DaprClientBuilder().withStateSerializer(null); } - @Test - public void testBuilderWithManagedChannel(){ - DaprClientBuilder daprClientBuilder = new DaprClientBuilder(); - ManagedChannelBuilder managedChannelBuilder = Grpc.newChannelBuilder("localhost:8000", TlsChannelCredentials.create()) - .executor(Executors.newFixedThreadPool(20)); - DaprClient client = daprClientBuilder.withManagedGrpcChannel(managedChannelBuilder.build()).build(); - assertNotNull(client); - } - - @Test - public void testBuilderWithOkHttpClient(){ - DaprClientBuilder daprClientBuilder = new DaprClientBuilder(); - DaprClient client = daprClientBuilder.withOkHttpClient(new OkHttpClient.Builder().readTimeout(10, TimeUnit.SECONDS)).build(); - assertNotNull(client); - } - } From 4b64452c8d8ca2de02ad7c1a7a0222c63315d7b5 Mon Sep 17 00:00:00 2001 From: Subash Gamage Date: Sat, 5 Mar 2022 08:13:59 -0500 Subject: [PATCH 05/13] Provide custom grpc/http client for DaprClientBuilder update 2. Signed-off-by: Subash Gamage Signed-off-by: Subash Gamage --- README.md | 13 +++++++++ .../io/dapr/client/DaprClientBuilder.java | 11 +++++-- .../client/DaprExtensibleClientBuilder.java | 29 +++++++++++++++++++ .../io/dapr/client/DaprClientBuilderTest.java | 14 +++++++++ 4 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 sdk/src/main/java/io/dapr/client/DaprExtensibleClientBuilder.java diff --git a/README.md b/README.md index 2479f730e..00935591c 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,19 @@ This SDK provides a basic serialization for request/response objects but also fo ``` +#### How to extend DaprClientBuilder + +This gives a way to provide a managed grpc channel to your DaprClient. + + ```java + + DaprExtensibleClientBuilder daprClientBuilder = new DaprExtensibleClientBuilder(); + ManagedChannelBuilder managedChannelBuilder = Grpc.newChannelBuilder("localhost:8000", TlsChannelCredentials.create()) + .executor(Executors.newFixedThreadPool(20)); + DaprClient client = daprClientBuilder.withManagedGrpcChannel(managedChannelBuilder.build()).build(); + ``` + + #### Debug Java application or Dapr's Java SDK **In IntelliJ Community Edition, consider [debugging in IntelliJ](https://docs.dapr.io/developing-applications/ides/intellij/).** diff --git a/sdk/src/main/java/io/dapr/client/DaprClientBuilder.java b/sdk/src/main/java/io/dapr/client/DaprClientBuilder.java index 855c6013e..c18c86011 100644 --- a/sdk/src/main/java/io/dapr/client/DaprClientBuilder.java +++ b/sdk/src/main/java/io/dapr/client/DaprClientBuilder.java @@ -53,6 +53,11 @@ public class DaprClientBuilder { */ private DaprObjectSerializer stateSerializer; + /** + * Managed gRPC channel + */ + protected ManagedChannel channel; + /** * Creates a constructor for DaprClient. * @@ -157,8 +162,10 @@ private DaprClient buildDaprClientGrpc() { if (port <= 0) { throw new IllegalArgumentException("Invalid port."); } - ManagedChannel channel = ManagedChannelBuilder.forAddress( - Properties.SIDECAR_IP.get(), port).usePlaintext().build(); + if(channel == null) { + channel = ManagedChannelBuilder.forAddress( + Properties.SIDECAR_IP.get(), port).usePlaintext().build(); + } Closeable closeableChannel = () -> { if (channel != null && !channel.isShutdown()) { channel.shutdown(); diff --git a/sdk/src/main/java/io/dapr/client/DaprExtensibleClientBuilder.java b/sdk/src/main/java/io/dapr/client/DaprExtensibleClientBuilder.java new file mode 100644 index 000000000..004cbd87a --- /dev/null +++ b/sdk/src/main/java/io/dapr/client/DaprExtensibleClientBuilder.java @@ -0,0 +1,29 @@ +/* + * Copyright 2021 The Dapr Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and +limitations under the License. +*/ + +package io.dapr.client; + +import io.grpc.ManagedChannel; + +/** + * A builder for the DaprClient. + */ +public class DaprExtensibleClientBuilder extends DaprClientBuilder{ + + public DaprClientBuilder withManagedGrpcChannel(ManagedChannel channel){ + this.channel = channel; + return this; + } + + +} diff --git a/sdk/src/test/java/io/dapr/client/DaprClientBuilderTest.java b/sdk/src/test/java/io/dapr/client/DaprClientBuilderTest.java index c543c1b93..79461f407 100644 --- a/sdk/src/test/java/io/dapr/client/DaprClientBuilderTest.java +++ b/sdk/src/test/java/io/dapr/client/DaprClientBuilderTest.java @@ -14,8 +14,13 @@ package io.dapr.client; import io.dapr.serializer.DaprObjectSerializer; +import io.grpc.Grpc; +import io.grpc.ManagedChannelBuilder; +import io.grpc.TlsChannelCredentials; import org.junit.Test; +import java.util.concurrent.Executors; + import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -34,6 +39,15 @@ public void build() { assertNotNull(daprClient); } + @Test + public void testBuilderWithManagedChannel(){ + DaprExtensibleClientBuilder daprClientBuilder = new DaprExtensibleClientBuilder(); + ManagedChannelBuilder managedChannelBuilder = Grpc.newChannelBuilder("localhost:8000", TlsChannelCredentials.create()) + .executor(Executors.newFixedThreadPool(20)); + DaprClient client = daprClientBuilder.withManagedGrpcChannel(managedChannelBuilder.build()).build(); + assertNotNull(client); + } + @Test(expected = IllegalArgumentException.class) public void noObjectSerializer() { new DaprClientBuilder().withObjectSerializer(null); From a6c22dc88b39a9feef5e7ae7a15c237855fa8dbb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 3 Mar 2022 22:19:40 +0530 Subject: [PATCH 06/13] Bump actions/setup-java from 2.5.0 to 3 (#696) Bumps [actions/setup-java](https://github.com/actions/setup-java) from 2.5.0 to 3. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/v2.5.0...v3) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: Subash Gamage --- .github/workflows/build.yml | 4 ++-- .github/workflows/validate.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 37f0f0899..2782607bf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,7 +33,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Set up OpenJDK ${{ env.JDK_VER }} - uses: actions/setup-java@v2.5.0 + uses: actions/setup-java@v3 with: distribution: 'adopt' java-version: ${{ env.JDK_VER }} @@ -125,7 +125,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Set up OpenJDK ${{ env.JDK_VER }} - uses: actions/setup-java@v2.5.0 + uses: actions/setup-java@v3 with: distribution: 'adopt' java-version: ${{ env.JDK_VER }} diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 4254b1097..eaccdde06 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -44,7 +44,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Set up OpenJDK ${{ env.JDK_VER }} - uses: actions/setup-java@v2.5.0 + uses: actions/setup-java@v3 with: distribution: 'adopt' java-version: ${{ env.JDK_VER }} From 8a65491b1dc70b812df4f8628034fd54008fa17a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 5 Mar 2022 22:04:40 +0530 Subject: [PATCH 07/13] Bump actions/github-script from 5 to 6 (#684) Bumps [actions/github-script](https://github.com/actions/github-script) from 5 to 6. - [Release notes](https://github.com/actions/github-script/releases) - [Commits](https://github.com/actions/github-script/compare/v5...v6) --- updated-dependencies: - dependency-name: actions/github-script dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: Subash Gamage --- .github/workflows/dapr_bot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dapr_bot.yml b/.github/workflows/dapr_bot.yml index 0c2676c7a..4d3130736 100644 --- a/.github/workflows/dapr_bot.yml +++ b/.github/workflows/dapr_bot.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Comment analyzer - uses: actions/github-script@v5 + uses: actions/github-script@v6 with: github-token: ${{secrets.DAPR_BOT_TOKEN}} script: | From c1d9489ffd1fc862513de1782154e88ca5bd628c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Mar 2022 08:57:47 +0530 Subject: [PATCH 08/13] Bump actions/checkout from 2 to 3 (#699) Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: Subash Gamage --- .github/workflows/automerge-bot.yml | 2 +- .github/workflows/build.yml | 8 ++++---- .github/workflows/validate.yml | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/automerge-bot.yml b/.github/workflows/automerge-bot.yml index 70e3c8814..f296eef7f 100644 --- a/.github/workflows/automerge-bot.yml +++ b/.github/workflows/automerge-bot.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install dependencies run: pip install PyGithub - name: Automerge and update diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2782607bf..b6bd1b413 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,7 +31,7 @@ jobs: DAPR_CLI_REF: DAPR_REF: steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up OpenJDK ${{ env.JDK_VER }} uses: actions/setup-java@v3 with: @@ -45,14 +45,14 @@ jobs: with: go-version: ${{ env.GOVER }} - name: Checkout Dapr CLI repo to override dapr command. - uses: actions/checkout@v2 + uses: actions/checkout@v3 if: env.DAPR_CLI_REF != '' with: repository: dapr/cli ref: ${{ env.DAPR_CLI_REF }} path: cli - name: Checkout Dapr repo to override daprd. - uses: actions/checkout@v2 + uses: actions/checkout@v3 if: env.DAPR_REF != '' with: repository: dapr/dapr @@ -123,7 +123,7 @@ jobs: GPG_KEY: ${{ secrets.GPG_KEY }} GPG_PWD: ${{ secrets.GPG_PWD }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up OpenJDK ${{ env.JDK_VER }} uses: actions/setup-java@v3 with: diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index eaccdde06..a11ac3565 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -42,7 +42,7 @@ jobs: DAPR_CLI_REF: DAPR_REF: steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up OpenJDK ${{ env.JDK_VER }} uses: actions/setup-java@v3 with: @@ -56,14 +56,14 @@ jobs: with: go-version: ${{ env.GOVER }} - name: Checkout Dapr CLI repo to override dapr command. - uses: actions/checkout@v2 + uses: actions/checkout@v3 if: env.DAPR_CLI_REF != '' with: repository: dapr/cli ref: ${{ env.DAPR_CLI_REF }} path: cli - name: Checkout Dapr repo to override daprd. - uses: actions/checkout@v2 + uses: actions/checkout@v3 if: env.DAPR_REF != '' with: repository: dapr/dapr From 3226c1c06c50ae8d204652b50f9f56882d730518 Mon Sep 17 00:00:00 2001 From: Subash Gamage Date: Thu, 17 Mar 2022 16:27:04 -0400 Subject: [PATCH 09/13] Making GrpcDaprClient builder restricted to only grpc Signed-off-by: Subash Gamage --- .../io/dapr/client/DaprClientBuilder.java | 2 +- .../client/DaprExtensibleClientBuilder.java | 6 +++++- .../io/dapr/client/DaprClientBuilderTest.java | 19 ++++++++++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/sdk/src/main/java/io/dapr/client/DaprClientBuilder.java b/sdk/src/main/java/io/dapr/client/DaprClientBuilder.java index c18c86011..750aeedae 100644 --- a/sdk/src/main/java/io/dapr/client/DaprClientBuilder.java +++ b/sdk/src/main/java/io/dapr/client/DaprClientBuilder.java @@ -180,7 +180,7 @@ private DaprClient buildDaprClientGrpc() { * * @return DaprClient over HTTP. */ - private DaprClient buildDaprClientHttp() { + protected DaprClient buildDaprClientHttp() { return new DaprClientHttp(this.daprHttpBuilder.build(), this.objectSerializer, this.stateSerializer); } } diff --git a/sdk/src/main/java/io/dapr/client/DaprExtensibleClientBuilder.java b/sdk/src/main/java/io/dapr/client/DaprExtensibleClientBuilder.java index 004cbd87a..f460e2df0 100644 --- a/sdk/src/main/java/io/dapr/client/DaprExtensibleClientBuilder.java +++ b/sdk/src/main/java/io/dapr/client/DaprExtensibleClientBuilder.java @@ -25,5 +25,9 @@ public DaprClientBuilder withManagedGrpcChannel(ManagedChannel channel){ return this; } + @Override + protected DaprClient buildDaprClientHttp() { + throw new UnsupportedOperationException("Http protocol is not supported in this builder."); + } -} + } diff --git a/sdk/src/test/java/io/dapr/client/DaprClientBuilderTest.java b/sdk/src/test/java/io/dapr/client/DaprClientBuilderTest.java index 79461f407..0df67cbb7 100644 --- a/sdk/src/test/java/io/dapr/client/DaprClientBuilderTest.java +++ b/sdk/src/test/java/io/dapr/client/DaprClientBuilderTest.java @@ -13,6 +13,7 @@ package io.dapr.client; +import io.dapr.config.Properties; import io.dapr.serializer.DaprObjectSerializer; import io.grpc.Grpc; import io.grpc.ManagedChannelBuilder; @@ -41,11 +42,27 @@ public void build() { @Test public void testBuilderWithManagedChannel(){ + + System.setProperty(Properties.API_METHOD_INVOCATION_PROTOCOL.getName(), DaprApiProtocol.GRPC.name()); + System.setProperty(Properties.API_PROTOCOL.getName(),DaprApiProtocol.GRPC.name()); + DaprExtensibleClientBuilder daprClientBuilder = new DaprExtensibleClientBuilder(); + ManagedChannelBuilder managedChannelBuilder = Grpc.newChannelBuilder(Properties.SIDECAR_IP.get(), TlsChannelCredentials.create()) + .executor(Executors.newFixedThreadPool(20)); + DaprClient client = daprClientBuilder.withManagedGrpcChannel(managedChannelBuilder.build()).build(); + assertNotNull(client); + System.setProperty(Properties.API_PROTOCOL.getName(),""); + } + + @Test(expected = UnsupportedOperationException.class) + public void testBuilderWithManagedChannelErrorHandling(){ + System.setProperty(Properties.API_METHOD_INVOCATION_PROTOCOL.getName(), DaprApiProtocol.HTTP.name()); + System.setProperty(Properties.API_PROTOCOL.getName(),DaprApiProtocol.HTTP.name()); DaprExtensibleClientBuilder daprClientBuilder = new DaprExtensibleClientBuilder(); - ManagedChannelBuilder managedChannelBuilder = Grpc.newChannelBuilder("localhost:8000", TlsChannelCredentials.create()) + ManagedChannelBuilder managedChannelBuilder = Grpc.newChannelBuilder(Properties.SIDECAR_IP.get(), TlsChannelCredentials.create()) .executor(Executors.newFixedThreadPool(20)); DaprClient client = daprClientBuilder.withManagedGrpcChannel(managedChannelBuilder.build()).build(); assertNotNull(client); + System.setProperty(Properties.API_PROTOCOL.getName(),""); } @Test(expected = IllegalArgumentException.class) From 63b38b6eaed3eb1e7c87bf3001e11161b03c85a5 Mon Sep 17 00:00:00 2001 From: Shubham Sharma Date: Tue, 15 Mar 2022 09:51:11 +0530 Subject: [PATCH 10/13] Add FOSSA workflow and badge (#703) * Add workflow and badge Signed-off-by: Shubham Sharma * Encode space in URL Signed-off-by: Shubham Sharma Signed-off-by: Subash Gamage --- .github/workflows/fossa.yml | 45 +++++++++++++++++++++++++++++++++++++ README.md | 3 ++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/fossa.yml diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml new file mode 100644 index 000000000..9e97442de --- /dev/null +++ b/.github/workflows/fossa.yml @@ -0,0 +1,45 @@ +# +# Copyright 2021 The Dapr Authors +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +name: fossa +on: + push: + branches: + - master + - release-* + tags: + - v* + pull_request: + branches: + - master + - release-* + workflow_dispatch: {} +jobs: + fossa-scan: + runs-on: ubuntu-latest + env: + FOSSA_API_KEY: b88e1f4287c3108c8751bf106fb46db6 # This is a push-only token that is safe to be exposed. + steps: + - name: "Checkout code" + uses: actions/checkout@v2 + + - name: "Run FOSSA Scan" + uses: fossas/fossa-action@main # Use a specific version if locking is preferred + with: + api-key: ${{ env.FOSSA_API_KEY }} + + - name: "Run FOSSA Test" + uses: fossas/fossa-action@main # Use a specific version if locking is preferred + with: + api-key: ${{ env.FOSSA_API_KEY }} + run-tests: true \ No newline at end of file diff --git a/README.md b/README.md index 00935591c..6f2c5dac3 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ [![Build Status](https://github.com/dapr/java-sdk/workflows/Build/badge.svg?event=push&branch=master)](https://github.com/dapr/java-sdk/actions?workflow=Build) [![Discord](https://img.shields.io/discord/778680217417809931)](https://discord.com/channels/778680217417809931/778749797242765342) [![codecov](https://codecov.io/gh/dapr/java-sdk/branch/master/graph/badge.svg)](https://codecov.io/gh/dapr/java-sdk) -[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) +[![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-yellow.svg)](https://opensource.org/licenses/Apache-2.0) +[![FOSSA Status](https://app.fossa.com/api/projects/custom%2B162%2Fgithub.com%2Fdapr%2Fjava-sdk.svg?type=shield)](https://app.fossa.com/projects/custom%2B162%2Fgithub.com%2Fdapr%2Fjava-sdk?ref=badge_shield) [![Maven Central](https://img.shields.io/maven-central/v/io.dapr/dapr-sdk.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22io.dapr%22%20AND%20a:%22dapr-sdk%22) This is the Dapr SDK for Java, including the following features: From c085ca1886d4f14c28b8084067c40a473780a973 Mon Sep 17 00:00:00 2001 From: Shubham Sharma Date: Tue, 15 Mar 2022 15:02:46 +0530 Subject: [PATCH 11/13] Update FOSSA workflow condition to not run on Forks (#706) * Add workflow and badge Signed-off-by: Shubham Sharma * Encode space in URL Signed-off-by: Shubham Sharma * Update FOSSA workflow condition Signed-off-by: Shubham Sharma Signed-off-by: Subash Gamage --- .github/workflows/fossa.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 9e97442de..e1fc57a0b 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -26,6 +26,7 @@ on: workflow_dispatch: {} jobs: fossa-scan: + if: github.repository_owner == 'dapr' # FOSSA is not intended to run on forks. runs-on: ubuntu-latest env: FOSSA_API_KEY: b88e1f4287c3108c8751bf106fb46db6 # This is a push-only token that is safe to be exposed. @@ -42,4 +43,4 @@ jobs: uses: fossas/fossa-action@main # Use a specific version if locking is preferred with: api-key: ${{ env.FOSSA_API_KEY }} - run-tests: true \ No newline at end of file + run-tests: true From 72d8cae99c202f6be67bcd7445fbe5fb070ad3b3 Mon Sep 17 00:00:00 2001 From: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> Date: Tue, 15 Mar 2022 23:29:12 +0530 Subject: [PATCH 12/13] remove deprecated classes (#704) * remove deprecated classes Signed-off-by: Mukundan Sundararajan * remove builder class ref in ITs Signed-off-by: Mukundan Sundararajan * fix setter in IT Signed-off-by: Mukundan Sundararajan Signed-off-by: Subash Gamage --- .../pubsub/http/CloudEventPublisher.java | 1 - .../dapr/examples/tracing/InvokeClient.java | 1 - .../TracingDemoMiddleServiceController.java | 1 - .../java/io/dapr/it/pubsub/http/PubSubIT.java | 7 +- sdk/pom.xml | 3 +- .../domain/DeleteStateRequestBuilder.java | 70 ------------------ ...ExecuteStateTransactionRequestBuilder.java | 56 --------------- .../domain/GetBulkSecretRequestBuilder.java | 50 ------------- .../domain/GetBulkStateRequestBuilder.java | 68 ------------------ .../domain/GetSecretRequestBuilder.java | 53 -------------- .../client/domain/GetStateRequestBuilder.java | 61 ---------------- .../domain/InvokeBindingRequestBuilder.java | 62 ---------------- .../domain/InvokeMethodRequestBuilder.java | 66 ----------------- .../domain/PublishEventRequestBuilder.java | 72 ------------------- .../domain/SaveStateRequestBuilder.java | 56 --------------- .../client/DaprClientGrpcTelemetryTest.java | 1 - .../io/dapr/client/DaprClientGrpcTest.java | 5 -- .../io/dapr/client/DaprClientHttpTest.java | 4 -- 18 files changed, 4 insertions(+), 633 deletions(-) delete mode 100644 sdk/src/main/java/io/dapr/client/domain/DeleteStateRequestBuilder.java delete mode 100644 sdk/src/main/java/io/dapr/client/domain/ExecuteStateTransactionRequestBuilder.java delete mode 100644 sdk/src/main/java/io/dapr/client/domain/GetBulkSecretRequestBuilder.java delete mode 100644 sdk/src/main/java/io/dapr/client/domain/GetBulkStateRequestBuilder.java delete mode 100644 sdk/src/main/java/io/dapr/client/domain/GetSecretRequestBuilder.java delete mode 100644 sdk/src/main/java/io/dapr/client/domain/GetStateRequestBuilder.java delete mode 100644 sdk/src/main/java/io/dapr/client/domain/InvokeBindingRequestBuilder.java delete mode 100644 sdk/src/main/java/io/dapr/client/domain/InvokeMethodRequestBuilder.java delete mode 100644 sdk/src/main/java/io/dapr/client/domain/PublishEventRequestBuilder.java delete mode 100644 sdk/src/main/java/io/dapr/client/domain/SaveStateRequestBuilder.java diff --git a/examples/src/main/java/io/dapr/examples/pubsub/http/CloudEventPublisher.java b/examples/src/main/java/io/dapr/examples/pubsub/http/CloudEventPublisher.java index c5dbf56ef..e75afa0ec 100644 --- a/examples/src/main/java/io/dapr/examples/pubsub/http/CloudEventPublisher.java +++ b/examples/src/main/java/io/dapr/examples/pubsub/http/CloudEventPublisher.java @@ -18,7 +18,6 @@ import io.dapr.client.domain.CloudEvent; import io.dapr.client.domain.Metadata; import io.dapr.client.domain.PublishEventRequest; -import io.dapr.client.domain.PublishEventRequestBuilder; import java.util.UUID; diff --git a/examples/src/main/java/io/dapr/examples/tracing/InvokeClient.java b/examples/src/main/java/io/dapr/examples/tracing/InvokeClient.java index 9a3c9f115..9078fb0d5 100644 --- a/examples/src/main/java/io/dapr/examples/tracing/InvokeClient.java +++ b/examples/src/main/java/io/dapr/examples/tracing/InvokeClient.java @@ -17,7 +17,6 @@ import io.dapr.client.DaprClientBuilder; import io.dapr.client.domain.HttpExtension; import io.dapr.client.domain.InvokeMethodRequest; -import io.dapr.client.domain.InvokeMethodRequestBuilder; import io.dapr.examples.OpenTelemetryConfig; import io.dapr.utils.TypeRef; import io.opentelemetry.api.OpenTelemetry; diff --git a/examples/src/main/java/io/dapr/examples/tracing/TracingDemoMiddleServiceController.java b/examples/src/main/java/io/dapr/examples/tracing/TracingDemoMiddleServiceController.java index d2d4c03cc..9a3111e85 100644 --- a/examples/src/main/java/io/dapr/examples/tracing/TracingDemoMiddleServiceController.java +++ b/examples/src/main/java/io/dapr/examples/tracing/TracingDemoMiddleServiceController.java @@ -16,7 +16,6 @@ import io.dapr.client.DaprClient; import io.dapr.client.domain.HttpExtension; import io.dapr.client.domain.InvokeMethodRequest; -import io.dapr.client.domain.InvokeMethodRequestBuilder; import io.dapr.examples.OpenTelemetryInterceptor; import io.dapr.utils.TypeRef; import io.opentelemetry.context.Context; diff --git a/sdk-tests/src/test/java/io/dapr/it/pubsub/http/PubSubIT.java b/sdk-tests/src/test/java/io/dapr/it/pubsub/http/PubSubIT.java index c4e393972..35e77ce5e 100644 --- a/sdk-tests/src/test/java/io/dapr/it/pubsub/http/PubSubIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/pubsub/http/PubSubIT.java @@ -20,7 +20,7 @@ import io.dapr.client.domain.CloudEvent; import io.dapr.client.domain.HttpExtension; import io.dapr.client.domain.Metadata; -import io.dapr.client.domain.PublishEventRequestBuilder; +import io.dapr.client.domain.PublishEventRequest; import io.dapr.it.BaseIT; import io.dapr.it.DaprRun; import io.dapr.serializer.DaprObjectSerializer; @@ -195,9 +195,8 @@ public String getContentType() { cloudEvent.setDatacontenttype("text/plain"); //Publishing a cloud event. - client.publishEvent(new PublishEventRequestBuilder(PUBSUB_NAME, TOPIC_NAME, cloudEvent) - .withContentType("application/cloudevents+json") - .build()).block(); + client.publishEvent(new PublishEventRequest(PUBSUB_NAME, TOPIC_NAME, cloudEvent) + .setContentType("application/cloudevents+json")).block(); System.out.println("Published one cloud event."); Thread.sleep(3000); diff --git a/sdk/pom.xml b/sdk/pom.xml index 1244351ee..08a9027b3 100644 --- a/sdk/pom.xml +++ b/sdk/pom.xml @@ -167,8 +167,7 @@ LINE COVEREDRATIO - - 79% + 80% diff --git a/sdk/src/main/java/io/dapr/client/domain/DeleteStateRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/DeleteStateRequestBuilder.java deleted file mode 100644 index 0ad17d8d6..000000000 --- a/sdk/src/main/java/io/dapr/client/domain/DeleteStateRequestBuilder.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2021 The Dapr Authors - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and -limitations under the License. -*/ - -package io.dapr.client.domain; - -import java.util.Collections; -import java.util.Map; - -/** - * Builds a request to delete a state by key. - * Deprecated in favor of @see{@link DeleteStateRequest}. - * Deprecated since SDK version 1.3.0, slated for removal in SDK version 1.5.0. - */ -@Deprecated -public class DeleteStateRequestBuilder { - - private final String stateStoreName; - - private final String key; - - private Map metadata; - - private String etag; - - private StateOptions stateOptions; - - public DeleteStateRequestBuilder(String stateStoreName, String key) { - this.stateStoreName = stateStoreName; - this.key = key; - } - - public DeleteStateRequestBuilder withMetadata(Map metadata) { - this.metadata = metadata == null ? null : Collections.unmodifiableMap(metadata); - return this; - } - - public DeleteStateRequestBuilder withEtag(String etag) { - this.etag = etag; - return this; - } - - public DeleteStateRequestBuilder withStateOptions(StateOptions stateOptions) { - this.stateOptions = stateOptions; - return this; - } - - /** - * Builds a request object. - * - * @return Request object. - */ - public DeleteStateRequest build() { - DeleteStateRequest request = new DeleteStateRequest(this.stateStoreName, this.key); - request.setMetadata(metadata); - request.setEtag(this.etag); - request.setStateOptions(this.stateOptions); - return request; - } - -} diff --git a/sdk/src/main/java/io/dapr/client/domain/ExecuteStateTransactionRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/ExecuteStateTransactionRequestBuilder.java deleted file mode 100644 index 6eb04dd7b..000000000 --- a/sdk/src/main/java/io/dapr/client/domain/ExecuteStateTransactionRequestBuilder.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2021 The Dapr Authors - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and -limitations under the License. -*/ - -package io.dapr.client.domain; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * Deprecated in favor of @see{@link ExecuteStateTransactionRequest}. - * Deprecated since SDK version 1.3.0, slated for removal in SDK version 1.5.0. - */ -@Deprecated -public final class ExecuteStateTransactionRequestBuilder { - private final String storeName; - private List> transactionalStates; - private Map metadata; - - public ExecuteStateTransactionRequestBuilder(String storeName) { - this.storeName = storeName; - } - - public ExecuteStateTransactionRequestBuilder withTransactionalStates( - TransactionalStateOperation... transactionalStates) { - this.transactionalStates = Collections.unmodifiableList(Arrays.asList(transactionalStates)); - return this; - } - - public ExecuteStateTransactionRequestBuilder withTransactionalStates( - List> transactionalStates) { - this.transactionalStates = transactionalStates == null ? null : Collections.unmodifiableList(transactionalStates); - return this; - } - - public ExecuteStateTransactionRequestBuilder withMetadata(Map metadata) { - this.metadata = Collections.unmodifiableMap(metadata); - return this; - } - - public ExecuteStateTransactionRequest build() { - return new ExecuteStateTransactionRequest(storeName) - .setMetadata(metadata).setOperations(transactionalStates); - } -} diff --git a/sdk/src/main/java/io/dapr/client/domain/GetBulkSecretRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/GetBulkSecretRequestBuilder.java deleted file mode 100644 index 46325dafe..000000000 --- a/sdk/src/main/java/io/dapr/client/domain/GetBulkSecretRequestBuilder.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2021 The Dapr Authors - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and -limitations under the License. -*/ - -package io.dapr.client.domain; - -import java.util.Collections; -import java.util.Map; - -/** - * Builds a request to fetch all secrets of a secret store. - * Deprecated in favor of @see{@link GetBulkSecretRequest}. - * Deprecated since SDK version 1.3.0, slated for removal in SDK version 1.5.0. - */ -@Deprecated -public class GetBulkSecretRequestBuilder { - - private final String storeName; - - private Map metadata; - - public GetBulkSecretRequestBuilder(String storeName) { - this.storeName = storeName; - } - - public GetBulkSecretRequestBuilder withMetadata(Map metadata) { - this.metadata = metadata == null ? null : Collections.unmodifiableMap(metadata); - return this; - } - - /** - * Builds a request object. - * - * @return Request object. - */ - public GetBulkSecretRequest build() { - GetBulkSecretRequest request = new GetBulkSecretRequest(storeName); - return request.setMetadata(this.metadata); - } - -} diff --git a/sdk/src/main/java/io/dapr/client/domain/GetBulkStateRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/GetBulkStateRequestBuilder.java deleted file mode 100644 index 2a9de3811..000000000 --- a/sdk/src/main/java/io/dapr/client/domain/GetBulkStateRequestBuilder.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2021 The Dapr Authors - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and -limitations under the License. -*/ - -package io.dapr.client.domain; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * Builds a request to request states. - * Deprecated in favor of @see{@link GetBulkStateRequest}. - * Deprecated since SDK version 1.3.0, slated for removal in SDK version 1.5.0. - */ -@Deprecated -public class GetBulkStateRequestBuilder { - - private final String storeName; - - private final List keys; - - private Map metadata; - - private int parallelism = 1; - - public GetBulkStateRequestBuilder(String storeName, List keys) { - this.storeName = storeName; - this.keys = keys == null ? null : Collections.unmodifiableList(keys); - } - - public GetBulkStateRequestBuilder(String storeName, String... keys) { - this.storeName = storeName; - this.keys = keys == null ? null : Collections.unmodifiableList(Arrays.asList(keys)); - } - - public GetBulkStateRequestBuilder withMetadata(Map metadata) { - this.metadata = metadata == null ? null : Collections.unmodifiableMap(metadata); - return this; - } - - public GetBulkStateRequestBuilder withParallelism(int parallelism) { - this.parallelism = parallelism; - return this; - } - - /** - * Builds a request object. - * - * @return Request object. - */ - public GetBulkStateRequest build() { - GetBulkStateRequest request = new GetBulkStateRequest(storeName, keys); - return request.setMetadata(this.metadata) - .setParallelism(this.parallelism); - } - -} diff --git a/sdk/src/main/java/io/dapr/client/domain/GetSecretRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/GetSecretRequestBuilder.java deleted file mode 100644 index f4aec7fe0..000000000 --- a/sdk/src/main/java/io/dapr/client/domain/GetSecretRequestBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2021 The Dapr Authors - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and -limitations under the License. -*/ - -package io.dapr.client.domain; - -import java.util.Collections; -import java.util.Map; - -/** - * Builds a request to publish an event. - * Deprecated in favor of @see{@link GetSecretRequest}. - * Deprecated since SDK version 1.3.0, slated for removal in SDK version 1.5.0 - */ -@Deprecated -public class GetSecretRequestBuilder { - - private final String storeName; - - private final String key; - - private Map metadata; - - public GetSecretRequestBuilder(String storeName, String key) { - this.storeName = storeName; - this.key = key; - } - - public GetSecretRequestBuilder withMetadata(Map metadata) { - this.metadata = metadata == null ? null : Collections.unmodifiableMap(metadata); - return this; - } - - /** - * Builds a request object. - * - * @return Request object. - */ - public GetSecretRequest build() { - GetSecretRequest request = new GetSecretRequest(storeName, key); - return request.setMetadata(this.metadata); - } - -} diff --git a/sdk/src/main/java/io/dapr/client/domain/GetStateRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/GetStateRequestBuilder.java deleted file mode 100644 index 07b017656..000000000 --- a/sdk/src/main/java/io/dapr/client/domain/GetStateRequestBuilder.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2021 The Dapr Authors - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and -limitations under the License. -*/ - -package io.dapr.client.domain; - -import java.util.Collections; -import java.util.Map; - -/** - * Builds a request to request state. - * Deprecated in favor of @see{@link GetStateRequest}. - * Deprecated since SDK version 1.3.0, slated for removal in SDK version 1.5.0 - */ -@Deprecated -public class GetStateRequestBuilder { - - private final String storeName; - - private final String key; - - private Map metadata; - - private StateOptions stateOptions; - - public GetStateRequestBuilder(String storeName, String key) { - this.storeName = storeName; - this.key = key; - } - - public GetStateRequestBuilder withMetadata(Map metadata) { - this.metadata = metadata == null ? null : Collections.unmodifiableMap(metadata); - return this; - } - - public GetStateRequestBuilder withStateOptions(StateOptions stateOptions) { - this.stateOptions = stateOptions; - return this; - } - - /** - * Builds a request object. - * - * @return Request object. - */ - public GetStateRequest build() { - GetStateRequest request = new GetStateRequest(storeName, key); - return request.setMetadata(this.metadata) - .setStateOptions(this.stateOptions); - } - -} diff --git a/sdk/src/main/java/io/dapr/client/domain/InvokeBindingRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/InvokeBindingRequestBuilder.java deleted file mode 100644 index 7b2b5d8cb..000000000 --- a/sdk/src/main/java/io/dapr/client/domain/InvokeBindingRequestBuilder.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2021 The Dapr Authors - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and -limitations under the License. -*/ - -package io.dapr.client.domain; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -/** - * Builds a request to publish an event. - * Deprecated in favor of @see{@link InvokeBindingRequest}. - * Deprecated since SDK version 1.3.0, slated for removal in SDK version 1.5.0 - */ -@Deprecated -public class InvokeBindingRequestBuilder { - - private final String name; - - private final String operation; - - private Object data; - - private Map metadata = new HashMap<>(); - - public InvokeBindingRequestBuilder(String name, String operation) { - this.name = name; - this.operation = operation; - } - - public InvokeBindingRequestBuilder withData(Object data) { - this.data = data; - return this; - } - - public InvokeBindingRequestBuilder withMetadata(Map metadata) { - this.metadata = metadata == null ? null : Collections.unmodifiableMap(metadata); - return this; - } - - /** - * Builds a request object. - * - * @return Request object. - */ - public InvokeBindingRequest build() { - InvokeBindingRequest request = new InvokeBindingRequest(name, operation); - return request.setData(this.data) - .setMetadata(this.metadata); - } - -} diff --git a/sdk/src/main/java/io/dapr/client/domain/InvokeMethodRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/InvokeMethodRequestBuilder.java deleted file mode 100644 index 4586ca93b..000000000 --- a/sdk/src/main/java/io/dapr/client/domain/InvokeMethodRequestBuilder.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2021 The Dapr Authors - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and -limitations under the License. -*/ - -package io.dapr.client.domain; - -/** - * Builds a request to invoke a service. - * Deprecated in favor of @see{@link InvokeMethodRequest}. - * Deprecated since SDK version 1.3.0, slated for removal in SDK version 1.5.0 - */ -@Deprecated -public class InvokeMethodRequestBuilder { - - private final String appId; - - private final String method; - - private String contentType; - - private Object body; - - private HttpExtension httpExtension = HttpExtension.NONE; - - public InvokeMethodRequestBuilder(String appId, String method) { - this.appId = appId; - this.method = method; - } - - public InvokeMethodRequestBuilder withContentType(String contentType) { - this.contentType = contentType; - return this; - } - - public InvokeMethodRequestBuilder withBody(Object body) { - this.body = body; - return this; - } - - public InvokeMethodRequestBuilder withHttpExtension(HttpExtension httpExtension) { - this.httpExtension = httpExtension; - return this; - } - - /** - * Builds a request object. - * - * @return Request object. - */ - public InvokeMethodRequest build() { - InvokeMethodRequest request = new InvokeMethodRequest(appId, method); - return request.setBody(this.body) - .setContentType(contentType) - .setHttpExtension(this.httpExtension); - } - -} diff --git a/sdk/src/main/java/io/dapr/client/domain/PublishEventRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/PublishEventRequestBuilder.java deleted file mode 100644 index 8de53f179..000000000 --- a/sdk/src/main/java/io/dapr/client/domain/PublishEventRequestBuilder.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2021 The Dapr Authors - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and -limitations under the License. -*/ - -package io.dapr.client.domain; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -/** - * Builds a request to publish an event. - * Deprecated in favor of @see{@link PublishEventRequest}. - * Deprecated since SDK version 1.3.0, slated for removal in SDK version 1.5.0 - */ -@Deprecated -public class PublishEventRequestBuilder { - - private final String pubsubName; - - private final String topic; - - private final Object data; - - private String contentType; - - private Map metadata = new HashMap<>(); - - /** - * Instantiates a builder for a publish request. - * - * @param pubsubName Name of the Dapr PubSub. - * @param topic Topic name. - * @param data Data to be published. - */ - public PublishEventRequestBuilder(String pubsubName, String topic, Object data) { - this.pubsubName = pubsubName; - this.topic = topic; - this.data = data; - } - - public PublishEventRequestBuilder withContentType(String contentType) { - this.contentType = contentType; - return this; - } - - public PublishEventRequestBuilder withMetadata(Map metadata) { - this.metadata = metadata == null ? null : Collections.unmodifiableMap(metadata); - return this; - } - - /** - * Builds a request object. - * - * @return Request object. - */ - public PublishEventRequest build() { - PublishEventRequest request = new PublishEventRequest(pubsubName, topic, data); - return request.setContentType(this.contentType) - .setMetadata(this.metadata); - } - -} diff --git a/sdk/src/main/java/io/dapr/client/domain/SaveStateRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/SaveStateRequestBuilder.java deleted file mode 100644 index 26cc79960..000000000 --- a/sdk/src/main/java/io/dapr/client/domain/SaveStateRequestBuilder.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2021 The Dapr Authors - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and -limitations under the License. -*/ - -package io.dapr.client.domain; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -/** - * A request to save states to state store. - * Deprecated in favor of @see{@link SaveStateRequest}. - * Deprecated since SDK version 1.3.0, slated for removal in SDK version 1.5.0 - */ -@Deprecated -public class SaveStateRequestBuilder { - - private final String storeName; - - private List> states = new ArrayList<>(); - - public SaveStateRequestBuilder(String storeName) { - this.storeName = storeName; - } - - public SaveStateRequestBuilder withStates(State... states) { - this.states = Collections.unmodifiableList(Arrays.asList(states)); - return this; - } - - public SaveStateRequestBuilder withStates(List> states) { - this.states = states == null ? null : Collections.unmodifiableList(states); - return this; - } - - /** - * Builds a request object. - * - * @return Request object. - */ - public SaveStateRequest build() { - SaveStateRequest request = new SaveStateRequest(storeName); - return request.setStates(this.states); - } -} diff --git a/sdk/src/test/java/io/dapr/client/DaprClientGrpcTelemetryTest.java b/sdk/src/test/java/io/dapr/client/DaprClientGrpcTelemetryTest.java index 2894bea9c..e323d9b57 100644 --- a/sdk/src/test/java/io/dapr/client/DaprClientGrpcTelemetryTest.java +++ b/sdk/src/test/java/io/dapr/client/DaprClientGrpcTelemetryTest.java @@ -15,7 +15,6 @@ import io.dapr.client.domain.HttpExtension; import io.dapr.client.domain.InvokeMethodRequest; -import io.dapr.client.domain.InvokeMethodRequestBuilder; import io.dapr.serializer.DefaultObjectSerializer; import io.dapr.utils.TypeRef; import io.dapr.v1.CommonProtos; diff --git a/sdk/src/test/java/io/dapr/client/DaprClientGrpcTest.java b/sdk/src/test/java/io/dapr/client/DaprClientGrpcTest.java index 7d3fb3d2b..09c7f159b 100644 --- a/sdk/src/test/java/io/dapr/client/DaprClientGrpcTest.java +++ b/sdk/src/test/java/io/dapr/client/DaprClientGrpcTest.java @@ -17,16 +17,11 @@ import com.google.protobuf.ByteString; import com.google.protobuf.Empty; import io.dapr.client.domain.DeleteStateRequest; -import io.dapr.client.domain.DeleteStateRequestBuilder; import io.dapr.client.domain.ExecuteStateTransactionRequest; -import io.dapr.client.domain.ExecuteStateTransactionRequestBuilder; import io.dapr.client.domain.GetBulkStateRequest; -import io.dapr.client.domain.GetBulkStateRequestBuilder; import io.dapr.client.domain.GetStateRequest; -import io.dapr.client.domain.GetStateRequestBuilder; import io.dapr.client.domain.HttpExtension; import io.dapr.client.domain.PublishEventRequest; -import io.dapr.client.domain.PublishEventRequestBuilder; import io.dapr.client.domain.State; import io.dapr.client.domain.StateOptions; import io.dapr.client.domain.TransactionalStateOperation; diff --git a/sdk/src/test/java/io/dapr/client/DaprClientHttpTest.java b/sdk/src/test/java/io/dapr/client/DaprClientHttpTest.java index afa0a8f4e..0cdf2a82e 100644 --- a/sdk/src/test/java/io/dapr/client/DaprClientHttpTest.java +++ b/sdk/src/test/java/io/dapr/client/DaprClientHttpTest.java @@ -16,15 +16,11 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.dataformat.xml.XmlMapper; import io.dapr.client.domain.DeleteStateRequest; -import io.dapr.client.domain.DeleteStateRequestBuilder; import io.dapr.client.domain.GetBulkStateRequest; -import io.dapr.client.domain.GetBulkStateRequestBuilder; import io.dapr.client.domain.GetStateRequest; -import io.dapr.client.domain.GetStateRequestBuilder; import io.dapr.client.domain.HttpExtension; import io.dapr.client.domain.InvokeMethodRequest; import io.dapr.client.domain.PublishEventRequest; -import io.dapr.client.domain.PublishEventRequestBuilder; import io.dapr.client.domain.State; import io.dapr.client.domain.StateOptions; import io.dapr.client.domain.TransactionalStateOperation; From 5d985b415a50987029b2005f925c10a95d792477 Mon Sep 17 00:00:00 2001 From: Pravin Pushkar Date: Wed, 16 Mar 2022 13:30:48 +0530 Subject: [PATCH 13/13] Adding link for MSFT JDK11 in README.md (#707) Signed-off-by: pravinpushkar Signed-off-by: Subash Gamage --- README.md | 2 +- examples/src/main/java/io/dapr/examples/actors/README.md | 5 ++++- .../src/main/java/io/dapr/examples/bindings/http/README.md | 5 ++++- .../main/java/io/dapr/examples/configuration/grpc/README.md | 5 ++++- examples/src/main/java/io/dapr/examples/exception/README.md | 5 ++++- .../src/main/java/io/dapr/examples/invoke/grpc/README.md | 5 ++++- .../src/main/java/io/dapr/examples/invoke/http/README.md | 5 ++++- .../src/main/java/io/dapr/examples/pubsub/http/README.md | 5 ++++- examples/src/main/java/io/dapr/examples/secrets/README.md | 5 ++++- examples/src/main/java/io/dapr/examples/state/README.md | 5 ++++- examples/src/main/java/io/dapr/examples/tracing/README.md | 5 ++++- .../src/main/java/io/dapr/examples/unittesting/README.md | 5 ++++- 12 files changed, 45 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 6f2c5dac3..d85f0dfd2 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ This is the Dapr SDK for Java, including the following features: #### Pre-Requisites * JDK 11 or above - the published jars are compatible with Java 8: + * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11) * [AdoptOpenJDK 11 - LTS](https://adoptopenjdk.net/) - * [Oracle's JDK 15](https://www.oracle.com/java/technologies/javase-jdk15-downloads.html) * [Oracle's JDK 11 - LTS](https://www.oracle.com/java/technologies/javase-jdk11-downloads.html) * [OpenJDK](https://openjdk.java.net/) * Java IDE installed: diff --git a/examples/src/main/java/io/dapr/examples/actors/README.md b/examples/src/main/java/io/dapr/examples/actors/README.md index ed5d93745..3f9100ff5 100644 --- a/examples/src/main/java/io/dapr/examples/actors/README.md +++ b/examples/src/main/java/io/dapr/examples/actors/README.md @@ -14,7 +14,10 @@ This example contains the follow classes: ## Pre-requisites * [Dapr and Dapr Cli](https://docs.dapr.io/getting-started/install-dapr/). -* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/). +* Java JDK 11 (or greater): + * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11) + * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) + * [OpenJDK 11](https://jdk.java.net/11/) * [Apache Maven](https://maven.apache.org/install.html) version 3.x. ### Checking out the code diff --git a/examples/src/main/java/io/dapr/examples/bindings/http/README.md b/examples/src/main/java/io/dapr/examples/bindings/http/README.md index dcbe5e6ca..b042e3ba8 100644 --- a/examples/src/main/java/io/dapr/examples/bindings/http/README.md +++ b/examples/src/main/java/io/dapr/examples/bindings/http/README.md @@ -18,7 +18,10 @@ Visit [this](https://github.com/dapr/components-contrib/tree/master/bindings) li ## Pre-requisites * [Dapr and Dapr Cli](https://docs.dapr.io/getting-started/install-dapr/). -* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/). +* Java JDK 11 (or greater): + * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11) + * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) + * [OpenJDK 11](https://jdk.java.net/11/) * [Apache Maven](https://maven.apache.org/install.html) version 3.x. ### Checking out the code diff --git a/examples/src/main/java/io/dapr/examples/configuration/grpc/README.md b/examples/src/main/java/io/dapr/examples/configuration/grpc/README.md index b78491204..3785e9f5f 100644 --- a/examples/src/main/java/io/dapr/examples/configuration/grpc/README.md +++ b/examples/src/main/java/io/dapr/examples/configuration/grpc/README.md @@ -12,7 +12,10 @@ The java SDK exposes several methods for this - ## Pre-requisites * [Dapr and Dapr Cli](https://docs.dapr.io/getting-started/install-dapr/). -* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/). +* Java JDK 11 (or greater): + * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11) + * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) + * [OpenJDK 11](https://jdk.java.net/11/) * [Apache Maven](https://maven.apache.org/install.html) version 3.x. ### Checking out the code diff --git a/examples/src/main/java/io/dapr/examples/exception/README.md b/examples/src/main/java/io/dapr/examples/exception/README.md index 50549f613..da6d6d356 100644 --- a/examples/src/main/java/io/dapr/examples/exception/README.md +++ b/examples/src/main/java/io/dapr/examples/exception/README.md @@ -5,7 +5,10 @@ This sample illustrates how to handle exceptions in Dapr. ## Pre-requisites * [Dapr and Dapr Cli](https://docs.dapr.io/getting-started/install-dapr/). -* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/). +* Java JDK 11 (or greater): + * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11) + * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) + * [OpenJDK 11](https://jdk.java.net/11/) * [Apache Maven](https://maven.apache.org/install.html) version 3.x. ### Checking out the code diff --git a/examples/src/main/java/io/dapr/examples/invoke/grpc/README.md b/examples/src/main/java/io/dapr/examples/invoke/grpc/README.md index f1b6ded84..16e632222 100644 --- a/examples/src/main/java/io/dapr/examples/invoke/grpc/README.md +++ b/examples/src/main/java/io/dapr/examples/invoke/grpc/README.md @@ -5,7 +5,10 @@ In this example, you will run a Grpc service and client using Dapr's invoke feat ## Pre-requisites * [Dapr and Dapr Cli](https://docs.dapr.io/getting-started/install-dapr/). -* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/). +* Java JDK 11 (or greater): + * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11) + * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) + * [OpenJDK 11](https://jdk.java.net/11/) * [Apache Maven](https://maven.apache.org/install.html) version 3.x. ### Checking out the code diff --git a/examples/src/main/java/io/dapr/examples/invoke/http/README.md b/examples/src/main/java/io/dapr/examples/invoke/http/README.md index 05df6af21..37af2068f 100644 --- a/examples/src/main/java/io/dapr/examples/invoke/http/README.md +++ b/examples/src/main/java/io/dapr/examples/invoke/http/README.md @@ -15,7 +15,10 @@ This sample uses the Client provided in Dapr Java SDK invoking a remote method. ## Pre-requisites * [Dapr and Dapr CLI](https://docs.dapr.io/getting-started/install-dapr/). -* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/). +* Java JDK 11 (or greater): + * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11) + * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) + * [OpenJDK 11](https://jdk.java.net/11/) * [Apache Maven](https://maven.apache.org/install.html) version 3.x. ### Checking out the code diff --git a/examples/src/main/java/io/dapr/examples/pubsub/http/README.md b/examples/src/main/java/io/dapr/examples/pubsub/http/README.md index 90c6e4885..0d25dee86 100644 --- a/examples/src/main/java/io/dapr/examples/pubsub/http/README.md +++ b/examples/src/main/java/io/dapr/examples/pubsub/http/README.md @@ -10,7 +10,10 @@ This sample uses the HTTP Client provided in Dapr Java SDK for subscribing, and ## Pre-requisites * [Dapr and Dapr Cli](https://docs.dapr.io/getting-started/install-dapr/). -* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/). +* Java JDK 11 (or greater): + * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11) + * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) + * [OpenJDK 11](https://jdk.java.net/11/) * [Apache Maven](https://maven.apache.org/install.html) version 3.x. ### Checking out the code diff --git a/examples/src/main/java/io/dapr/examples/secrets/README.md b/examples/src/main/java/io/dapr/examples/secrets/README.md index 24a1ddb38..ecc07169e 100644 --- a/examples/src/main/java/io/dapr/examples/secrets/README.md +++ b/examples/src/main/java/io/dapr/examples/secrets/README.md @@ -20,7 +20,10 @@ Visit [this](https://github.com/dapr/components-contrib/tree/master/secretstores ## Pre-requisites * [Dapr and Dapr Cli](https://docs.dapr.io/getting-started/install-dapr/). -* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/). +* Java JDK 11 (or greater): + * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11) + * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) + * [OpenJDK 11](https://jdk.java.net/11/) * [Apache Maven](https://maven.apache.org/install.html) version 3.x. * Hashicorp's vault client [installed](https://www.vaultproject.io/docs/install/). diff --git a/examples/src/main/java/io/dapr/examples/state/README.md b/examples/src/main/java/io/dapr/examples/state/README.md index 9af078b75..a002c41a6 100644 --- a/examples/src/main/java/io/dapr/examples/state/README.md +++ b/examples/src/main/java/io/dapr/examples/state/README.md @@ -5,7 +5,10 @@ This sample illustrates the capabilities provided by Dapr Java SDK for state man ## Pre-requisites * [Dapr and Dapr Cli](https://docs.dapr.io/getting-started/install-dapr/). -* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/). +* Java JDK 11 (or greater): + * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11) + * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) + * [OpenJDK 11](https://jdk.java.net/11/) * [Apache Maven](https://maven.apache.org/install.html) version 3.x. ### Checking out the code diff --git a/examples/src/main/java/io/dapr/examples/tracing/README.md b/examples/src/main/java/io/dapr/examples/tracing/README.md index 847e45d62..4294a795a 100644 --- a/examples/src/main/java/io/dapr/examples/tracing/README.md +++ b/examples/src/main/java/io/dapr/examples/tracing/README.md @@ -17,7 +17,10 @@ This sample uses the Client provided in Dapr Java SDK invoking a remote method a ## Pre-requisites * [Dapr and Dapr CLI](https://docs.dapr.io/getting-started/install-dapr/). -* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/). +* Java JDK 11 (or greater): + * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11) + * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) + * [OpenJDK 11](https://jdk.java.net/11/) * [Apache Maven](https://maven.apache.org/install.html) version 3.x. * [Configure Redis](https://docs.dapr.io/getting-started/configure-redis/) as a state store for Dapr. diff --git a/examples/src/main/java/io/dapr/examples/unittesting/README.md b/examples/src/main/java/io/dapr/examples/unittesting/README.md index 5dc89c4d9..cc1073a38 100644 --- a/examples/src/main/java/io/dapr/examples/unittesting/README.md +++ b/examples/src/main/java/io/dapr/examples/unittesting/README.md @@ -5,7 +5,10 @@ This sample illustrates how applications can write unit testing with Dapr's Java ## Pre-requisites * [Dapr and Dapr Cli](https://docs.dapr.io/getting-started/install-dapr/). -* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/). +* Java JDK 11 (or greater): + * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11) + * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) + * [OpenJDK 11](https://jdk.java.net/11/) * [Apache Maven](https://maven.apache.org/install.html) version 3.x. ### Checking out the code