1616import com .google .common .base .Strings ;
1717import com .google .protobuf .ByteString ;
1818import com .google .protobuf .Empty ;
19+ import io .dapr .client .domain .AppConnectionPropertiesHealthMetadata ;
20+ import io .dapr .client .domain .AppConnectionPropertiesMetadata ;
1921import io .dapr .client .domain .BulkPublishEntry ;
2022import io .dapr .client .domain .BulkPublishRequest ;
2123import io .dapr .client .domain .BulkPublishResponse ;
3032import io .dapr .client .domain .GetConfigurationRequest ;
3133import io .dapr .client .domain .GetSecretRequest ;
3234import io .dapr .client .domain .GetStateRequest ;
35+ import io .dapr .client .domain .HttpEndpointMetadata ;
3336import io .dapr .client .domain .HttpExtension ;
3437import io .dapr .client .domain .InvokeBindingRequest ;
3538import io .dapr .client .domain .InvokeMethodRequest ;
6265import io .dapr .v1 .CommonProtos ;
6366import io .dapr .v1 .DaprGrpc ;
6467import 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 ;
6571import io .dapr .v1 .DaprProtos .PubsubSubscription ;
6672import io .dapr .v1 .DaprProtos .PubsubSubscriptionRule ;
6773import 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+ }
0 commit comments