4141import static io .dapr .config .Properties .GRPC_KEEP_ALIVE_TIMEOUT_SECONDS ;
4242import static io .dapr .config .Properties .GRPC_KEEP_ALIVE_TIME_SECONDS ;
4343import 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 ;
4446import static io .dapr .config .Properties .GRPC_PORT ;
4547import static io .dapr .config .Properties .GRPC_TLS_CA_PATH ;
4648import static io .dapr .config .Properties .GRPC_TLS_CERT_PATH ;
4749import static io .dapr .config .Properties .GRPC_TLS_INSECURE ;
4850import static io .dapr .config .Properties .GRPC_TLS_KEY_PATH ;
4951import static io .dapr .config .Properties .SIDECAR_IP ;
5052
53+
5154/**
5255 * Utility methods for network, internal to Dapr SDK.
5356 */
@@ -152,7 +155,9 @@ public static ManagedChannel buildGrpcManagedChannel(Properties properties, Clie
152155 .keepAliveTimeout (settings .keepAliveTimeoutSeconds .toSeconds (), TimeUnit .SECONDS )
153156 .keepAliveWithoutCalls (settings .keepAliveWithoutCalls );
154157 }
155-
158+
159+ builder .maxInboundMessageSize (settings .maxInboundMessageSize );
160+ builder .maxInboundMetadataSize (settings .maxInboundMetadataSize );
156161 return builder .build ();
157162 } catch (Exception e ) {
158163 throw new DaprException (
@@ -233,10 +238,13 @@ static final class GrpcEndpointSettings {
233238 final Duration keepAliveTimeoutSeconds ;
234239 final boolean keepAliveWithoutCalls ;
235240
241+ final int maxInboundMessageSize ;
242+ final int maxInboundMetadataSize ;
243+
236244 private GrpcEndpointSettings (
237245 String endpoint , boolean secure , String tlsPrivateKeyPath , String tlsCertPath , String tlsCaPath ,
238246 boolean enableKeepAlive , Duration keepAliveTimeSeconds , Duration keepAliveTimeoutSeconds ,
239- boolean keepAliveWithoutCalls ) {
247+ boolean keepAliveWithoutCalls , int maxInboundMessageSize , int maxInboundMetadataSize ) {
240248 this .endpoint = endpoint ;
241249 this .secure = secure ;
242250 this .tlsPrivateKeyPath = tlsPrivateKeyPath ;
@@ -246,6 +254,8 @@ private GrpcEndpointSettings(
246254 this .keepAliveTimeSeconds = keepAliveTimeSeconds ;
247255 this .keepAliveTimeoutSeconds = keepAliveTimeoutSeconds ;
248256 this .keepAliveWithoutCalls = keepAliveWithoutCalls ;
257+ this .maxInboundMessageSize = maxInboundMessageSize ;
258+ this .maxInboundMetadataSize = maxInboundMetadataSize ;
249259 }
250260
251261 static GrpcEndpointSettings parse (Properties properties ) {
@@ -258,6 +268,8 @@ static GrpcEndpointSettings parse(Properties properties) {
258268 Duration keepAliveTimeSeconds = properties .getValue (GRPC_KEEP_ALIVE_TIME_SECONDS );
259269 Duration keepAliveTimeoutSeconds = properties .getValue (GRPC_KEEP_ALIVE_TIMEOUT_SECONDS );
260270 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 );
261273
262274 boolean secure = false ;
263275 String grpcEndpoint = properties .getValue (GRPC_ENDPOINT );
@@ -301,27 +313,30 @@ static GrpcEndpointSettings parse(Properties properties) {
301313 address ,
302314 port ),
303315 secure , clientKeyPath , clientCertPath , caCertPath , enablekeepAlive , keepAliveTimeSeconds ,
304- keepAliveTimeoutSeconds , keepAliveWithoutCalls );
316+ keepAliveTimeoutSeconds , keepAliveWithoutCalls , maxInboundMessageSizeBytes , maxInboundMetadataSizeBytes );
305317 }
306318
307319 var socket = matcher .group ("socket" );
308320 if (socket != null ) {
309321 return new GrpcEndpointSettings (socket , secure , clientKeyPath , clientCertPath , caCertPath , enablekeepAlive ,
310- keepAliveTimeSeconds , keepAliveTimeoutSeconds , keepAliveWithoutCalls );
322+ keepAliveTimeSeconds , keepAliveTimeoutSeconds , keepAliveWithoutCalls ,
323+ maxInboundMessageSizeBytes , maxInboundMetadataSizeBytes );
311324 }
312325
313326 var vsocket = matcher .group ("vsocket" );
314327 if (vsocket != null ) {
315328 return new GrpcEndpointSettings (vsocket , secure , clientKeyPath , clientCertPath , caCertPath , enablekeepAlive ,
316- keepAliveTimeSeconds , keepAliveTimeoutSeconds , keepAliveWithoutCalls );
329+ keepAliveTimeSeconds , keepAliveTimeoutSeconds , keepAliveWithoutCalls ,
330+ maxInboundMessageSizeBytes , maxInboundMetadataSizeBytes );
317331 }
318332 }
319333
320334 return new GrpcEndpointSettings (String .format (
321335 "dns:///%s:%d" ,
322336 address ,
323337 port ), secure , clientKeyPath , clientCertPath , caCertPath , enablekeepAlive , keepAliveTimeSeconds ,
324- keepAliveTimeoutSeconds , keepAliveWithoutCalls );
338+ keepAliveTimeoutSeconds , keepAliveWithoutCalls ,
339+ maxInboundMessageSizeBytes , maxInboundMetadataSizeBytes );
325340 }
326341
327342 }
0 commit comments