Skip to content

Commit 128f5c8

Browse files
authored
Merge branch 'master' into actor_ttl
2 parents 6f382ff + 64f291f commit 128f5c8

File tree

10 files changed

+189
-42
lines changed

10 files changed

+189
-42
lines changed

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

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
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.ActorMetadata;
1920
import io.dapr.client.domain.AppConnectionPropertiesHealthMetadata;
2021
import io.dapr.client.domain.AppConnectionPropertiesMetadata;
2122
import io.dapr.client.domain.BulkPublishEntry;
@@ -65,6 +66,8 @@
6566
import io.dapr.v1.CommonProtos;
6667
import io.dapr.v1.DaprGrpc;
6768
import io.dapr.v1.DaprProtos;
69+
import io.dapr.v1.DaprProtos.ActiveActorsCount;
70+
import io.dapr.v1.DaprProtos.ActorRuntime;
6871
import io.dapr.v1.DaprProtos.AppConnectionHealthProperties;
6972
import io.dapr.v1.DaprProtos.AppConnectionProperties;
7073
import io.dapr.v1.DaprProtos.MetadataHTTPEndpoint;
@@ -1266,22 +1269,35 @@ private DaprMetadata buildDaprMetadata(DaprProtos.GetMetadataResponse response)
12661269
String id = response.getId();
12671270
String runtimeVersion = response.getRuntimeVersion();
12681271
List<String> enabledFeatures = response.getEnabledFeaturesList();
1272+
List<ActorMetadata> actors = getActors(response);
12691273
Map<String, String> attributes = response.getExtendedMetadataMap();
12701274
List<ComponentMetadata> components = getComponents(response);
12711275
List<HttpEndpointMetadata> httpEndpoints = getHttpEndpoints(response);
12721276
List<SubscriptionMetadata> subscriptions = getSubscriptions(response);
12731277
AppConnectionPropertiesMetadata appConnectionProperties = getAppConnectionProperties(response);
12741278

1275-
return new DaprMetadata(id, runtimeVersion, enabledFeatures, attributes, components, httpEndpoints, subscriptions,
1276-
appConnectionProperties);
1279+
return new DaprMetadata(id, runtimeVersion, enabledFeatures, actors, attributes, components, httpEndpoints,
1280+
subscriptions, appConnectionProperties);
1281+
}
1282+
1283+
private List<ActorMetadata> getActors(DaprProtos.GetMetadataResponse response) {
1284+
ActorRuntime actorRuntime = response.getActorRuntime();
1285+
List<ActiveActorsCount> activeActorsList = actorRuntime.getActiveActorsList();
1286+
1287+
List<ActorMetadata> actors = new ArrayList<>();
1288+
for (ActiveActorsCount aac : activeActorsList) {
1289+
actors.add(new ActorMetadata(aac.getType(), aac.getCount()));
1290+
}
1291+
1292+
return actors;
12771293
}
12781294

