41
41
import static io .dapr .config .Properties .GRPC_KEEP_ALIVE_TIMEOUT_SECONDS ;
42
42
import static io .dapr .config .Properties .GRPC_KEEP_ALIVE_TIME_SECONDS ;
43
43
import static io .dapr .config .Properties .GRPC_KEEP_ALIVE_WITHOUT_CALLS ;
44
+ import static io .dapr .config .Properties .GRPC_MAX_INBOUND_MESSAGE_SIZE_BYTES ;
45
+ import static io .dapr .config .Properties .GRPC_MAX_INBOUND_METADATA_SIZE_BYTES ;
44
46
import static io .dapr .config .Properties .GRPC_PORT ;
45
47
import static io .dapr .config .Properties .GRPC_TLS_CA_PATH ;
46
48
import static io .dapr .config .Properties .GRPC_TLS_CERT_PATH ;
47
49
import static io .dapr .config .Properties .GRPC_TLS_INSECURE ;
48
50
import static io .dapr .config .Properties .GRPC_TLS_KEY_PATH ;
49
51
import static io .dapr .config .Properties .SIDECAR_IP ;
50
52
53
+
51
54
/**
52
55
* Utility methods for network, internal to Dapr SDK.
53
56
*/
@@ -152,7 +155,9 @@ public static ManagedChannel buildGrpcManagedChannel(Properties properties, Clie
152
155
.keepAliveTimeout (settings .keepAliveTimeoutSeconds .toSeconds (), TimeUnit .SECONDS )
153
156
.keepAliveWithoutCalls (settings .keepAliveWithoutCalls );
154
157
}
155
-
158
+
159
+ builder .maxInboundMessageSize (settings .maxInboundMessageSize );
160
+ builder .maxInboundMetadataSize (settings .maxInboundMetadataSize );
156
161
return builder .build ();
157
162
} catch (Exception e ) {
158
163
throw new DaprException (
@@ -233,10 +238,13 @@ static final class GrpcEndpointSettings {
233
238
final Duration keepAliveTimeoutSeconds ;
234
239
final boolean keepAliveWithoutCalls ;
235
240
241
+ final int maxInboundMessageSize ;
242
+ final int maxInboundMetadataSize ;
243
+
236
244
private GrpcEndpointSettings (
237
245
String endpoint , boolean secure , String tlsPrivateKeyPath , String tlsCertPath , String tlsCaPath ,
238
246
boolean enableKeepAlive , Duration keepAliveTimeSeconds , Duration keepAliveTimeoutSeconds ,
239
- boolean keepAliveWithoutCalls ) {
247
+ boolean keepAliveWithoutCalls , int maxInboundMessageSize , int maxInboundMetadataSize ) {
240
248
this .endpoint = endpoint ;
241
249
this .secure = secure ;
242
250
this .tlsPrivateKeyPath = tlsPrivateKeyPath ;
@@ -246,6 +254,8 @@ private GrpcEndpointSettings(
246
254
this .keepAliveTimeSeconds = keepAliveTimeSeconds ;
247
255
this .keepAliveTimeoutSeconds = keepAliveTimeoutSeconds ;
248
256
this .keepAliveWithoutCalls = keepAliveWithoutCalls ;
257
+ this .maxInboundMessageSize = maxInboundMessageSize ;
258
+ this .maxInboundMetadataSize = maxInboundMetadataSize ;
249
259
}
250
260
251
261
static GrpcEndpointSettings parse (Properties properties ) {
@@ -258,6 +268,8 @@ static GrpcEndpointSettings parse(Properties properties) {
258
268
Duration keepAliveTimeSeconds = properties .getValue (GRPC_KEEP_ALIVE_TIME_SECONDS );
259
269
Duration keepAliveTimeoutSeconds = properties .getValue (GRPC_KEEP_ALIVE_TIMEOUT_SECONDS );
260
270
boolean keepAliveWithoutCalls = properties .getValue (GRPC_KEEP_ALIVE_WITHOUT_CALLS );
271
+ int maxInboundMessageSizeBytes = properties .getValue (GRPC_MAX_INBOUND_MESSAGE_SIZE_BYTES );
272
+ int maxInboundMetadataSizeBytes = properties .getValue (GRPC_MAX_INBOUND_METADATA_SIZE_BYTES );
261
273
262
274
boolean secure = false ;
263
275
String grpcEndpoint = properties .getValue (GRPC_ENDPOINT );
@@ -301,27 +313,30 @@ static GrpcEndpointSettings parse(Properties properties) {
301
313
address ,
302
314
port ),
303
315
secure , clientKeyPath , clientCertPath , caCertPath , enablekeepAlive , keepAliveTimeSeconds ,
304
- keepAliveTimeoutSeconds , keepAliveWithoutCalls );
316
+ keepAliveTimeoutSeconds , keepAliveWithoutCalls , maxInboundMessageSizeBytes , maxInboundMetadataSizeBytes );
305
317
}
306
318
307
319
var socket = matcher .group ("socket" );
308
320
if (socket != null ) {
309
321
return new GrpcEndpointSettings (socket , secure , clientKeyPath , clientCertPath , caCertPath , enablekeepAlive ,
310
- keepAliveTimeSeconds , keepAliveTimeoutSeconds , keepAliveWithoutCalls );
322
+ keepAliveTimeSeconds , keepAliveTimeoutSeconds , keepAliveWithoutCalls ,
323
+ maxInboundMessageSizeBytes , maxInboundMetadataSizeBytes );
311
324
}
312
325
313
326
var vsocket = matcher .group ("vsocket" );
314
327
if (vsocket != null ) {
315
328
return new GrpcEndpointSettings (vsocket , secure , clientKeyPath , clientCertPath , caCertPath , enablekeepAlive ,
316
- keepAliveTimeSeconds , keepAliveTimeoutSeconds , keepAliveWithoutCalls );
329
+ keepAliveTimeSeconds , keepAliveTimeoutSeconds , keepAliveWithoutCalls ,
330
+ maxInboundMessageSizeBytes , maxInboundMetadataSizeBytes );
317
331
}
318
332
}
319
333
320
334
return new GrpcEndpointSettings (String .format (
321
335
"dns:///%s:%d" ,
322
336
address ,
323
337
port ), secure , clientKeyPath , clientCertPath , caCertPath , enablekeepAlive , keepAliveTimeSeconds ,
324
- keepAliveTimeoutSeconds , keepAliveWithoutCalls );
338
+ keepAliveTimeoutSeconds , keepAliveWithoutCalls ,
339
+ maxInboundMessageSizeBytes , maxInboundMetadataSizeBytes );
325
340
}
326
341
327
342
}
0 commit comments