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,8 +155,11 @@ public static ManagedChannel buildGrpcManagedChannel(Properties properties, Clie
152155              .keepAliveTimeout (settings .keepAliveTimeoutSeconds .toSeconds (), TimeUnit .SECONDS )
153156              .keepAliveWithoutCalls (settings .keepAliveWithoutCalls );
154157        }
158+         
159+         return  builder .maxInboundMessageSize (settings .maxInboundMessageSize )
160+         .maxInboundMetadataSize (settings .maxInboundMetadataSize )
161+         .build ();
155162
156-         return  builder .build ();
157163      } catch  (Exception  e ) {
158164        throw  new  DaprException (
159165            new  DaprError ().setErrorCode ("TLS_CREDENTIALS_ERROR" )
@@ -217,7 +223,8 @@ public static ManagedChannel buildGrpcManagedChannel(Properties properties, Clie
217223          .keepAliveWithoutCalls (settings .keepAliveWithoutCalls );
218224    }
219225
220-     return  builder .build ();
226+     return  builder .maxInboundMessageSize (settings .maxInboundMessageSize )
227+         .maxInboundMetadataSize (settings .maxInboundMetadataSize ).build ();
221228  }
222229
223230  // Not private to allow unit testing 
@@ -233,10 +240,13 @@ static final class GrpcEndpointSettings {
233240    final  Duration  keepAliveTimeoutSeconds ;
234241    final  boolean  keepAliveWithoutCalls ;
235242
243+     final  int  maxInboundMessageSize ;
244+     final  int  maxInboundMetadataSize ;
245+ 
236246    private  GrpcEndpointSettings (
237247        String  endpoint , boolean  secure , String  tlsPrivateKeyPath , String  tlsCertPath , String  tlsCaPath ,
238248        boolean  enableKeepAlive , Duration  keepAliveTimeSeconds , Duration  keepAliveTimeoutSeconds ,
239-         boolean  keepAliveWithoutCalls ) {
249+         boolean  keepAliveWithoutCalls ,  int   maxInboundMessageSize ,  int   maxInboundMetadataSize ) {
240250      this .endpoint  = endpoint ;
241251      this .secure  = secure ;
242252      this .tlsPrivateKeyPath  = tlsPrivateKeyPath ;
@@ -246,6 +256,8 @@ private GrpcEndpointSettings(
246256      this .keepAliveTimeSeconds  = keepAliveTimeSeconds ;
247257      this .keepAliveTimeoutSeconds  = keepAliveTimeoutSeconds ;
248258      this .keepAliveWithoutCalls  = keepAliveWithoutCalls ;
259+       this .maxInboundMessageSize  = maxInboundMessageSize ;
260+       this .maxInboundMetadataSize  = maxInboundMetadataSize ;
249261    }
250262
251263    static  GrpcEndpointSettings  parse (Properties  properties ) {
@@ -258,6 +270,8 @@ static GrpcEndpointSettings parse(Properties properties) {
258270      Duration  keepAliveTimeSeconds  = properties .getValue (GRPC_KEEP_ALIVE_TIME_SECONDS );
259271      Duration  keepAliveTimeoutSeconds  = properties .getValue (GRPC_KEEP_ALIVE_TIMEOUT_SECONDS );
260272      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 );
261275
262276      boolean  secure  = false ;
263277      String  grpcEndpoint  = properties .getValue (GRPC_ENDPOINT );
@@ -301,27 +315,30 @@ static GrpcEndpointSettings parse(Properties properties) {
301315                  address ,
302316                  port ),
303317              secure , clientKeyPath , clientCertPath , caCertPath , enablekeepAlive , keepAliveTimeSeconds ,
304-               keepAliveTimeoutSeconds , keepAliveWithoutCalls );
318+               keepAliveTimeoutSeconds , keepAliveWithoutCalls ,  maxInboundMessageSizeBytes ,  maxInboundMetadataSizeBytes );
305319        }
306320
307321        var  socket  = matcher .group ("socket" );
308322        if  (socket  != null ) {
309323          return  new  GrpcEndpointSettings (socket , secure , clientKeyPath , clientCertPath , caCertPath , enablekeepAlive ,
310-               keepAliveTimeSeconds , keepAliveTimeoutSeconds , keepAliveWithoutCalls );
324+               keepAliveTimeSeconds , keepAliveTimeoutSeconds , keepAliveWithoutCalls ,
325+               maxInboundMessageSizeBytes , maxInboundMetadataSizeBytes );
311326        }
312327
313328        var  vsocket  = matcher .group ("vsocket" );
314329        if  (vsocket  != null ) {
315330          return  new  GrpcEndpointSettings (vsocket , secure , clientKeyPath , clientCertPath , caCertPath , enablekeepAlive ,
316-               keepAliveTimeSeconds , keepAliveTimeoutSeconds , keepAliveWithoutCalls );
331+               keepAliveTimeSeconds , keepAliveTimeoutSeconds , keepAliveWithoutCalls , 
332+               maxInboundMessageSizeBytes , maxInboundMetadataSizeBytes );
317333        }
318334      }
319335
320336      return  new  GrpcEndpointSettings (String .format (
321337          "dns:///%s:%d" ,
322338          address ,
323339          port ), secure , clientKeyPath , clientCertPath , caCertPath , enablekeepAlive , keepAliveTimeSeconds ,
324-           keepAliveTimeoutSeconds , keepAliveWithoutCalls );
340+           keepAliveTimeoutSeconds , keepAliveWithoutCalls ,
341+           maxInboundMessageSizeBytes , maxInboundMetadataSizeBytes );
325342    }
326343
327344  }
0 commit comments