From a4ccfcbd7d6a5b06a47184756e5c5e0e9a6c4a78 Mon Sep 17 00:00:00 2001 From: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> Date: Thu, 20 Apr 2023 07:14:24 +0530 Subject: [PATCH 1/8] Convert Config API to Stable endpoints. Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> --- .../grpc/ConfigurationClient.java | 7 +- .../http/ConfigurationClient.java | 9 +- pom.xml | 4 +- sdk-tests/pom.xml | 2 +- .../grpc/ConfigurationClientIT.java | 18 +- .../configuration/http/ConfigurationIT.java | 12 +- .../http/ConfigurationSubscribeIT.java | 12 +- .../main/java/io/dapr/client/DaprClient.java | 100 +++++++ .../java/io/dapr/client/DaprClientGrpc.java | 10 +- .../java/io/dapr/client/DaprClientHttp.java | 6 +- .../java/io/dapr/client/DaprClientProxy.java | 91 ++++++- .../io/dapr/client/DaprPreviewClient.java | 100 ------- .../io/dapr/client/DaprClientGrpcTest.java | 249 +++++++++++++++++ .../io/dapr/client/DaprClientHttpTest.java | 122 +++++++++ .../client/DaprPreviewClientGrpcTest.java | 252 ------------------ .../client/DaprPreviewClientHttpTest.java | 123 --------- 16 files changed, 601 insertions(+), 516 deletions(-) diff --git a/examples/src/main/java/io/dapr/examples/configuration/grpc/ConfigurationClient.java b/examples/src/main/java/io/dapr/examples/configuration/grpc/ConfigurationClient.java index 69e36b5f2..848a85470 100644 --- a/examples/src/main/java/io/dapr/examples/configuration/grpc/ConfigurationClient.java +++ b/examples/src/main/java/io/dapr/examples/configuration/grpc/ConfigurationClient.java @@ -13,6 +13,7 @@ package io.dapr.examples.configuration.grpc; +import io.dapr.client.DaprClient; import io.dapr.client.DaprClientBuilder; import io.dapr.client.DaprPreviewClient; import io.dapr.client.domain.ConfigurationItem; @@ -44,7 +45,7 @@ public class ConfigurationClient { * @throws Exception throws Exception */ public static void main(String[] args) throws Exception { - try (DaprPreviewClient client = (new DaprClientBuilder()).buildPreviewClient()) { + try (DaprClient client = (new DaprClientBuilder()).build()) { System.out.println("Using preview client..."); getConfigurations(client); subscribeConfigurationRequest(client); @@ -56,7 +57,7 @@ public static void main(String[] args) throws Exception { * * @param client DaprPreviewClient object */ - public static void getConfigurations(DaprPreviewClient client) { + public static void getConfigurations(DaprClient client) { System.out.println("*******trying to retrieve configurations for a list of keys********"); List keys = new ArrayList<>(); keys.add("myconfig1"); @@ -76,7 +77,7 @@ public static void getConfigurations(DaprPreviewClient client) { * * @param client DaprPreviewClient object */ - public static void subscribeConfigurationRequest(DaprPreviewClient client) { + public static void subscribeConfigurationRequest(DaprClient client) { System.out.println("Subscribing to key: myconfig1"); SubscribeConfigurationRequest req = new SubscribeConfigurationRequest( CONFIG_STORE_NAME, Collections.singletonList("myconfig1")); diff --git a/examples/src/main/java/io/dapr/examples/configuration/http/ConfigurationClient.java b/examples/src/main/java/io/dapr/examples/configuration/http/ConfigurationClient.java index 9ad93d625..02e3d7789 100644 --- a/examples/src/main/java/io/dapr/examples/configuration/http/ConfigurationClient.java +++ b/examples/src/main/java/io/dapr/examples/configuration/http/ConfigurationClient.java @@ -14,6 +14,7 @@ package io.dapr.examples.configuration.http; import io.dapr.client.DaprApiProtocol; +import io.dapr.client.DaprClient; import io.dapr.client.DaprClientBuilder; import io.dapr.client.DaprPreviewClient; import io.dapr.client.domain.ConfigurationItem; @@ -42,8 +43,8 @@ public class ConfigurationClient { */ public static void main(String[] args) throws Exception { System.getProperties().setProperty(Properties.API_PROTOCOL.getName(), DaprApiProtocol.HTTP.name()); - try (DaprPreviewClient client = (new DaprClientBuilder()).buildPreviewClient()) { - System.out.println("Using preview client..."); + try (DaprClient client = (new DaprClientBuilder()).build()) { + System.out.println("Using client..."); getConfigurations(client); subscribeConfigurationRequest(client); } @@ -54,7 +55,7 @@ public static void main(String[] args) throws Exception { * * @param client DaprPreviewClient object */ - public static void getConfigurations(DaprPreviewClient client) { + public static void getConfigurations(DaprClient client) { System.out.println("*******trying to retrieve configurations for a list of keys********"); List keys = new ArrayList<>(); keys.add("myconfig1"); @@ -79,7 +80,7 @@ public static void getConfigurations(DaprPreviewClient client) { * * @param client DaprPreviewClient object */ - public static void subscribeConfigurationRequest(DaprPreviewClient client) throws InterruptedException { + public static void subscribeConfigurationRequest(DaprClient client) throws InterruptedException { System.out.println("Subscribing to key: myconfig2"); SubscribeConfigurationRequest req = new SubscribeConfigurationRequest( CONFIG_STORE_NAME, Collections.singletonList("myconfig2")); diff --git a/pom.xml b/pom.xml index af3c27001..2f10e36ed 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ UTF-8 1.42.1 3.17.3 - https://raw.githubusercontent.com/dapr/dapr/v1.10.0-rc.2/dapr/proto + https://raw.githubusercontent.com/dapr/dapr/5e42aeba091b132067e5620692af8fc35dcab07a/dapr/proto 1.6.2 3.1.1 1.8 @@ -65,7 +65,7 @@ junit junit - 4.13.1 + 4.13.2 test diff --git a/sdk-tests/pom.xml b/sdk-tests/pom.xml index 699db1606..f8474e663 100644 --- a/sdk-tests/pom.xml +++ b/sdk-tests/pom.xml @@ -103,7 +103,7 @@ junit junit - 4.13.1 + 4.13.2 test diff --git a/sdk-tests/src/test/java/io/dapr/it/configuration/grpc/ConfigurationClientIT.java b/sdk-tests/src/test/java/io/dapr/it/configuration/grpc/ConfigurationClientIT.java index e64be4103..303f2451e 100644 --- a/sdk-tests/src/test/java/io/dapr/it/configuration/grpc/ConfigurationClientIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/configuration/grpc/ConfigurationClientIT.java @@ -13,8 +13,8 @@ package io.dapr.it.configuration.grpc; +import io.dapr.client.DaprClient; import io.dapr.client.DaprClientBuilder; -import io.dapr.client.DaprPreviewClient; import io.dapr.client.domain.ConfigurationItem; import io.dapr.client.domain.SubscribeConfigurationResponse; import io.dapr.client.domain.UnsubscribeConfigurationResponse; @@ -37,7 +37,7 @@ public class ConfigurationClientIT extends BaseIT { private static DaprRun daprRun; - private static DaprPreviewClient daprPreviewClient; + private static DaprClient daprClient; private static String key = "myconfig1"; @@ -63,12 +63,12 @@ public class ConfigurationClientIT extends BaseIT { public static void init() throws Exception { daprRun = startDaprApp(ConfigurationClientIT.class.getSimpleName(), 5000); daprRun.switchToGRPC(); - daprPreviewClient = new DaprClientBuilder().buildPreviewClient(); + daprClient = new DaprClientBuilder().build(); } @AfterClass public static void tearDown() throws Exception { - daprPreviewClient.close(); + daprClient.close(); } @Before @@ -78,13 +78,13 @@ public void setupConfigStore() { @Test public void getConfiguration() { - ConfigurationItem ci = daprPreviewClient.getConfiguration(CONFIG_STORE_NAME, "myconfigkey1").block(); + ConfigurationItem ci = daprClient.getConfiguration(CONFIG_STORE_NAME, "myconfigkey1").block(); assertEquals(ci.getValue(), "myconfigvalue1"); } @Test public void getConfigurations() { - Map cis = daprPreviewClient.getConfiguration(CONFIG_STORE_NAME, "myconfigkey1", "myconfigkey2").block(); + Map cis = daprClient.getConfiguration(CONFIG_STORE_NAME, "myconfigkey1", "myconfigkey2").block(); assertTrue(cis.size() == 2); assertTrue(cis.containsKey("myconfigkey1")); assertTrue(cis.containsKey("myconfigkey2")); @@ -94,7 +94,7 @@ public void getConfigurations() { @Test public void subscribeConfiguration() { Runnable subscribeTask = () -> { - Flux outFlux = daprPreviewClient + Flux outFlux = daprClient .subscribeConfiguration(CONFIG_STORE_NAME, "myconfigkey1", "myconfigkey2"); outFlux.subscribe(update -> { if (update.getItems().size() == 0 ) { @@ -132,7 +132,7 @@ public void unsubscribeConfigurationItems() { AtomicReference disposableAtomicReference = new AtomicReference<>(); AtomicReference subscriptionId = new AtomicReference<>(); Runnable subscribeTask = () -> { - Flux outFlux = daprPreviewClient + Flux outFlux = daprClient .subscribeConfiguration(CONFIG_STORE_NAME, "myconfigkey1"); disposableAtomicReference.set(outFlux .subscribe(update -> { @@ -163,7 +163,7 @@ public void unsubscribeConfigurationItems() { // To ensure key starts getting updated inducingSleepTime(1000); - UnsubscribeConfigurationResponse res = daprPreviewClient.unsubscribeConfiguration( + UnsubscribeConfigurationResponse res = daprClient.unsubscribeConfiguration( subscriptionId.get(), CONFIG_STORE_NAME ).block(); diff --git a/sdk-tests/src/test/java/io/dapr/it/configuration/http/ConfigurationIT.java b/sdk-tests/src/test/java/io/dapr/it/configuration/http/ConfigurationIT.java index dfd85787a..7b5df1478 100644 --- a/sdk-tests/src/test/java/io/dapr/it/configuration/http/ConfigurationIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/configuration/http/ConfigurationIT.java @@ -1,7 +1,7 @@ package io.dapr.it.configuration.http; +import io.dapr.client.DaprClient; import io.dapr.client.DaprClientBuilder; -import io.dapr.client.DaprPreviewClient; import io.dapr.client.domain.ConfigurationItem; import io.dapr.it.BaseIT; import io.dapr.it.DaprRun; @@ -21,7 +21,7 @@ public class ConfigurationIT extends BaseIT { private static DaprRun daprRun; - private static DaprPreviewClient daprPreviewClient; + private static DaprClient daprClient; private static String key = "myconfig1"; @@ -39,12 +39,12 @@ public class ConfigurationIT extends BaseIT { public static void init() throws Exception { daprRun = startDaprApp(ConfigurationIT.class.getSimpleName(), 5000); daprRun.switchToHTTP(); - daprPreviewClient = new DaprClientBuilder().buildPreviewClient(); + daprClient = new DaprClientBuilder().build(); } @AfterClass public static void tearDown() throws Exception { - daprPreviewClient.close(); + daprClient.close(); } @Before @@ -54,14 +54,14 @@ public void setupConfigStore() { @Test public void getConfiguration() { - ConfigurationItem ci = daprPreviewClient.getConfiguration(CONFIG_STORE_NAME, "myconfigkey1").block(); + ConfigurationItem ci = daprClient.getConfiguration(CONFIG_STORE_NAME, "myconfigkey1").block(); assertEquals(ci.getKey(), "myconfigkey1"); assertEquals(ci.getValue(), "myconfigvalue1"); } @Test public void getConfigurations() { - Map cis = daprPreviewClient.getConfiguration(CONFIG_STORE_NAME, "myconfigkey1", "myconfigkey2").block(); + Map cis = daprClient.getConfiguration(CONFIG_STORE_NAME, "myconfigkey1", "myconfigkey2").block(); assertTrue(cis.size() == 2); assertTrue(cis.containsKey("myconfigkey1")); assertTrue(cis.containsKey("myconfigkey2")); diff --git a/sdk-tests/src/test/java/io/dapr/it/configuration/http/ConfigurationSubscribeIT.java b/sdk-tests/src/test/java/io/dapr/it/configuration/http/ConfigurationSubscribeIT.java index d86dd0660..dcfc362ec 100644 --- a/sdk-tests/src/test/java/io/dapr/it/configuration/http/ConfigurationSubscribeIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/configuration/http/ConfigurationSubscribeIT.java @@ -1,7 +1,7 @@ package io.dapr.it.configuration.http; +import io.dapr.client.DaprClient; import io.dapr.client.DaprClientBuilder; -import io.dapr.client.DaprPreviewClient; import io.dapr.client.domain.SubscribeConfigurationResponse; import io.dapr.client.domain.UnsubscribeConfigurationResponse; import io.dapr.it.BaseIT; @@ -23,7 +23,7 @@ public class ConfigurationSubscribeIT extends BaseIT { private static DaprRun daprRun; - private static DaprPreviewClient daprPreviewClient; + private static DaprClient daprClient; private static String key = "myconfig1"; @@ -46,12 +46,12 @@ public static void init() throws Exception { true, 60000); daprRun.switchToHTTP(); - daprPreviewClient = new DaprClientBuilder().buildPreviewClient(); + daprClient = new DaprClientBuilder().build(); } @AfterClass public static void tearDown() throws Exception { - daprPreviewClient.close(); + daprClient.close(); } @Before @@ -62,14 +62,14 @@ public void setupConfigStore() { @Test public void subscribeAndUnsubscribeConfiguration() { AtomicReference subId= new AtomicReference<>(""); - Flux outFlux = daprPreviewClient + Flux outFlux = daprClient .subscribeConfiguration(CONFIG_STORE_NAME, "myconfigkey1", "myconfigkey2"); outFlux.subscribe(items -> { subId.set(items.getSubscriptionId()); }); assertTrue(subId.get().length() > 0); - UnsubscribeConfigurationResponse res = daprPreviewClient.unsubscribeConfiguration( + UnsubscribeConfigurationResponse res = daprClient.unsubscribeConfiguration( subId.get(), CONFIG_STORE_NAME ).block(); diff --git a/sdk/src/main/java/io/dapr/client/DaprClient.java b/sdk/src/main/java/io/dapr/client/DaprClient.java index 49a998896..f625aee76 100644 --- a/sdk/src/main/java/io/dapr/client/DaprClient.java +++ b/sdk/src/main/java/io/dapr/client/DaprClient.java @@ -13,10 +13,12 @@ package io.dapr.client; +import io.dapr.client.domain.ConfigurationItem; import io.dapr.client.domain.DeleteStateRequest; import io.dapr.client.domain.ExecuteStateTransactionRequest; import io.dapr.client.domain.GetBulkSecretRequest; import io.dapr.client.domain.GetBulkStateRequest; +import io.dapr.client.domain.GetConfigurationRequest; import io.dapr.client.domain.GetSecretRequest; import io.dapr.client.domain.GetStateRequest; import io.dapr.client.domain.HttpExtension; @@ -26,8 +28,13 @@ import io.dapr.client.domain.SaveStateRequest; import io.dapr.client.domain.State; import io.dapr.client.domain.StateOptions; +import io.dapr.client.domain.SubscribeConfigurationRequest; +import io.dapr.client.domain.SubscribeConfigurationResponse; import io.dapr.client.domain.TransactionalStateOperation; +import io.dapr.client.domain.UnsubscribeConfigurationRequest; +import io.dapr.client.domain.UnsubscribeConfigurationResponse; import io.dapr.utils.TypeRef; +import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import java.util.List; @@ -559,6 +566,99 @@ Mono executeStateTransaction(String storeName, */ Mono>> getBulkSecret(GetBulkSecretRequest request); + /** + * Retrieve a configuration based on a provided key. + * + * @param storeName Name of the configuration store + * @param key key of the configuration item which is to be retrieved + * @return Mono of the Configuration Item + */ + Mono getConfiguration(String storeName, String key); + + /** + * Retrieve a configuration based on a provided key. + * + * @param storeName Name of the configuration store + * @param key key of the configuration item which is to be retrieved + * @param metadata optional metadata + * @return Mono of the Configuration Item + */ + Mono getConfiguration(String storeName, String key, Map metadata); + + /** + * Retrieve Map of configurations based on a provided variable number of keys. + * + * @param storeName Name of the configuration store + * @param keys keys of the configurations which are to be retrieved + * @return Mono of Map of ConfigurationItems + */ + Mono> getConfiguration(String storeName, String... keys); + + /** + * Retrieve Map of configurations based on a provided variable number of keys. + * + * @param storeName Name of the configuration store + * @param keys keys of the configurations which are to be retrieved + * @param metadata optional metadata + * @return Mono of Map of ConfigurationItems + */ + Mono> getConfiguration(String storeName, List keys, + Map metadata); + + /** + * Retrieve Map of configurations based on a provided configuration request object. + * + * @param request request for retrieving Configurations for a list keys + * @return Mono of Map of ConfigurationItems + */ + + Mono> getConfiguration(GetConfigurationRequest request); + + /** + * Subscribe to the keys for any change. + * + * @param storeName Name of the configuration store + * @param keys keys of the configurations which are to be subscribed + * @return Flux of {@link SubscribeConfigurationResponse} instance + */ + Flux subscribeConfiguration(String storeName, String... keys); + + /** + * Subscribe to the keys for any change. + * + * @param storeName Name of the configuration store + * @param keys keys of the configurations which are to be subscribed + * @param metadata optional metadata + * @return Flux of {@link SubscribeConfigurationResponse} instance + */ + Flux subscribeConfiguration(String storeName, List keys, + Map metadata); + + /** + * Subscribe to the keys for any change. + * + * @param request request for subscribing to any change for the given keys in request + * @return Flux of {@link SubscribeConfigurationResponse} instance + */ + Flux subscribeConfiguration(SubscribeConfigurationRequest request); + + /** + * Unsubscribe from previously subscribed keys. + * + * @param id subscription id returned by subscribeConfiguration API. + * @param storeName Name of the configuration store. + * @return Mono of {@link UnsubscribeConfigurationResponse} instance. + */ + Mono unsubscribeConfiguration(String id, String storeName); + + /** + * Unsubscribe from previously subscribed keys. + * + * @param request request for unsubscribing to any change for the given subscription id in request + * @return Mono of {@link UnsubscribeConfigurationResponse} instance. + */ + Mono unsubscribeConfiguration(UnsubscribeConfigurationRequest request); + /** * Gracefully shutdown the dapr runtime. * diff --git a/sdk/src/main/java/io/dapr/client/DaprClientGrpc.java b/sdk/src/main/java/io/dapr/client/DaprClientGrpc.java index e038ea4c2..9b795c7d7 100644 --- a/sdk/src/main/java/io/dapr/client/DaprClientGrpc.java +++ b/sdk/src/main/java/io/dapr/client/DaprClientGrpc.java @@ -881,18 +881,18 @@ public Mono> getConfiguration(GetConfigurationReq } DaprProtos.GetConfigurationRequest envelope = builder.build(); - return this.getConfigurationAlpha1(envelope); + return this.getConfiguration(envelope); } catch (Exception ex) { return DaprException.wrapMono(ex); } } - private Mono> getConfigurationAlpha1(DaprProtos.GetConfigurationRequest envelope) { + private Mono> getConfiguration(DaprProtos.GetConfigurationRequest envelope) { return Mono.deferContextual( context -> this.createMono( - it -> intercept(context, asyncStub).getConfigurationAlpha1(envelope, it) + it -> intercept(context, asyncStub).getConfiguration(envelope, it) ) ).map( it -> { @@ -932,7 +932,7 @@ public Flux subscribeConfiguration(SubscribeConf DaprProtos.SubscribeConfigurationRequest envelope = builder.build(); return this.createFlux( - it -> intercept(asyncStub).subscribeConfigurationAlpha1(envelope, it) + it -> intercept(asyncStub).subscribeConfiguration(envelope, it) ).map( it -> { Map configMap = new HashMap<>(); @@ -972,7 +972,7 @@ public Mono unsubscribeConfiguration(Unsubscri DaprProtos.UnsubscribeConfigurationRequest envelope = builder.build(); return this.createMono( - it -> intercept(asyncStub).unsubscribeConfigurationAlpha1(envelope, it) + it -> intercept(asyncStub).unsubscribeConfiguration(envelope, it) ).map( it -> new UnsubscribeConfigurationResponse(it.getOk(), it.getMessage()) ); diff --git a/sdk/src/main/java/io/dapr/client/DaprClientHttp.java b/sdk/src/main/java/io/dapr/client/DaprClientHttp.java index 286dbe8c1..1439699e8 100644 --- a/sdk/src/main/java/io/dapr/client/DaprClientHttp.java +++ b/sdk/src/main/java/io/dapr/client/DaprClientHttp.java @@ -809,7 +809,7 @@ public Mono> getConfiguration(GetConfigurationReq Map> queryArgs = metadataToQueryArgs(metadata); queryParams.putAll(queryArgs); - String[] pathSegments = new String[] {DaprHttp.ALPHA_1_API_VERSION, "configuration", configurationStoreName }; + String[] pathSegments = new String[] {DaprHttp.API_VERSION, "configuration", configurationStoreName }; return Mono.deferContextual( context -> this.client .invokeApi( @@ -870,7 +870,7 @@ public Flux subscribeConfiguration(SubscribeConf queryParams.putAll(queryArgs); String[] pathSegments = - new String[] { DaprHttp.ALPHA_1_API_VERSION, "configuration", configurationStoreName, "subscribe" }; + new String[] { DaprHttp.API_VERSION, "configuration", configurationStoreName, "subscribe" }; SubscribeConfigurationResponse res = Mono.deferContextual( context -> this.client.invokeApi( DaprHttp.HttpMethods.GET.name(), @@ -911,7 +911,7 @@ public Mono unsubscribeConfiguration(Unsubscri } String[] pathSegments = new String[] - { DaprHttp.ALPHA_1_API_VERSION, "configuration", configStoreName, id, "unsubscribe" }; + { DaprHttp.API_VERSION, "configuration", configStoreName, id, "unsubscribe" }; return Mono.deferContextual( context -> this.client diff --git a/sdk/src/main/java/io/dapr/client/DaprClientProxy.java b/sdk/src/main/java/io/dapr/client/DaprClientProxy.java index 114ba132c..370091a96 100644 --- a/sdk/src/main/java/io/dapr/client/DaprClientProxy.java +++ b/sdk/src/main/java/io/dapr/client/DaprClientProxy.java @@ -13,23 +13,28 @@ package io.dapr.client; +import io.dapr.client.domain.ConfigurationItem; import io.dapr.client.domain.DeleteStateRequest; import io.dapr.client.domain.ExecuteStateTransactionRequest; import io.dapr.client.domain.GetBulkSecretRequest; import io.dapr.client.domain.GetBulkStateRequest; +import io.dapr.client.domain.GetConfigurationRequest; import io.dapr.client.domain.GetSecretRequest; import io.dapr.client.domain.GetStateRequest; import io.dapr.client.domain.HttpExtension; import io.dapr.client.domain.InvokeBindingRequest; import io.dapr.client.domain.InvokeMethodRequest; import io.dapr.client.domain.PublishEventRequest; -import io.dapr.client.domain.QueryStateRequest; -import io.dapr.client.domain.QueryStateResponse; import io.dapr.client.domain.SaveStateRequest; import io.dapr.client.domain.State; import io.dapr.client.domain.StateOptions; +import io.dapr.client.domain.SubscribeConfigurationRequest; +import io.dapr.client.domain.SubscribeConfigurationResponse; import io.dapr.client.domain.TransactionalStateOperation; +import io.dapr.client.domain.UnsubscribeConfigurationRequest; +import io.dapr.client.domain.UnsubscribeConfigurationResponse; import io.dapr.utils.TypeRef; +import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import java.util.List; @@ -500,6 +505,88 @@ public Mono>> getBulkSecret(GetBulkSecretRequest return client.getBulkSecret(request); } + /** + * {@inheritDoc} + */ + @Override + public Mono getConfiguration(String storeName, String key) { + return client.getConfiguration(storeName, key); + } + + /** + * {@inheritDoc} + */ + @Override + public Mono getConfiguration(String storeName, String key, Map metadata) { + return client.getConfiguration(storeName, key, metadata); + } + + /** + * {@inheritDoc} + */ + @Override + public Mono> getConfiguration(String storeName, String... keys) { + return client.getConfiguration(storeName, keys); + } + + /** + * {@inheritDoc} + */ + @Override + public Mono> getConfiguration(String storeName, List keys, + Map metadata) { + return client.getConfiguration(storeName, keys, metadata); + } + + /** + * {@inheritDoc} + */ + @Override + public Mono> getConfiguration(GetConfigurationRequest request) { + return client.getConfiguration(request); + } + + /** + * {@inheritDoc} + */ + @Override + public Flux subscribeConfiguration(String storeName, String... keys) { + return client.subscribeConfiguration(storeName, keys); + } + + /** + * {@inheritDoc} + */ + @Override + public Flux subscribeConfiguration(String storeName, List keys, + Map metadata) { + return client.subscribeConfiguration(storeName, keys, metadata); + } + + /** + * {@inheritDoc} + */ + @Override + public Flux subscribeConfiguration(SubscribeConfigurationRequest request) { + return client.subscribeConfiguration(request); + } + + /** + * {@inheritDoc} + */ + @Override + public Mono unsubscribeConfiguration(String id, String storeName) { + return client.unsubscribeConfiguration(id, storeName); + } + + /** + * {@inheritDoc} + */ + @Override + public Mono unsubscribeConfiguration(UnsubscribeConfigurationRequest request) { + return client.unsubscribeConfiguration(request); + } + /** * {@inheritDoc} */ diff --git a/sdk/src/main/java/io/dapr/client/DaprPreviewClient.java b/sdk/src/main/java/io/dapr/client/DaprPreviewClient.java index 271ce6d17..06f470202 100644 --- a/sdk/src/main/java/io/dapr/client/DaprPreviewClient.java +++ b/sdk/src/main/java/io/dapr/client/DaprPreviewClient.java @@ -17,17 +17,10 @@ import io.dapr.client.domain.BulkPublishRequest; import io.dapr.client.domain.BulkPublishResponse; import io.dapr.client.domain.BulkPublishResponseFailedEntry; -import io.dapr.client.domain.ConfigurationItem; -import io.dapr.client.domain.GetConfigurationRequest; import io.dapr.client.domain.QueryStateRequest; import io.dapr.client.domain.QueryStateResponse; -import io.dapr.client.domain.SubscribeConfigurationRequest; -import io.dapr.client.domain.SubscribeConfigurationResponse; -import io.dapr.client.domain.UnsubscribeConfigurationRequest; -import io.dapr.client.domain.UnsubscribeConfigurationResponse; import io.dapr.client.domain.query.Query; import io.dapr.utils.TypeRef; -import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import java.util.List; @@ -40,99 +33,6 @@ */ public interface DaprPreviewClient extends AutoCloseable { - /** - * Retrieve a configuration based on a provided key. - * - * @param storeName Name of the configuration store - * @param key key of the configuration item which is to be retrieved - * @return Mono of the Configuration Item - */ - Mono getConfiguration(String storeName, String key); - - /** - * Retrieve a configuration based on a provided key. - * - * @param storeName Name of the configuration store - * @param key key of the configuration item which is to be retrieved - * @param metadata optional metadata - * @return Mono of the Configuration Item - */ - Mono getConfiguration(String storeName, String key, Map metadata); - - /** - * Retrieve Map of configurations based on a provided variable number of keys. - * - * @param storeName Name of the configuration store - * @param keys keys of the configurations which are to be retrieved - * @return Mono of Map of ConfigurationItems - */ - Mono> getConfiguration(String storeName, String... keys); - - /** - * Retrieve Map of configurations based on a provided variable number of keys. - * - * @param storeName Name of the configuration store - * @param keys keys of the configurations which are to be retrieved - * @param metadata optional metadata - * @return Mono of Map of ConfigurationItems - */ - Mono> getConfiguration(String storeName, List keys, - Map metadata); - - /** - * Retrieve Map of configurations based on a provided configuration request object. - * - * @param request request for retrieving Configurations for a list keys - * @return Mono of Map of ConfigurationItems - */ - - Mono> getConfiguration(GetConfigurationRequest request); - - /** - * Subscribe to the keys for any change. - * - * @param storeName Name of the configuration store - * @param keys keys of the configurations which are to be subscribed - * @return Flux of {@link SubscribeConfigurationResponse} instance - */ - Flux subscribeConfiguration(String storeName, String... keys); - - /** - * Subscribe to the keys for any change. - * - * @param storeName Name of the configuration store - * @param keys keys of the configurations which are to be subscribed - * @param metadata optional metadata - * @return Flux of {@link SubscribeConfigurationResponse} instance - */ - Flux subscribeConfiguration(String storeName, List keys, - Map metadata); - - /** - * Subscribe to the keys for any change. - * - * @param request request for subscribing to any change for the given keys in request - * @return Flux of {@link SubscribeConfigurationResponse} instance - */ - Flux subscribeConfiguration(SubscribeConfigurationRequest request); - - /** - * Subscribe to the keys for any change. - * - * @param id subscription id returned by subscribeConfiguration API. - * @param storeName Name of the configuration store. - * @return Mono of {@link UnsubscribeConfigurationResponse} instance. - */ - Mono unsubscribeConfiguration(String id, String storeName); - - /** - * Subscribe to the keys for any change. - * - * @param request request for unsubscribing to any change for the given subscription id in request - * @return Mono of {@link UnsubscribeConfigurationResponse} instance. - */ - Mono unsubscribeConfiguration(UnsubscribeConfigurationRequest request); - /** * Query for states using a query string. * diff --git a/sdk/src/test/java/io/dapr/client/DaprClientGrpcTest.java b/sdk/src/test/java/io/dapr/client/DaprClientGrpcTest.java index 09c7f159b..434fb6ca2 100644 --- a/sdk/src/test/java/io/dapr/client/DaprClientGrpcTest.java +++ b/sdk/src/test/java/io/dapr/client/DaprClientGrpcTest.java @@ -16,6 +16,7 @@ import com.google.protobuf.Any; import com.google.protobuf.ByteString; import com.google.protobuf.Empty; +import io.dapr.client.domain.ConfigurationItem; import io.dapr.client.domain.DeleteStateRequest; import io.dapr.client.domain.ExecuteStateTransactionRequest; import io.dapr.client.domain.GetBulkStateRequest; @@ -24,7 +25,10 @@ import io.dapr.client.domain.PublishEventRequest; import io.dapr.client.domain.State; import io.dapr.client.domain.StateOptions; +import io.dapr.client.domain.SubscribeConfigurationResponse; import io.dapr.client.domain.TransactionalStateOperation; +import io.dapr.client.domain.UnsubscribeConfigurationRequest; +import io.dapr.client.domain.UnsubscribeConfigurationResponse; import io.dapr.config.Properties; import io.dapr.serializer.DaprObjectSerializer; import io.dapr.serializer.DefaultObjectSerializer; @@ -53,6 +57,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; @@ -82,6 +87,8 @@ public class DaprClientGrpcTest { private static final String STATE_STORE_NAME = "MyStateStore"; + private static final String CONFIG_STORE_NAME = "MyConfigStore"; + private static final String SECRET_STORE_NAME = "MySecretStore"; private Closeable closeable; @@ -2098,6 +2105,248 @@ public void getBulkSecretsWithMetadata() { assertEquals("2", secrets.get("two").get("b")); } + @Test + public void getConfigurationTestErrorScenario() { + assertThrows(IllegalArgumentException.class, () -> { + client.getConfiguration("", "key").block(); + }); + } + + @Test + public void getSingleConfigurationTest() { + doAnswer((Answer) invocation -> { + StreamObserver observer = + (StreamObserver) invocation.getArguments()[1]; + observer.onNext(getSingleMockResponse()); + observer.onCompleted(); + return null; + }).when(daprStub).getConfiguration(any(DaprProtos.GetConfigurationRequest.class), any()); + + ConfigurationItem ci = client.getConfiguration(CONFIG_STORE_NAME, "configkey1").block(); + assertEquals("configvalue1", ci.getValue()); + assertEquals("1", ci.getVersion()); + } + + @Test + public void getSingleConfigurationWithMetadataTest() { + doAnswer((Answer) invocation -> { + StreamObserver observer = + (StreamObserver) invocation.getArguments()[1]; + observer.onNext(getSingleMockResponse()); + observer.onCompleted(); + return null; + }).when(daprStub).getConfiguration(any(DaprProtos.GetConfigurationRequest.class), any()); + + Map reqMetadata = new HashMap<>(); + reqMetadata.put("meta1", "value1"); + ConfigurationItem ci = client.getConfiguration(CONFIG_STORE_NAME, "configkey1", reqMetadata).block(); + assertEquals("configvalue1", ci.getValue()); + assertEquals("1", ci.getVersion()); + } + + @Test + public void getMultipleConfigurationTest() { + doAnswer((Answer) invocation -> { + StreamObserver observer = + (StreamObserver) invocation.getArguments()[1]; + observer.onNext(getMultipleMockResponse()); + observer.onCompleted(); + return null; + }).when(daprStub).getConfiguration(any(DaprProtos.GetConfigurationRequest.class), any()); + + Map cis = client.getConfiguration(CONFIG_STORE_NAME, "configkey1","configkey2").block(); + assertEquals(2, cis.size()); + assertTrue("configkey1", cis.containsKey("configkey1")); + assertEquals("configvalue1", cis.get("configkey1").getValue()); + assertEquals("1", cis.get("configkey1").getVersion()); + assertTrue("configkey2", cis.containsKey("configkey2")); + assertEquals("configvalue2", cis.get("configkey2").getValue()); + assertEquals("1", cis.get("configkey2").getVersion()); + } + + @Test + public void getMultipleConfigurationWithMetadataTest() { + doAnswer((Answer) invocation -> { + StreamObserver observer = + (StreamObserver) invocation.getArguments()[1]; + observer.onNext(getMultipleMockResponse()); + observer.onCompleted(); + return null; + }).when(daprStub).getConfiguration(any(DaprProtos.GetConfigurationRequest.class), any()); + + Map reqMetadata = new HashMap<>(); + reqMetadata.put("meta1", "value1"); + List keys = Arrays.asList("configkey1","configkey2"); + Map cis = client.getConfiguration(CONFIG_STORE_NAME, keys, reqMetadata).block(); + assertEquals(2, cis.size()); + assertTrue("configkey1", cis.containsKey("configkey1")); + assertEquals("configvalue1", cis.get("configkey1").getValue()); + } + + @Test + public void subscribeConfigurationTest() { + Map metadata = new HashMap<>(); + metadata.put("meta1", "value1"); + Map configs = new HashMap<>(); + configs.put("configkey1", CommonProtos.ConfigurationItem.newBuilder() + .setValue("configvalue1") + .setVersion("1") + .putAllMetadata(metadata) + .build()); + DaprProtos.SubscribeConfigurationResponse responseEnvelope = DaprProtos.SubscribeConfigurationResponse.newBuilder() + .putAllItems(configs) + .setId("subscription_id") + .build(); + + doAnswer((Answer) invocation -> { + StreamObserver observer = + (StreamObserver) invocation.getArguments()[1]; + observer.onNext(responseEnvelope); + observer.onCompleted(); + return null; + }).when(daprStub).subscribeConfiguration(any(DaprProtos.SubscribeConfigurationRequest.class), any()); + + Iterator itr = client.subscribeConfiguration(CONFIG_STORE_NAME, "configkey1").toIterable().iterator(); + assertTrue(itr.hasNext()); + SubscribeConfigurationResponse res = itr.next(); + assertTrue(res.getItems().containsKey("configkey1")); + assertEquals("subscription_id", res.getSubscriptionId()); + assertFalse(itr.hasNext()); + } + + @Test + public void subscribeConfigurationTestWithMetadata() { + Map metadata = new HashMap<>(); + metadata.put("meta1", "value1"); + Map configs = new HashMap<>(); + configs.put("configkey1", CommonProtos.ConfigurationItem.newBuilder() + .setValue("configvalue1") + .setVersion("1") + .putAllMetadata(metadata) + .build()); + DaprProtos.SubscribeConfigurationResponse responseEnvelope = DaprProtos.SubscribeConfigurationResponse.newBuilder() + .putAllItems(configs) + .setId("subscription_id") + .build(); + + doAnswer((Answer) invocation -> { + StreamObserver observer = + (StreamObserver) invocation.getArguments()[1]; + observer.onNext(responseEnvelope); + observer.onCompleted(); + return null; + }).when(daprStub).subscribeConfiguration(any(DaprProtos.SubscribeConfigurationRequest.class), any()); + + Map reqMetadata = new HashMap<>(); + List keys = Arrays.asList("configkey1"); + + Iterator itr = client.subscribeConfiguration(CONFIG_STORE_NAME, keys, reqMetadata).toIterable().iterator(); + assertTrue(itr.hasNext()); + SubscribeConfigurationResponse res = itr.next(); + assertTrue(res.getItems().containsKey("configkey1")); + assertEquals("subscription_id", res.getSubscriptionId()); + assertFalse(itr.hasNext()); + } + + @Test + public void subscribeConfigurationWithErrorTest() { + doAnswer((Answer) invocation -> { + StreamObserver observer = + (StreamObserver) invocation.getArguments()[1]; + observer.onError(new RuntimeException()); + observer.onCompleted(); + return null; + }).when(daprStub).subscribeConfiguration(any(DaprProtos.SubscribeConfigurationRequest.class), any()); + + assertThrowsDaprException(ExecutionException.class, () -> { + client.subscribeConfiguration(CONFIG_STORE_NAME, "key").blockFirst(); + }); + + assertThrows(IllegalArgumentException.class, () -> { + client.subscribeConfiguration("", "key").blockFirst(); + }); + } + + @Test + public void unsubscribeConfigurationTest() { + DaprProtos.UnsubscribeConfigurationResponse responseEnvelope = DaprProtos.UnsubscribeConfigurationResponse.newBuilder() + .setOk(true) + .setMessage("unsubscribed_message") + .build(); + + doAnswer((Answer) invocation -> { + StreamObserver observer = + (StreamObserver) invocation.getArguments()[1]; + observer.onNext(responseEnvelope); + observer.onCompleted(); + return null; + }).when(daprStub).unsubscribeConfiguration(any(DaprProtos.UnsubscribeConfigurationRequest.class), any()); + + UnsubscribeConfigurationResponse + response = client.unsubscribeConfiguration("subscription_id", CONFIG_STORE_NAME).block(); + assertTrue(response.getIsUnsubscribed()); + assertEquals("unsubscribed_message", response.getMessage()); + } + + @Test + public void unsubscribeConfigurationTestWithError() { + doAnswer((Answer) invocation -> { + StreamObserver observer = + (StreamObserver) invocation.getArguments()[1]; + observer.onError(new RuntimeException()); + observer.onCompleted(); + return null; + }).when(daprStub).unsubscribeConfiguration(any(DaprProtos.UnsubscribeConfigurationRequest.class), any()); + + assertThrowsDaprException(ExecutionException.class, () -> { + client.unsubscribeConfiguration("subscription_id", CONFIG_STORE_NAME).block(); + }); + + assertThrows(IllegalArgumentException.class, () -> { + client.unsubscribeConfiguration("", CONFIG_STORE_NAME).block(); + }); + + UnsubscribeConfigurationRequest req = new UnsubscribeConfigurationRequest("subscription_id", ""); + assertThrows(IllegalArgumentException.class, () -> { + client.unsubscribeConfiguration(req).block(); + }); + } + + private DaprProtos.GetConfigurationResponse getSingleMockResponse() { + Map metadata = new HashMap<>(); + metadata.put("meta1", "value1"); + Map configs = new HashMap<>(); + configs.put("configkey1", CommonProtos.ConfigurationItem.newBuilder() + .setValue("configvalue1") + .setVersion("1") + .putAllMetadata(metadata) + .build()); + DaprProtos.GetConfigurationResponse responseEnvelope = DaprProtos.GetConfigurationResponse.newBuilder() + .putAllItems(configs) + .build(); + return responseEnvelope; + } + + private DaprProtos.GetConfigurationResponse getMultipleMockResponse() { + Map metadata = new HashMap<>(); + metadata.put("meta1", "value1"); + Map configs = new HashMap<>(); + configs.put("configkey1", CommonProtos.ConfigurationItem.newBuilder() + .setValue("configvalue1") + .setVersion("1") + .putAllMetadata(metadata) + .build()); + configs.put("configkey2", CommonProtos.ConfigurationItem.newBuilder() + .setValue("configvalue2") + .setVersion("1") + .putAllMetadata(metadata) + .build()); + DaprProtos.GetConfigurationResponse responseEnvelope = DaprProtos.GetConfigurationResponse.newBuilder() + .putAllItems(configs) + .build(); + return responseEnvelope; + } + /* If this test is failing, it means that a new value was added to StateOptions.Consistency * enum, without creating a mapping to one of the proto defined gRPC enums */ diff --git a/sdk/src/test/java/io/dapr/client/DaprClientHttpTest.java b/sdk/src/test/java/io/dapr/client/DaprClientHttpTest.java index d5df3de38..9988d6462 100644 --- a/sdk/src/test/java/io/dapr/client/DaprClientHttpTest.java +++ b/sdk/src/test/java/io/dapr/client/DaprClientHttpTest.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.dataformat.xml.XmlMapper; +import io.dapr.client.domain.ConfigurationItem; import io.dapr.client.domain.DeleteStateRequest; import io.dapr.client.domain.GetBulkStateRequest; import io.dapr.client.domain.GetStateRequest; @@ -23,7 +24,10 @@ import io.dapr.client.domain.PublishEventRequest; import io.dapr.client.domain.State; import io.dapr.client.domain.StateOptions; +import io.dapr.client.domain.SubscribeConfigurationResponse; import io.dapr.client.domain.TransactionalStateOperation; +import io.dapr.client.domain.UnsubscribeConfigurationRequest; +import io.dapr.client.domain.UnsubscribeConfigurationResponse; import io.dapr.config.Properties; import io.dapr.exceptions.DaprException; import io.dapr.serializer.DaprObjectSerializer; @@ -51,6 +55,7 @@ import java.util.Base64; import java.util.Collections; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import reactor.util.context.ContextView; @@ -58,6 +63,7 @@ import static io.dapr.utils.TestUtils.assertThrowsDaprException; import static io.dapr.utils.TestUtils.findFreePort; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -68,6 +74,8 @@ public class DaprClientHttpTest { private static final String STATE_STORE_NAME = "MyStateStore"; + private static final String CONFIG_STORE_NAME = "MyConfigStore"; + private static final String SECRET_STORE_NAME = "MySecretStore"; private final String EXPECTED_RESULT = @@ -1304,6 +1312,120 @@ public void getBulkSecretsWithMetadata() { assertEquals("2", secrets.get("two").get("b")); } + @Test + public void getConfigurationTestErrorScenario() { + assertThrows(IllegalArgumentException.class, () -> { + daprClientHttp.getConfiguration("", "key").block(); + }); + assertThrows(IllegalArgumentException.class, () -> { + daprClientHttp.getConfiguration(" ", "key").block(); + }); + } + + @Test + public void getConfigurationTest() { + mockInterceptor.addRule() + .get() + .path("/v1.0/configuration/MyConfigStore") + .param("key","configkey1") + .respond("{\"configkey1\" : {\"value\" : \"configvalue1\",\"version\" : \"1\"}}"); + + ConfigurationItem ci = daprClientHttp.getConfiguration(CONFIG_STORE_NAME, "configkey1").block(); + assertNotNull(ci); + assertEquals("configkey1", ci.getKey()); + assertEquals("configvalue1", ci.getValue()); + assertEquals("1", ci.getVersion()); + } + + @Test + public void getAllConfigurationTest() { + mockInterceptor.addRule() + .get() + .path("/v1.0/configuration/MyConfigStore") + .respond("{\"configkey1\" : {\"value\" : \"configvalue1\",\"version\" : \"1\"}}"); + + ConfigurationItem ci = daprClientHttp.getConfiguration(CONFIG_STORE_NAME, "configkey1").block(); + assertNotNull(ci); + assertEquals("configkey1", ci.getKey()); + assertEquals("configvalue1", ci.getValue()); + assertEquals("1", ci.getVersion()); + } + + @Test + public void subscribeConfigurationTest() { + mockInterceptor.addRule() + .get() + .path("/v1.0/configuration/MyConfigStore/subscribe") + .param("key", "configkey1") + .respond("{\"id\":\"1234\"}"); + + Iterator itr = daprClientHttp.subscribeConfiguration(CONFIG_STORE_NAME, "configkey1").toIterable().iterator(); + assertTrue(itr.hasNext()); + SubscribeConfigurationResponse res = itr.next(); + assertEquals("1234", res.getSubscriptionId()); + assertFalse(itr.hasNext()); + } + + @Test + public void subscribeAllConfigurationTest() { + mockInterceptor.addRule() + .get() + .path("/v1.0/configuration/MyConfigStore/subscribe") + .respond("{\"id\":\"1234\"}"); + + Iterator itr = daprClientHttp.subscribeConfiguration(CONFIG_STORE_NAME, "configkey1").toIterable().iterator(); + assertTrue(itr.hasNext()); + SubscribeConfigurationResponse res = itr.next(); + assertEquals("1234", res.getSubscriptionId()); + assertFalse(itr.hasNext()); + } + + @Test + public void unsubscribeConfigurationTest() { + mockInterceptor.addRule() + .get() + .path("/v1.0/configuration/MyConfigStore/1234/unsubscribe") + .respond("{\"ok\": true}"); + + UnsubscribeConfigurationResponse res = daprClientHttp.unsubscribeConfiguration("1234", CONFIG_STORE_NAME).block(); + assertTrue(res.getIsUnsubscribed()); + } + + @Test + public void unsubscribeConfigurationTestWithError() { + assertThrows(IllegalArgumentException.class, () -> { + daprClientHttp.unsubscribeConfiguration("", CONFIG_STORE_NAME).block(); + }); + + UnsubscribeConfigurationRequest req = new UnsubscribeConfigurationRequest("subscription_id", ""); + assertThrows(IllegalArgumentException.class, () -> { + daprClientHttp.unsubscribeConfiguration(req).block(); + }); + + mockInterceptor.addRule() + .get() + .path("/v1.0/configuration/MyConfigStore/1234/unsubscribe") + .respond("{\"ok\": false, \"message\": \"some error while unsubscribing\"}"); + UnsubscribeConfigurationResponse res = daprClientHttp.unsubscribeConfiguration("1234", CONFIG_STORE_NAME).block(); + assertFalse(res.getIsUnsubscribed()); + } + + @Test + public void subscribeConfigurationTestWithError() { + assertThrows(IllegalArgumentException.class, () -> { + daprClientHttp.subscribeConfiguration("", "key1").blockFirst(); + }); + + mockInterceptor.addRule() + .get() + .path("/v1.0/configuration/MyConfigStore/subscribe") + .param("key", "configkey1") + .respond(500); + assertThrows(DaprException.class, () -> { + daprClientHttp.subscribeConfiguration(CONFIG_STORE_NAME, "configkey1").blockFirst(); + }); + } + @Test public void closeException() { DaprHttp daprHttp = Mockito.mock(DaprHttp.class); diff --git a/sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java b/sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java index d54be7aa0..dcf6051e4 100644 --- a/sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java +++ b/sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java @@ -20,17 +20,12 @@ import io.dapr.client.domain.BulkPublishRequest; import io.dapr.client.domain.BulkPublishEntry; import io.dapr.client.domain.BulkPublishResponse; -import io.dapr.client.domain.ConfigurationItem; import io.dapr.client.domain.QueryStateItem; import io.dapr.client.domain.QueryStateRequest; import io.dapr.client.domain.QueryStateResponse; -import io.dapr.client.domain.SubscribeConfigurationResponse; -import io.dapr.client.domain.UnsubscribeConfigurationRequest; -import io.dapr.client.domain.UnsubscribeConfigurationResponse; import io.dapr.client.domain.query.Query; import io.dapr.serializer.DaprObjectSerializer; import io.dapr.serializer.DefaultObjectSerializer; -import io.dapr.v1.CommonProtos; import io.dapr.v1.DaprGrpc; import io.dapr.v1.DaprProtos; import io.grpc.Status; @@ -47,19 +42,15 @@ import java.io.Closeable; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; import static io.dapr.utils.TestUtils.assertThrowsDaprException; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; @@ -72,7 +63,6 @@ public class DaprPreviewClientGrpcTest { private static final ObjectMapper MAPPER = new ObjectMapper(); - private static final String CONFIG_STORE_NAME = "MyConfigStore"; private static final String QUERY_STORE_NAME = "testQueryStore"; private static final String PUBSUB_NAME = "testPubsub"; @@ -295,248 +285,6 @@ public void publishEventsContentTypeOverrideTest() { Assert.assertEquals("expected no entries to be failed", 0, result.getFailedEntries().size()); } - @Test - public void getConfigurationTestErrorScenario() { - assertThrows(IllegalArgumentException.class, () -> { - previewClient.getConfiguration("", "key").block(); - }); - } - - @Test - public void getSingleConfigurationTest() { - doAnswer((Answer) invocation -> { - StreamObserver observer = - (StreamObserver) invocation.getArguments()[1]; - observer.onNext(getSingleMockResponse()); - observer.onCompleted(); - return null; - }).when(daprStub).getConfigurationAlpha1(any(DaprProtos.GetConfigurationRequest.class), any()); - - ConfigurationItem ci = previewClient.getConfiguration(CONFIG_STORE_NAME, "configkey1").block(); - assertEquals("configvalue1", ci.getValue()); - assertEquals("1", ci.getVersion()); - } - - @Test - public void getSingleConfigurationWithMetadataTest() { - doAnswer((Answer) invocation -> { - StreamObserver observer = - (StreamObserver) invocation.getArguments()[1]; - observer.onNext(getSingleMockResponse()); - observer.onCompleted(); - return null; - }).when(daprStub).getConfigurationAlpha1(any(DaprProtos.GetConfigurationRequest.class), any()); - - Map reqMetadata = new HashMap<>(); - reqMetadata.put("meta1", "value1"); - ConfigurationItem ci = previewClient.getConfiguration(CONFIG_STORE_NAME, "configkey1", reqMetadata).block(); - assertEquals("configvalue1", ci.getValue()); - assertEquals("1", ci.getVersion()); - } - - @Test - public void getMultipleConfigurationTest() { - doAnswer((Answer) invocation -> { - StreamObserver observer = - (StreamObserver) invocation.getArguments()[1]; - observer.onNext(getMultipleMockResponse()); - observer.onCompleted(); - return null; - }).when(daprStub).getConfigurationAlpha1(any(DaprProtos.GetConfigurationRequest.class), any()); - - Map cis = previewClient.getConfiguration(CONFIG_STORE_NAME, "configkey1","configkey2").block(); - assertEquals(2, cis.size()); - assertTrue("configkey1", cis.containsKey("configkey1")); - assertEquals("configvalue1", cis.get("configkey1").getValue()); - assertEquals("1", cis.get("configkey1").getVersion()); - assertTrue("configkey2", cis.containsKey("configkey2")); - assertEquals("configvalue2", cis.get("configkey2").getValue()); - assertEquals("1", cis.get("configkey2").getVersion()); - } - - @Test - public void getMultipleConfigurationWithMetadataTest() { - doAnswer((Answer) invocation -> { - StreamObserver observer = - (StreamObserver) invocation.getArguments()[1]; - observer.onNext(getMultipleMockResponse()); - observer.onCompleted(); - return null; - }).when(daprStub).getConfigurationAlpha1(any(DaprProtos.GetConfigurationRequest.class), any()); - - Map reqMetadata = new HashMap<>(); - reqMetadata.put("meta1", "value1"); - List keys = Arrays.asList("configkey1","configkey2"); - Map cis = previewClient.getConfiguration(CONFIG_STORE_NAME, keys, reqMetadata).block(); - assertEquals(2, cis.size()); - assertTrue("configkey1", cis.containsKey("configkey1")); - assertEquals("configvalue1", cis.get("configkey1").getValue()); - } - - @Test - public void subscribeConfigurationTest() { - Map metadata = new HashMap<>(); - metadata.put("meta1", "value1"); - Map configs = new HashMap<>(); - configs.put("configkey1", CommonProtos.ConfigurationItem.newBuilder() - .setValue("configvalue1") - .setVersion("1") - .putAllMetadata(metadata) - .build()); - DaprProtos.SubscribeConfigurationResponse responseEnvelope = DaprProtos.SubscribeConfigurationResponse.newBuilder() - .putAllItems(configs) - .setId("subscription_id") - .build(); - - doAnswer((Answer) invocation -> { - StreamObserver observer = - (StreamObserver) invocation.getArguments()[1]; - observer.onNext(responseEnvelope); - observer.onCompleted(); - return null; - }).when(daprStub).subscribeConfigurationAlpha1(any(DaprProtos.SubscribeConfigurationRequest.class), any()); - - Iterator itr = previewClient.subscribeConfiguration(CONFIG_STORE_NAME, "configkey1").toIterable().iterator(); - assertTrue(itr.hasNext()); - SubscribeConfigurationResponse res = itr.next(); - assertTrue(res.getItems().containsKey("configkey1")); - assertEquals("subscription_id", res.getSubscriptionId()); - assertFalse(itr.hasNext()); - } - - @Test - public void subscribeConfigurationTestWithMetadata() { - Map metadata = new HashMap<>(); - metadata.put("meta1", "value1"); - Map configs = new HashMap<>(); - configs.put("configkey1", CommonProtos.ConfigurationItem.newBuilder() - .setValue("configvalue1") - .setVersion("1") - .putAllMetadata(metadata) - .build()); - DaprProtos.SubscribeConfigurationResponse responseEnvelope = DaprProtos.SubscribeConfigurationResponse.newBuilder() - .putAllItems(configs) - .setId("subscription_id") - .build(); - - doAnswer((Answer) invocation -> { - StreamObserver observer = - (StreamObserver) invocation.getArguments()[1]; - observer.onNext(responseEnvelope); - observer.onCompleted(); - return null; - }).when(daprStub).subscribeConfigurationAlpha1(any(DaprProtos.SubscribeConfigurationRequest.class), any()); - - Map reqMetadata = new HashMap<>(); - List keys = Arrays.asList("configkey1"); - - Iterator itr = previewClient.subscribeConfiguration(CONFIG_STORE_NAME, keys, reqMetadata).toIterable().iterator(); - assertTrue(itr.hasNext()); - SubscribeConfigurationResponse res = itr.next(); - assertTrue(res.getItems().containsKey("configkey1")); - assertEquals("subscription_id", res.getSubscriptionId()); - assertFalse(itr.hasNext()); - } - - @Test - public void subscribeConfigurationWithErrorTest() { - doAnswer((Answer) invocation -> { - StreamObserver observer = - (StreamObserver) invocation.getArguments()[1]; - observer.onError(new RuntimeException()); - observer.onCompleted(); - return null; - }).when(daprStub).subscribeConfigurationAlpha1(any(DaprProtos.SubscribeConfigurationRequest.class), any()); - - assertThrowsDaprException(ExecutionException.class, () -> { - previewClient.subscribeConfiguration(CONFIG_STORE_NAME, "key").blockFirst(); - }); - - assertThrows(IllegalArgumentException.class, () -> { - previewClient.subscribeConfiguration("", "key").blockFirst(); - }); - } - - @Test - public void unsubscribeConfigurationTest() { - DaprProtos.UnsubscribeConfigurationResponse responseEnvelope = DaprProtos.UnsubscribeConfigurationResponse.newBuilder() - .setOk(true) - .setMessage("unsubscribed_message") - .build(); - - doAnswer((Answer) invocation -> { - StreamObserver observer = - (StreamObserver) invocation.getArguments()[1]; - observer.onNext(responseEnvelope); - observer.onCompleted(); - return null; - }).when(daprStub).unsubscribeConfigurationAlpha1(any(DaprProtos.UnsubscribeConfigurationRequest.class), any()); - - UnsubscribeConfigurationResponse - response = previewClient.unsubscribeConfiguration("subscription_id", CONFIG_STORE_NAME).block(); - assertTrue(response.getIsUnsubscribed()); - assertEquals("unsubscribed_message", response.getMessage()); - } - - @Test - public void unsubscribeConfigurationTestWithError() { - doAnswer((Answer) invocation -> { - StreamObserver observer = - (StreamObserver) invocation.getArguments()[1]; - observer.onError(new RuntimeException()); - observer.onCompleted(); - return null; - }).when(daprStub).unsubscribeConfigurationAlpha1(any(DaprProtos.UnsubscribeConfigurationRequest.class), any()); - - assertThrowsDaprException(ExecutionException.class, () -> { - previewClient.unsubscribeConfiguration("subscription_id", CONFIG_STORE_NAME).block(); - }); - - assertThrows(IllegalArgumentException.class, () -> { - previewClient.unsubscribeConfiguration("", CONFIG_STORE_NAME).block(); - }); - - UnsubscribeConfigurationRequest req = new UnsubscribeConfigurationRequest("subscription_id", ""); - assertThrows(IllegalArgumentException.class, () -> { - previewClient.unsubscribeConfiguration(req).block(); - }); - } - - private DaprProtos.GetConfigurationResponse getSingleMockResponse() { - Map metadata = new HashMap<>(); - metadata.put("meta1", "value1"); - Map configs = new HashMap<>(); - configs.put("configkey1", CommonProtos.ConfigurationItem.newBuilder() - .setValue("configvalue1") - .setVersion("1") - .putAllMetadata(metadata) - .build()); - DaprProtos.GetConfigurationResponse responseEnvelope = DaprProtos.GetConfigurationResponse.newBuilder() - .putAllItems(configs) - .build(); - return responseEnvelope; - } - - private DaprProtos.GetConfigurationResponse getMultipleMockResponse() { - Map metadata = new HashMap<>(); - metadata.put("meta1", "value1"); - Map configs = new HashMap<>(); - configs.put("configkey1", CommonProtos.ConfigurationItem.newBuilder() - .setValue("configvalue1") - .setVersion("1") - .putAllMetadata(metadata) - .build()); - configs.put("configkey2", CommonProtos.ConfigurationItem.newBuilder() - .setValue("configvalue2") - .setVersion("1") - .putAllMetadata(metadata) - .build()); - DaprProtos.GetConfigurationResponse responseEnvelope = DaprProtos.GetConfigurationResponse.newBuilder() - .putAllItems(configs) - .build(); - return responseEnvelope; - } - @Test public void queryStateExceptionsTest() { assertThrows(IllegalArgumentException.class, () -> { diff --git a/sdk/src/test/java/io/dapr/client/DaprPreviewClientHttpTest.java b/sdk/src/test/java/io/dapr/client/DaprPreviewClientHttpTest.java index d34daaf0e..038c32dea 100644 --- a/sdk/src/test/java/io/dapr/client/DaprPreviewClientHttpTest.java +++ b/sdk/src/test/java/io/dapr/client/DaprPreviewClientHttpTest.java @@ -13,15 +13,10 @@ package io.dapr.client; -import io.dapr.client.domain.ConfigurationItem; import io.dapr.client.domain.QueryStateRequest; import io.dapr.client.domain.QueryStateResponse; -import io.dapr.client.domain.SubscribeConfigurationResponse; -import io.dapr.client.domain.UnsubscribeConfigurationRequest; -import io.dapr.client.domain.UnsubscribeConfigurationResponse; import io.dapr.client.domain.query.Query; import io.dapr.config.Properties; -import io.dapr.exceptions.DaprException; import io.dapr.utils.TypeRef; import okhttp3.OkHttpClient; import okhttp3.mock.Behavior; @@ -29,16 +24,12 @@ import org.junit.Before; import org.junit.Test; -import java.util.Iterator; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertThrows; public class DaprPreviewClientHttpTest { - private static final String CONFIG_STORE_NAME = "MyConfigStore"; private DaprPreviewClient daprPreviewClientHttp; @@ -107,118 +98,4 @@ public void queryStateTest() { assertEquals("result must be same", "testData", response.getResults().get(0).getValue()); assertEquals("result must be same", "6f54ad94-dfb9-46f0-a371-e42d550adb7d", response.getResults().get(0).getEtag()); } - - @Test - public void getConfigurationTestErrorScenario() { - assertThrows(IllegalArgumentException.class, () -> { - daprPreviewClientHttp.getConfiguration("", "key").block(); - }); - assertThrows(IllegalArgumentException.class, () -> { - daprPreviewClientHttp.getConfiguration(" ", "key").block(); - }); - } - - @Test - public void getConfigurationTest() { - mockInterceptor.addRule() - .get() - .path("/v1.0-alpha1/configuration/MyConfigStore") - .param("key","configkey1") - .respond("{\"configkey1\" : {\"value\" : \"configvalue1\",\"version\" : \"1\"}}"); - - ConfigurationItem ci = daprPreviewClientHttp.getConfiguration(CONFIG_STORE_NAME, "configkey1").block(); - assertNotNull(ci); - assertEquals("configkey1", ci.getKey()); - assertEquals("configvalue1", ci.getValue()); - assertEquals("1", ci.getVersion()); - } - - @Test - public void getAllConfigurationTest() { - mockInterceptor.addRule() - .get() - .path("/v1.0-alpha1/configuration/MyConfigStore") - .respond("{\"configkey1\" : {\"value\" : \"configvalue1\",\"version\" : \"1\"}}"); - - ConfigurationItem ci = daprPreviewClientHttp.getConfiguration(CONFIG_STORE_NAME, "configkey1").block(); - assertNotNull(ci); - assertEquals("configkey1", ci.getKey()); - assertEquals("configvalue1", ci.getValue()); - assertEquals("1", ci.getVersion()); - } - - @Test - public void subscribeConfigurationTest() { - mockInterceptor.addRule() - .get() - .path("/v1.0-alpha1/configuration/MyConfigStore/subscribe") - .param("key", "configkey1") - .respond("{\"id\":\"1234\"}"); - - Iterator itr = daprPreviewClientHttp.subscribeConfiguration(CONFIG_STORE_NAME, "configkey1").toIterable().iterator(); - assertTrue(itr.hasNext()); - SubscribeConfigurationResponse res = itr.next(); - assertEquals("1234", res.getSubscriptionId()); - assertFalse(itr.hasNext()); - } - - @Test - public void subscribeAllConfigurationTest() { - mockInterceptor.addRule() - .get() - .path("/v1.0-alpha1/configuration/MyConfigStore/subscribe") - .respond("{\"id\":\"1234\"}"); - - Iterator itr = daprPreviewClientHttp.subscribeConfiguration(CONFIG_STORE_NAME, "configkey1").toIterable().iterator(); - assertTrue(itr.hasNext()); - SubscribeConfigurationResponse res = itr.next(); - assertEquals("1234", res.getSubscriptionId()); - assertFalse(itr.hasNext()); - } - - @Test - public void unsubscribeConfigurationTest() { - mockInterceptor.addRule() - .get() - .path("/v1.0-alpha1/configuration/MyConfigStore/1234/unsubscribe") - .respond("{\"ok\": true}"); - - UnsubscribeConfigurationResponse res = daprPreviewClientHttp.unsubscribeConfiguration("1234", CONFIG_STORE_NAME).block(); - assertTrue(res.getIsUnsubscribed()); - } - - @Test - public void unsubscribeConfigurationTestWithError() { - assertThrows(IllegalArgumentException.class, () -> { - daprPreviewClientHttp.unsubscribeConfiguration("", CONFIG_STORE_NAME).block(); - }); - - UnsubscribeConfigurationRequest req = new UnsubscribeConfigurationRequest("subscription_id", ""); - assertThrows(IllegalArgumentException.class, () -> { - daprPreviewClientHttp.unsubscribeConfiguration(req).block(); - }); - - mockInterceptor.addRule() - .get() - .path("/v1.0-alpha1/configuration/MyConfigStore/1234/unsubscribe") - .respond("{\"ok\": false, \"message\": \"some error while unsubscribing\"}"); - UnsubscribeConfigurationResponse res = daprPreviewClientHttp.unsubscribeConfiguration("1234", CONFIG_STORE_NAME).block(); - assertFalse(res.getIsUnsubscribed()); - } - - @Test - public void subscribeConfigurationTestWithError() { - assertThrows(IllegalArgumentException.class, () -> { - daprPreviewClientHttp.subscribeConfiguration("", "key1").blockFirst(); - }); - - mockInterceptor.addRule() - .get() - .path("/v1.0-alpha1/configuration/MyConfigStore/subscribe") - .param("key", "configkey1") - .respond(500); - assertThrows(DaprException.class, () -> { - daprPreviewClientHttp.subscribeConfiguration(CONFIG_STORE_NAME, "configkey1").blockFirst(); - }); - } } From dd91e65f7352b41b55886a4497cbeed36f1d611e Mon Sep 17 00:00:00 2001 From: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> Date: Thu, 20 Apr 2023 07:16:59 +0530 Subject: [PATCH 2/8] Fix dapr build and validate ref. Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- .github/workflows/validate.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 187b36142..dc5eee3c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,7 +47,7 @@ jobs: DAPR_RUNTIME_VER: 1.10.0 DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.10.0/install/install.sh DAPR_CLI_REF: - DAPR_REF: + DAPR_REF: 5e42aeba091b132067e5620692af8fc35dcab07a steps: - uses: actions/checkout@v3 - name: Set up OpenJDK ${{ env.JDK_VER }} diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 447716cf6..5d7bb748f 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -41,7 +41,7 @@ jobs: DAPR_RUNTIME_VER: 1.10.0 DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.10.0/install/install.sh DAPR_CLI_REF: - DAPR_REF: + DAPR_REF: 5e42aeba091b132067e5620692af8fc35dcab07a steps: - uses: actions/checkout@v3 - name: Set up OpenJDK ${{ env.JDK_VER }} From a6f610d998286e18418b9fab52228a528d4cb13f Mon Sep 17 00:00:00 2001 From: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> Date: Thu, 20 Apr 2023 07:19:14 +0530 Subject: [PATCH 3/8] Fix GH workflow Golang version. Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- .github/workflows/validate.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dc5eee3c5..e9ea04248 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,7 +38,7 @@ jobs: spring-boot-version: 2.3.6.RELEASE experimental: false env: - GOVER: 1.19 + GOVER: 1.20 GOOS: linux GOARCH: amd64 GOPROXY: https://proxy.golang.org diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 5d7bb748f..90e0c606f 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -32,7 +32,7 @@ jobs: matrix: java: [ 11, 13, 15, 16 ] env: - GOVER: 1.19 + GOVER: 1.20 GOOS: linux GOARCH: amd64 GOPROXY: https://proxy.golang.org From a122c74b4bf899bf31e47a27102dff278e1e482e Mon Sep 17 00:00:00 2001 From: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> Date: Thu, 20 Apr 2023 07:21:01 +0530 Subject: [PATCH 4/8] Fix GH workflow Golang version. Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- .github/workflows/validate.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e9ea04248..9412b021d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,7 +38,7 @@ jobs: spring-boot-version: 2.3.6.RELEASE experimental: false env: - GOVER: 1.20 + GOVER: "1.20" GOOS: linux GOARCH: amd64 GOPROXY: https://proxy.golang.org diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 90e0c606f..55e9b78e4 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -32,7 +32,7 @@ jobs: matrix: java: [ 11, 13, 15, 16 ] env: - GOVER: 1.20 + GOVER: "1.20" GOOS: linux GOARCH: amd64 GOPROXY: https://proxy.golang.org From de8d85c1f530fb9deef44bc4e4122c0b2025f281 Mon Sep 17 00:00:00 2001 From: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> Date: Fri, 21 Apr 2023 15:40:23 +0530 Subject: [PATCH 5/8] fix config client example Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> --- .../examples/configuration/grpc/ConfigurationClient.java | 2 +- .../main/java/io/dapr/examples/configuration/grpc/README.md | 5 ++--- .../examples/configuration/http/ConfigurationClient.java | 2 +- .../main/java/io/dapr/examples/configuration/http/README.md | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/src/main/java/io/dapr/examples/configuration/grpc/ConfigurationClient.java b/examples/src/main/java/io/dapr/examples/configuration/grpc/ConfigurationClient.java index 848a85470..14648e030 100644 --- a/examples/src/main/java/io/dapr/examples/configuration/grpc/ConfigurationClient.java +++ b/examples/src/main/java/io/dapr/examples/configuration/grpc/ConfigurationClient.java @@ -46,7 +46,7 @@ public class ConfigurationClient { */ public static void main(String[] args) throws Exception { try (DaprClient client = (new DaprClientBuilder()).build()) { - System.out.println("Using preview client..."); + System.out.println("Using Dapr client..."); getConfigurations(client); subscribeConfigurationRequest(client); } 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 832f65871..f10e412fd 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 @@ -1,7 +1,6 @@ ## Retrieve Configurations via Configuration API This example provides the different capabilities provided by Dapr Java SDK for Configuration. For further information about Configuration APIs please refer to [this link](https://docs.dapr.io/developing-applications/building-blocks/configuration/) -**This API is available in Preview Mode**. ### Using the ConfigurationAPI @@ -63,7 +62,7 @@ public class ConfigurationClient { */ public static void main(String[] args) throws Exception { try (DaprPreviewClient client = (new DaprClientBuilder()).buildPreviewClient()) { - System.out.println("Using preview client..."); + System.out.println("Using Dapr client..."); getConfigurations(client); subscribeConfigurationRequestWithSubscribe(client); unsubscribeConfigurationItems(client); @@ -155,7 +154,7 @@ dapr run --components-path ./components/configuration --app-id configgrpc --log- ### Sample output ``` -== APP == Using preview client... +== APP == Using Dapr client... == APP == *******trying to retrieve configurations for a list of keys******** == APP == val1 : key ->myconfig1 == APP == val2 : key ->myconfig2 diff --git a/examples/src/main/java/io/dapr/examples/configuration/http/ConfigurationClient.java b/examples/src/main/java/io/dapr/examples/configuration/http/ConfigurationClient.java index 02e3d7789..08e2a830e 100644 --- a/examples/src/main/java/io/dapr/examples/configuration/http/ConfigurationClient.java +++ b/examples/src/main/java/io/dapr/examples/configuration/http/ConfigurationClient.java @@ -44,7 +44,7 @@ public class ConfigurationClient { public static void main(String[] args) throws Exception { System.getProperties().setProperty(Properties.API_PROTOCOL.getName(), DaprApiProtocol.HTTP.name()); try (DaprClient client = (new DaprClientBuilder()).build()) { - System.out.println("Using client..."); + System.out.println("Using Dapr client..."); getConfigurations(client); subscribeConfigurationRequest(client); } diff --git a/examples/src/main/java/io/dapr/examples/configuration/http/README.md b/examples/src/main/java/io/dapr/examples/configuration/http/README.md index edb0107a1..e2a4388aa 100644 --- a/examples/src/main/java/io/dapr/examples/configuration/http/README.md +++ b/examples/src/main/java/io/dapr/examples/configuration/http/README.md @@ -64,7 +64,7 @@ public class ConfigurationClient { public static void main(String[] args) throws Exception { System.getProperties().setProperty(Properties.API_PROTOCOL.getName(), DaprApiProtocol.HTTP.name()); try (DaprPreviewClient client = (new DaprClientBuilder()).buildPreviewClient()) { - System.out.println("Using preview client..."); + System.out.println("Using Dapr client..."); getConfigurations(client); subscribeConfigurationRequest(client); } @@ -184,7 +184,7 @@ docker exec dapr_redis redis-cli MSET myconfig2 "updated_val2||1" ### Sample output ``` -== APP == Using preview client... +== APP == Using Dapr client... == APP == *******trying to retrieve configurations for a list of keys******** == APP == val1 : key ->myconfig1 == APP == val2 : key ->myconfig2 From bf40449f26221c65e3abac607ce13fffc9f2005f Mon Sep 17 00:00:00 2001 From: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> Date: Fri, 21 Apr 2023 16:21:32 +0530 Subject: [PATCH 6/8] fix config api validation output Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> --- .../src/main/java/io/dapr/examples/configuration/grpc/README.md | 2 +- .../src/main/java/io/dapr/examples/configuration/http/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 f10e412fd..e30d8c887 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 @@ -133,7 +133,7 @@ Use the following command to run this example-