Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Convert Config API to Stable endpoints. #846

Merged
merged 9 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -47,7 +47,7 @@ jobs:
DAPR_RUNTIME_VER: 1.10.6-rc.2
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.10.0/install/install.sh
DAPR_CLI_REF:
DAPR_REF:
DAPR_REF: 1415e23b14628db70adf9403f5a18876f40b6924
steps:
- uses: actions/checkout@v3
- name: Set up OpenJDK ${{ env.JDK_VER }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -41,7 +41,7 @@ jobs:
DAPR_RUNTIME_VER: 1.10.6-rc.2
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.10.0/install/install.sh
DAPR_CLI_REF:
DAPR_REF:
DAPR_REF: 1415e23b14628db70adf9403f5a18876f40b6924
steps:
- uses: actions/checkout@v3
- name: Set up OpenJDK ${{ env.JDK_VER }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -44,8 +45,8 @@ public class ConfigurationClient {
* @throws Exception throws Exception
*/
public static void main(String[] args) throws Exception {
try (DaprPreviewClient client = (new DaprClientBuilder()).buildPreviewClient()) {
System.out.println("Using preview client...");
try (DaprClient client = (new DaprClientBuilder()).build()) {
System.out.println("Using Dapr client...");
getConfigurations(client);
subscribeConfigurationRequest(client);
}
Expand All @@ -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<String> keys = new ArrayList<>();
keys.add("myconfig1");
Expand All @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -134,7 +133,7 @@ Use the following command to run this example-
<!-- STEP
name: Run ConfigurationClient example
expected_stdout_lines:
- "== 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"
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 Dapr client...");
getConfigurations(client);
subscribeConfigurationRequest(client);
}
Expand All @@ -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<String> keys = new ArrayList<>();
keys.add("myconfig1");
Expand All @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -153,7 +153,7 @@ Use the following command to run this example-
<!-- STEP
name: Run ConfigurationClient example
expected_stdout_lines:
- "== 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"
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<grpc.version>1.42.1</grpc.version>
<protobuf.version>3.17.3</protobuf.version>
<dapr.proto.baseurl>https://raw.githubusercontent.com/dapr/dapr/v1.10.0-rc.2/dapr/proto</dapr.proto.baseurl>
<dapr.proto.baseurl>https://raw.githubusercontent.com/dapr/dapr/1415e23b14628db70adf9403f5a18876f40b6924/dapr/proto</dapr.proto.baseurl>
<os-maven-plugin.version>1.6.2</os-maven-plugin.version>
<maven-dependency-plugin.version>3.1.1</maven-dependency-plugin.version>
<maven-antrun-plugin.version>1.8</maven-antrun-plugin.version>
Expand Down Expand Up @@ -65,7 +65,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion sdk-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";

Expand All @@ -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
Expand All @@ -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<String, ConfigurationItem> cis = daprPreviewClient.getConfiguration(CONFIG_STORE_NAME, "myconfigkey1", "myconfigkey2").block();
Map<String, ConfigurationItem> cis = daprClient.getConfiguration(CONFIG_STORE_NAME, "myconfigkey1", "myconfigkey2").block();
assertTrue(cis.size() == 2);
assertTrue(cis.containsKey("myconfigkey1"));
assertTrue(cis.containsKey("myconfigkey2"));
Expand All @@ -94,7 +94,7 @@ public void getConfigurations() {
@Test
public void subscribeConfiguration() {
Runnable subscribeTask = () -> {
Flux<SubscribeConfigurationResponse> outFlux = daprPreviewClient
Flux<SubscribeConfigurationResponse> outFlux = daprClient
.subscribeConfiguration(CONFIG_STORE_NAME, "myconfigkey1", "myconfigkey2");
outFlux.subscribe(update -> {
if (update.getItems().size() == 0 ) {
Expand Down Expand Up @@ -132,7 +132,7 @@ public void unsubscribeConfigurationItems() {
AtomicReference<Disposable> disposableAtomicReference = new AtomicReference<>();
AtomicReference<String> subscriptionId = new AtomicReference<>();
Runnable subscribeTask = () -> {
Flux<SubscribeConfigurationResponse> outFlux = daprPreviewClient
Flux<SubscribeConfigurationResponse> outFlux = daprClient
.subscribeConfiguration(CONFIG_STORE_NAME, "myconfigkey1");
disposableAtomicReference.set(outFlux
.subscribe(update -> {
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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";

Expand All @@ -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
Expand All @@ -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<String, ConfigurationItem> cis = daprPreviewClient.getConfiguration(CONFIG_STORE_NAME, "myconfigkey1", "myconfigkey2").block();
Map<String, ConfigurationItem> cis = daprClient.getConfiguration(CONFIG_STORE_NAME, "myconfigkey1", "myconfigkey2").block();
assertTrue(cis.size() == 2);
assertTrue(cis.containsKey("myconfigkey1"));
assertTrue(cis.containsKey("myconfigkey2"));
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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";

Expand All @@ -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
Expand All @@ -62,14 +62,14 @@ public void setupConfigStore() {
@Test
public void subscribeAndUnsubscribeConfiguration() {
AtomicReference<String> subId= new AtomicReference<>("");
Flux<SubscribeConfigurationResponse> outFlux = daprPreviewClient
Flux<SubscribeConfigurationResponse> 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();
Expand Down
Loading