Skip to content

Commit 7454272

Browse files
authored
Merge branch 'master' into cherry_pick_1_11
2 parents 51d9b43 + 653ba7e commit 7454272

File tree

6 files changed

+320
-30
lines changed

6 files changed

+320
-30
lines changed

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

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import com.google.common.base.Strings;
1717
import com.google.protobuf.ByteString;
1818
import com.google.protobuf.Empty;
19+
import io.dapr.client.domain.AppConnectionPropertiesHealthMetadata;
20+
import io.dapr.client.domain.AppConnectionPropertiesMetadata;
1921
import io.dapr.client.domain.BulkPublishEntry;
2022
import io.dapr.client.domain.BulkPublishRequest;
2123
import io.dapr.client.domain.BulkPublishResponse;
@@ -30,6 +32,7 @@
3032
import io.dapr.client.domain.GetConfigurationRequest;
3133
import io.dapr.client.domain.GetSecretRequest;
3234
import io.dapr.client.domain.GetStateRequest;
35+
import io.dapr.client.domain.HttpEndpointMetadata;
3336
import io.dapr.client.domain.HttpExtension;
3437
import io.dapr.client.domain.InvokeBindingRequest;
3538
import io.dapr.client.domain.InvokeMethodRequest;
@@ -62,6 +65,9 @@
6265
import io.dapr.v1.CommonProtos;
6366
import io.dapr.v1.DaprGrpc;
6467
import io.dapr.v1.DaprProtos;
68+
import io.dapr.v1.DaprProtos.AppConnectionHealthProperties;
69+
import io.dapr.v1.DaprProtos.AppConnectionProperties;
70+
import io.dapr.v1.DaprProtos.MetadataHTTPEndpoint;
6571
import io.dapr.v1.DaprProtos.PubsubSubscription;
6672
import io.dapr.v1.DaprProtos.PubsubSubscriptionRule;
6773
import io.dapr.v1.DaprProtos.RegisteredComponents;
@@ -1256,16 +1262,34 @@ public Mono<DaprMetadata> getMetadata() {
12561262
});
12571263
}
12581264