12791295
private List<ComponentMetadata> getComponents(DaprProtos.GetMetadataResponse response) {
12801296
List<RegisteredComponents> registeredComponentsList = response.getRegisteredComponentsList();
12811297

12821298
List<ComponentMetadata> components = new ArrayList<>();
12831299
for (RegisteredComponents rc : registeredComponentsList) {
1284-
components.add(new ComponentMetadata(rc.getName(), rc.getType(), rc.getVersion()));
1300+
components.add(new ComponentMetadata(rc.getName(), rc.getType(), rc.getVersion(), rc.getCapabilitiesList()));
12851301
}
12861302

12871303
return components;
@@ -1295,9 +1311,10 @@ private List<SubscriptionMetadata> getSubscriptions(DaprProtos.GetMetadataRespon
12951311
List<PubsubSubscriptionRule> rulesList = s.getRules().getRulesList();
12961312
List<RuleMetadata> rules = new ArrayList<>();
12971313
for (PubsubSubscriptionRule r : rulesList) {
1298-
rules.add(new RuleMetadata(r.getPath()));
1314+
rules.add(new RuleMetadata(r.getMatch(), r.getPath()));
12991315
}
1300-
subscriptions.add(new SubscriptionMetadata(s.getTopic(), s.getPubsubName(), s.getDeadLetterTopic(), rules));
1316+
subscriptions.add(new SubscriptionMetadata(s.getPubsubName(), s.getTopic(), s.getMetadataMap(), rules,
1317+
s.getDeadLetterTopic()));
13011318
}
13021319

13031320
return subscriptions;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
/**
17+
* ActorMetadata describes a registered Dapr Actor.
18+
*/
19+
public final class ActorMetadata {
20+
private final String type;
21+
private final int count;
22+
23+
/**
24+
* Constructor for a ActorMetadata.
25+
*
26+
* @param type of the actor
27+
* @param count number of actors of a particular type
28+
*/
29+
public ActorMetadata(String type, int count) {
30+
this.type = type;
31+
this.count = count;
32+
}
33+
34+
public String getType() {
35+
return type;
36+
}
37+
38+
public int getCount() {
39+
return count;
40+
}
41+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
package io.dapr.client.domain;
1515

16+
/**
17+
* AppConnectionPropertiesHealthMetadata describes the application health properties.
18+
*/
1619
public final class AppConnectionPropertiesHealthMetadata {
1720

1821
private final String healthCheckPath;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
package io.dapr.client.domain;
1515

16+
/**
17+
* AppConnectionPropertiesMetadata describes the application connection properties.
18+
*/
1619
public final class AppConnectionPropertiesMetadata {
1720

1821
private final int port;

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,32 @@
1313

1414
package io.dapr.client.domain;
1515

16-
import java.util.Objects;
16+
import java.util.Collections;
17+
import java.util.List;
1718

1819
/**
1920
* ComponentMetadata describes a Dapr Component.
2021
*/
2122
public final class ComponentMetadata {
2223

23-
private String name;
24-
private String type;
25-
private String version;
24+
private final String name;
25+
private final String type;
26+
private final String version;
27+
private final List<String> capabilities;
2628

2729
/**
2830
* Constructor for a ComponentMetadata.
2931
*
3032
* @param name of the component
3133
* @param type component type
3234
* @param version version of the component
35+
* @param capabilities capabilities of the component
3336
*/
34-
public ComponentMetadata(String name, String type, String version) {
37+
public ComponentMetadata(String name, String type, String version, List<String> capabilities) {
3538
this.name = name;
3639
this.type = type;
3740
this.version = version;
41+
this.capabilities = capabilities == null ? Collections.emptyList() : Collections.unmodifiableList(capabilities);
3842
}
3943

4044
public String getName() {
@@ -48,5 +52,9 @@ public String getType() {
4852
public String getVersion() {
4953
return version;
5054
}
51-
55+
56+
public List<String> getCapabilities() {
57+
return capabilities;
58+
}
59+
5260
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public final class DaprMetadata {
2525
private final String id;
2626
private final String runtimeVersion;
2727
private final List<String> enabledFeatures;
28+
private final List<ActorMetadata> actors;
2829
private final Map<String, String> attributes;
2930
private final List<ComponentMetadata> components;
3031
private final List<HttpEndpointMetadata> httpEndpoints;
@@ -37,19 +38,21 @@ public final class DaprMetadata {
3738
* @param id of the application
3839
* @param runtimeVersion Dapr version
3940
* @param enabledFeatures list of enabled features
41+
* @param actors list of registered features
4042
* @param attributes map of extended attributes
4143
* @param components list of registered components
4244
* @param httpEndpoints list of registered http endpoints
4345
* @param subscriptions list of registered subscription
4446
* @param appConnectionProperties connection properties of the application
4547
*/
46-
public DaprMetadata(String id, String runtimeVersion, List<String> enabledFeatures, Map<String, String> attributes,
47-
List<ComponentMetadata> components, List<HttpEndpointMetadata> httpEndpoints,
48+
public DaprMetadata(String id, String runtimeVersion, List<String> enabledFeatures, List<ActorMetadata> actors,
49+
Map<String, String> attributes, List<ComponentMetadata> components, List<HttpEndpointMetadata> httpEndpoints,
4850
List<SubscriptionMetadata> subscriptions, AppConnectionPropertiesMetadata appConnectionProperties) {
4951
this.id = id;
5052
this.runtimeVersion = runtimeVersion;
5153
this.enabledFeatures = enabledFeatures == null ? Collections.emptyList() :
5254
Collections.unmodifiableList(enabledFeatures);
55+
this.actors = actors == null ? Collections.emptyList() : Collections.unmodifiableList(actors);
5356
this.attributes = attributes == null ? Collections.emptyMap() : Collections.unmodifiableMap(attributes);
5457
this.components = components == null ? Collections.emptyList() : Collections.unmodifiableList(components);
5558
this.httpEndpoints = httpEndpoints == null ? Collections.emptyList() : Collections.unmodifiableList(httpEndpoints);
@@ -69,6 +72,10 @@ public List<String> getEnabledFeatures() {
6972
return enabledFeatures;
7073
}
7174

75+
public List<ActorMetadata> getActors() {
76+
return actors;
77+
}
78+
7279
public Map<String, String> getAttributes() {
7380
return attributes;
7481
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
package io.dapr.client.domain;
1515

16+
/**
17+
* HttpEndpointMetadata describes a registered Dapr HTTP endpoint.
18+
*/
1619
public final class HttpEndpointMetadata {
1720

1821
private final String name;

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,25 @@
1717
* RuleMetadata describes the Subscription Rule's Metadata.
1818
*/
1919
public final class RuleMetadata {
20-
private String path;
2120

22-
public RuleMetadata(String path) {
21+
private final String match;
22+
private final String path;
23+
24+
/**
25+
* Constructor for a RuleMetadata.
26+
*
27+
* @param match CEL expression to match the message
28+
* @param path path to route the message
29+
*/
30+
public RuleMetadata(String match, String path) {
31+
this.match = match;
2332
this.path = path;
2433
}
2534

35+
public String getMatch() {
36+
return match;
37+
}
38+
2639
public String getPath() {
2740
return path;
2841
}

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

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,48 +15,55 @@
1515

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

2020
/**
2121
* SubscriptionMetadata describes the Subscription Metadata.
2222
*/
2323
public final class SubscriptionMetadata {
24-
private String topic;
25-
private String pubsubname;
26-
private String deadLetterTopic;
27-
private List<RuleMetadata> rules;
24+
25+
private final String pubsubname;
26+
private final String topic;
27+
private final Map<String, String> metadata;
28+
private final List<RuleMetadata> rules;
29+
private final String deadLetterTopic;
2830

2931
/**
3032
* Constructor for a SubscriptionMetadata.
3133
*
32-
* @param topic of the pubsub component
3334
* @param pubsubname component name
34-
* @param deadLetterTopic dead letter topic
35+
* @param topic of the pubsub component
36+
* @param metadata of the pubsub component
3537
* @param rules subscription path rules
38+
* @param deadLetterTopic dead letter topic
3639
*/
37-
public SubscriptionMetadata(String topic, String pubsubname, String deadLetterTopic, List<RuleMetadata> rules) {
38-
this.topic = topic;
40+
public SubscriptionMetadata(String pubsubname, String topic, Map<String, String> metadata, List<RuleMetadata> rules,
41+
String deadLetterTopic) {
3942
this.pubsubname = pubsubname;
40-
this.deadLetterTopic = deadLetterTopic;
43+
this.topic = topic;
44+
this.metadata = metadata == null ? Collections.emptyMap() : Collections.unmodifiableMap(metadata);
4145
this.rules = rules == null ? Collections.emptyList() : Collections.unmodifiableList(rules);
42-
}
43-
44-
public String getTopic() {
45-
return topic;
46+
this.deadLetterTopic = deadLetterTopic;
4647
}
4748

4849
public String getPubsubname() {
4950
return pubsubname;
5051
}
5152

52-
53-
public String getDeadLetterTopic() {
54-
return deadLetterTopic;
53+
public String getTopic() {
54+
return topic;
5555
}
5656

57+
public Map<String, String> getMetadata() {
58+
return metadata;
59+
}
5760

5861
public List<RuleMetadata> getRules() {
5962
return rules;
6063
}
6164

65+
public String getDeadLetterTopic() {
66+
return deadLetterTopic;
67+
}
68+
6269
}

0 commit comments

Comments
 (0)