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,8 +155,11 @@ public static ManagedChannel buildGrpcManagedChannel(Properties properties, Clie
152
155
.keepAliveTimeout (settings .keepAliveTimeoutSeconds .toSeconds (), TimeUnit .SECONDS )
153
156
.keepAliveWithoutCalls (settings .keepAliveWithoutCalls );
154
157
}
158
+
159
+ return builder .maxInboundMessageSize (settings .maxInboundMessageSize )
160
+ .maxInboundMetadataSize (settings .maxInboundMetadataSize )
161
+ .build ();
155
162
156
- return builder .build ();
157
163
} catch (Exception e ) {
158
164
throw new DaprException (
159
165
new DaprError ().setErrorCode ("TLS_CREDENTIALS_ERROR" )
@@ -217,7 +223,8 @@ public static ManagedChannel buildGrpcManagedChannel(Properties properties, Clie
217
223
.keepAliveWithoutCalls (settings .keepAliveWithoutCalls );
218
224
}
219
225
220
- return builder .build ();
226
+ return builder .maxInboundMessageSize (settings .maxInboundMessageSize )
227
+ .maxInboundMetadataSize (settings .maxInboundMetadataSize ).build ();
221
228
}
222
229
223
230
// Not private to allow unit testing
@@ -233,10 +240,13 @@ static final class GrpcEndpointSettings {
233
240
final Duration keepAliveTimeoutSeconds ;
234
241
final boolean keepAliveWithoutCalls ;
235
242
243
+ final int maxInboundMessageSize ;
244
+ final int maxInboundMetadataSize ;
245
+
236
246
private GrpcEndpointSettings (
237
247
String endpoint , boolean secure , String tlsPrivateKeyPath , String tlsCertPath , String tlsCaPath ,
238
248
boolean enableKeepAlive , Duration keepAliveTimeSeconds , Duration keepAliveTimeoutSeconds ,
239
- boolean keepAliveWithoutCalls ) {
249
+ boolean keepAliveWithoutCalls , int maxInboundMessageSize , int maxInboundMetadataSize ) {
240
250
this .endpoint = endpoint ;
241
251
this .secure = secure ;
242
252
this .tlsPrivateKeyPath = tlsPrivateKeyPath ;
@@ -246,6 +256,8 @@ private GrpcEndpointSettings(
246
256
this .keepAliveTimeSeconds = keepAliveTimeSeconds ;
247
257
this .keepAliveTimeoutSeconds = keepAliveTimeoutSeconds ;
248
258
this .keepAliveWithoutCalls = keepAliveWithoutCalls ;
259
+ this .maxInboundMessageSize = maxInboundMessageSize ;
260
+ this .maxInboundMetadataSize = maxInboundMetadataSize ;
249
261
}
250
262
251
263
static GrpcEndpointSettings parse (Properties properties ) {
@@ -258,6 +270,8 @@ static GrpcEndpointSettings parse(Properties properties) {
258
270
Duration keepAliveTimeSeconds = properties .getValue (GRPC_KEEP_ALIVE_TIME_SECONDS );
259
271
Duration keepAliveTimeoutSeconds = properties .getValue (GRPC_KEEP_ALIVE_TIMEOUT_SECONDS );
260
272
boolean keepAliveWithoutCalls = properties .getValue (GRPC_KEEP_ALIVE_WITHOUT_CALLS );
273
+ int maxInboundMessageSizeBytes = properties .getValue (GRPC_MAX_INBOUND_MESSAGE_SIZE_BYTES );
274
+ int maxInboundMetadataSizeBytes = properties .getValue (GRPC_MAX_INBOUND_METADATA_SIZE_BYTES );
261
275
262
276
boolean secure = false ;
263
277
String grpcEndpoint = properties .getValue (GRPC_ENDPOINT );
@@ -301,27 +315,30 @@ static GrpcEndpointSettings parse(Properties properties) {
301
315
address ,
302
316
port ),
303
317
secure , clientKeyPath , clientCertPath , caCertPath , enablekeepAlive , keepAliveTimeSeconds ,
304
- keepAliveTimeoutSeconds , keepAliveWithoutCalls );
318
+ keepAliveTimeoutSeconds , keepAliveWithoutCalls , maxInboundMessageSizeBytes , maxInboundMetadataSizeBytes );
305
319
}
306
320
307
321
var socket = matcher .group ("socket" );
308
322
if (socket != null ) {
309
323
return new GrpcEndpointSettings (socket , secure , clientKeyPath , clientCertPath , caCertPath , enablekeepAlive ,
310
- keepAliveTimeSeconds , keepAliveTimeoutSeconds , keepAliveWithoutCalls );
324
+ keepAliveTimeSeconds , keepAliveTimeoutSeconds , keepAliveWithoutCalls ,
325
+ maxInboundMessageSizeBytes , maxInboundMetadataSizeBytes );
311
326
}
312
327
313
328
var vsocket = matcher .group ("vsocket" );
314
329
if (vsocket != null ) {
315
330
return new GrpcEndpointSettings (vsocket , secure , clientKeyPath , clientCertPath , caCertPath , enablekeepAlive ,
316
- keepAliveTimeSeconds , keepAliveTimeoutSeconds , keepAliveWithoutCalls );
331
+ keepAliveTimeSeconds , keepAliveTimeoutSeconds , keepAliveWithoutCalls ,
332
+ maxInboundMessageSizeBytes , maxInboundMetadataSizeBytes );
317
333
}
318
334
}
319
335
320
336
return new GrpcEndpointSettings (String .format (
321
337
"dns:///%s:%d" ,
322
338
address ,
323
339
port ), secure , clientKeyPath , clientCertPath , caCertPath , enablekeepAlive , keepAliveTimeSeconds ,
324
- keepAliveTimeoutSeconds , keepAliveWithoutCalls );
340
+ keepAliveTimeoutSeconds , keepAliveWithoutCalls ,
341
+ maxInboundMessageSizeBytes , maxInboundMetadataSizeBytes );
325
342
}
326
343
327
344
}
0 commit comments