16
16
import com .google .common .base .Strings ;
17
17
import com .google .protobuf .ByteString ;
18
18
import com .google .protobuf .Empty ;
19
+ import io .dapr .client .domain .AppConnectionPropertiesHealthMetadata ;
20
+ import io .dapr .client .domain .AppConnectionPropertiesMetadata ;
19
21
import io .dapr .client .domain .BulkPublishEntry ;
20
22
import io .dapr .client .domain .BulkPublishRequest ;
21
23
import io .dapr .client .domain .BulkPublishResponse ;
30
32
import io .dapr .client .domain .GetConfigurationRequest ;
31
33
import io .dapr .client .domain .GetSecretRequest ;
32
34
import io .dapr .client .domain .GetStateRequest ;
35
+ import io .dapr .client .domain .HttpEndpointMetadata ;
33
36
import io .dapr .client .domain .HttpExtension ;
34
37
import io .dapr .client .domain .InvokeBindingRequest ;
35
38
import io .dapr .client .domain .InvokeMethodRequest ;
62
65
import io .dapr .v1 .CommonProtos ;
63
66
import io .dapr .v1 .DaprGrpc ;
64
67
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 ;
65
71
import io .dapr .v1 .DaprProtos .PubsubSubscription ;
66
72
import io .dapr .v1 .DaprProtos .PubsubSubscriptionRule ;
67
73
import io .dapr .v1 .DaprProtos .RegisteredComponents ;
@@ -1256,16 +1262,34 @@ public Mono<DaprMetadata> getMetadata() {
1256
1262
});
1257
1263
}
1258
1264
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 ) {
1261
1280
List <RegisteredComponents > registeredComponentsList = response .getRegisteredComponentsList ();
1262
1281
1263
1282
List <ComponentMetadata > components = new ArrayList <>();
1264
1283
for (RegisteredComponents rc : registeredComponentsList ) {
1265
1284
components .add (new ComponentMetadata (rc .getName (), rc .getType (), rc .getVersion ()));
1266
1285
}
1267
1286
1287
+ return components ;
1288
+ }
1289
+
1290
+ private List <SubscriptionMetadata > getSubscriptions (DaprProtos .GetMetadataResponse response ) {
1268
1291
List <PubsubSubscription > subscriptionsList = response .getSubscriptionsList ();
1292
+
1269
1293
List <SubscriptionMetadata > subscriptions = new ArrayList <>();
1270
1294
for (PubsubSubscription s : subscriptionsList ) {
1271
1295
List <PubsubSubscriptionRule > rulesList = s .getRules ().getRulesList ();
@@ -1276,6 +1300,45 @@ private DaprMetadata buildDaprMetadata(
1276
1300
subscriptions .add (new SubscriptionMetadata (s .getTopic (), s .getPubsubName (), s .getDeadLetterTopic (), rules ));
1277
1301
}
1278
1302
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 ;
1280
1315
}
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