1259-
private DaprMetadata buildDaprMetadata(
1260-
DaprProtos.GetMetadataResponse response) throws IOException {
1265+
private DaprMetadata buildDaprMetadata(DaprProtos.GetMetadataResponse response) throws IOException {
1266+
String id = response.getId();
1267+
String runtimeVersion = response.getRuntimeVersion();
1268+
List<String> enabledFeatures = response.getEnabledFeaturesList();
1269+
Map<String, String> attributes = response.getExtendedMetadataMap();
1270+
List<ComponentMetadata> components = getComponents(response);
1271+
List<HttpEndpointMetadata> httpEndpoints = getHttpEndpoints(response);
1272+
List<SubscriptionMetadata> subscriptions = getSubscriptions(response);
1273+
AppConnectionPropertiesMetadata appConnectionProperties = getAppConnectionProperties(response);
1274+
1275+
return new DaprMetadata(id, runtimeVersion, enabledFeatures, attributes, components, httpEndpoints, subscriptions,
1276+
appConnectionProperties);
1277+
}
1278+
1279+
private List<ComponentMetadata> getComponents(DaprProtos.GetMetadataResponse response) {
12611280
List<RegisteredComponents> registeredComponentsList = response.getRegisteredComponentsList();
12621281

12631282
List<ComponentMetadata> components = new ArrayList<>();
12641283
for (RegisteredComponents rc : registeredComponentsList) {
12651284
components.add(new ComponentMetadata(rc.getName(), rc.getType(), rc.getVersion()));
12661285
}
12671286

1287+
return components;
1288+
}
1289+
1290+
private List<SubscriptionMetadata> getSubscriptions(DaprProtos.GetMetadataResponse response) {
12681291
List<PubsubSubscription> subscriptionsList = response.getSubscriptionsList();
1292+
12691293
List<SubscriptionMetadata> subscriptions = new ArrayList<>();
12701294
for (PubsubSubscription s : subscriptionsList) {
12711295
List<PubsubSubscriptionRule> rulesList = s.getRules().getRulesList();
@@ -1276,6 +1300,45 @@ private DaprMetadata buildDaprMetadata(
12761300
subscriptions.add(new SubscriptionMetadata(s.getTopic(), s.getPubsubName(), s.getDeadLetterTopic(), rules));
12771301
}
12781302

1279-
return new DaprMetadata(response.getId(), response.getRuntimeVersion(), components, subscriptions);
1303+
return subscriptions;
1304+
}
1305+
1306+
private List<HttpEndpointMetadata> getHttpEndpoints(DaprProtos.GetMetadataResponse response) {
1307+
List<MetadataHTTPEndpoint> httpEndpointsList = response.getHttpEndpointsList();
1308+
1309+
List<HttpEndpointMetadata> httpEndpoints = new ArrayList<>();
1310+
for (MetadataHTTPEndpoint m : httpEndpointsList) {
1311+
httpEndpoints.add(new HttpEndpointMetadata(m.getName()));
1312+
}
1313+
1314+
return httpEndpoints;
12801315
}
1281-
}
1316+
1317+
private AppConnectionPropertiesMetadata getAppConnectionProperties(DaprProtos.GetMetadataResponse response) {
1318+
AppConnectionProperties appConnectionProperties = response.getAppConnectionProperties();
1319+
int port = appConnectionProperties.getPort();
1320+
String protocol = appConnectionProperties.getProtocol();
1321+
String channelAddress = appConnectionProperties.getChannelAddress();
1322+
int maxConcurrency = appConnectionProperties.getMaxConcurrency();
1323+
AppConnectionPropertiesHealthMetadata health = getAppConnectionPropertiesHealth(appConnectionProperties);
1324+
1325+
return new AppConnectionPropertiesMetadata(port, protocol, channelAddress, maxConcurrency, health);
1326+
}
1327+
1328+
private AppConnectionPropertiesHealthMetadata getAppConnectionPropertiesHealth(
1329+
AppConnectionProperties appConnectionProperties) {
1330+
if (!appConnectionProperties.hasHealth()) {
1331+
return null;
1332+
}
1333+
1334+
AppConnectionHealthProperties health = appConnectionProperties.getHealth();
1335+
String healthCheckPath = health.getHealthCheckPath();
1336+
String healthProbeInterval = health.getHealthProbeInterval();
1337+
String healthProbeTimeout = health.getHealthProbeTimeout();
1338+
int healthThreshold = health.getHealthThreshold();
1339+
1340+
return new AppConnectionPropertiesHealthMetadata(healthCheckPath, healthProbeInterval, healthProbeTimeout,
1341+
healthThreshold);
1342+
}
1343+
1344+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2024 The Dapr Authors
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package io.dapr.client.domain;
15+
16+
public final class AppConnectionPropertiesHealthMetadata {
17+
18+
private final String healthCheckPath;
19+
private final String healthProbeInterval;
20+
private final String healthProbeTimeout;
21+
private final int healthThreshold;
22+
23+
/**
24+
* Constructor for a AppConnectionPropertiesHealthMetadata.
25+
*
26+
* @param healthCheckPath of the application
27+
* @param healthProbeInterval time interval between health probes
28+
* @param healthProbeTimeout timeout for each health probe
29+
* @param healthThreshold max number of failed health probes
30+
*/
31+
public AppConnectionPropertiesHealthMetadata(String healthCheckPath, String healthProbeInterval,
32+
String healthProbeTimeout, int healthThreshold) {
33+
this.healthCheckPath = healthCheckPath;
34+
this.healthProbeInterval = healthProbeInterval;
35+
this.healthProbeTimeout = healthProbeTimeout;
36+
this.healthThreshold = healthThreshold;
37+
}
38+
39+
public String getHealthCheckPath() {
40+
return healthCheckPath;
41+
}
42+
43+
public String getHealthProbeInterval() {
44+
return healthProbeInterval;
45+
}
46+
47+
public String getHealthProbeTimeout() {
48+
return healthProbeTimeout;
49+
}
50+
51+
public int getHealthThreshold() {
52+
return healthThreshold;
53+
}
54+
55+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright 2024 The Dapr Authors
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package io.dapr.client.domain;
15+
16+
public final class AppConnectionPropertiesMetadata {
17+
18+
private final int port;
19+
private final String protocol;
20+
private final String channelAddress;
21+
private final int maxConcurrency;
22+
private final AppConnectionPropertiesHealthMetadata health;
23+
24+
/**
25+
* Constructor for a AppConnectionPropertiesMetadata.
26+
*
27+
* @param port of the application
28+
* @param protocol of the application
29+
* @param channelAddress host address of the application
30+
* @param maxConcurrency number of concurrent requests the app can handle
31+
* @param health health check details of the application
32+
*/
33+
public AppConnectionPropertiesMetadata(int port, String protocol, String channelAddress, int maxConcurrency,
34+
AppConnectionPropertiesHealthMetadata health) {
35+
this.port = port;
36+
this.protocol = protocol;
37+
this.channelAddress = channelAddress;
38+
this.maxConcurrency = maxConcurrency;
39+
this.health = health;
40+
}
41+
42+
public int getPort() {
43+
return port;
44+
}
45+
46+
public String getProtocol() {
47+
return protocol;
48+
}
49+
50+
public String getChannelAddress() {
51+
return channelAddress;
52+
}
53+
54+
public int getMaxConcurrency() {
55+
return maxConcurrency;
56+
}
57+
58+
public AppConnectionPropertiesHealthMetadata getHealth() {
59+
return health;
60+
}
61+
62+
}

sdk/src/main/java/io/dapr/client/domain/DaprMetadata.java

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,46 @@
1515

1616
import java.util.Collections;
1717
import java.util.List;
18-
import java.util.Objects;
18+
import java.util.Map;
1919

2020
/**
2121
* DaprMetadata describes the Dapr Metadata.
2222
*/
2323
public final class DaprMetadata {
2424

25-
private String id;
26-
private String runtimeVersion;
27-
private List<ComponentMetadata> components;
28-
private List<SubscriptionMetadata> subscriptions;
25+
private final String id;
26+
private final String runtimeVersion;
27+
private final List<String> enabledFeatures;
28+
private final Map<String, String> attributes;
29+
private final List<ComponentMetadata> components;
30+
private final List<HttpEndpointMetadata> httpEndpoints;
31+
private final List<SubscriptionMetadata> subscriptions;
32+
private final AppConnectionPropertiesMetadata appConnectionProperties;
2933

3034
/**
3135
* Constructor for a DaprMetadata.
3236
*
3337
* @param id of the application
3438
* @param runtimeVersion Dapr version
35-
* @param components list of registered componnets
39+
* @param enabledFeatures list of enabled features
40+
* @param attributes map of extended attributes
41+
* @param components list of registered components
42+
* @param httpEndpoints list of registered http endpoints
3643
* @param subscriptions list of registered subscription
44+
* @param appConnectionProperties connection properties of the application
3745
*/
38-
public DaprMetadata(String id, String runtimeVersion, List<ComponentMetadata> components,
39-
List<SubscriptionMetadata> subscriptions) {
46+
public DaprMetadata(String id, String runtimeVersion, List<String> enabledFeatures, Map<String, String> attributes,
47+
List<ComponentMetadata> components, List<HttpEndpointMetadata> httpEndpoints,
48+
List<SubscriptionMetadata> subscriptions, AppConnectionPropertiesMetadata appConnectionProperties) {
4049
this.id = id;
4150
this.runtimeVersion = runtimeVersion;
51+
this.enabledFeatures = enabledFeatures == null ? Collections.emptyList() :
52+
Collections.unmodifiableList(enabledFeatures);
53+
this.attributes = attributes == null ? Collections.emptyMap() : Collections.unmodifiableMap(attributes);
4254
this.components = components == null ? Collections.emptyList() : Collections.unmodifiableList(components);
55+
this.httpEndpoints = httpEndpoints == null ? Collections.emptyList() : Collections.unmodifiableList(httpEndpoints);
4356
this.subscriptions = subscriptions == null ? Collections.emptyList() : Collections.unmodifiableList(subscriptions);
57+
this.appConnectionProperties = appConnectionProperties;
4458
}
4559

4660
public String getId() {
@@ -51,12 +65,28 @@ public String getRuntimeVersion() {
5165
return runtimeVersion;
5266
}
5367

68+
public List<String> getEnabledFeatures() {
69+
return enabledFeatures;
70+
}
71+
72+
public Map<String, String> getAttributes() {
73+
return attributes;
74+
}
75+
5476
public List<ComponentMetadata> getComponents() {
5577
return components;
5678
}
5779

80+
public List<HttpEndpointMetadata> getHttpEndpoints() {
81+
return httpEndpoints;
82+
}
83+
5884
public List<SubscriptionMetadata> getSubscriptions() {
5985
return subscriptions;
6086
}
87+
88+
public AppConnectionPropertiesMetadata getAppConnectionProperties() {
89+
return appConnectionProperties;
90+
}
6191

6292
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2024 The Dapr Authors
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package io.dapr.client.domain;
15+
16+
public final class HttpEndpointMetadata {
17+
18+
private final String name;
19+
20+
/**
21+
* Constructor for a HttpEndpointMetadata.
22+
*
23+
* @param name of the HTTP endpoint
24+
*/
25+
public HttpEndpointMetadata(String name) {
26+
this.name = name;
27+
}
28+
29+
public String getName() {
30+
return name;
31+
}
32+
33+
}

0 commit comments

Comments
 (0)