|
25 | 25 | import java.util.regex.Pattern; |
26 | 26 |
|
27 | 27 | import static io.dapr.config.Properties.GRPC_ENDPOINT; |
| 28 | +import static io.dapr.config.Properties.GRPC_MAX_INBOUND_MESSAGE_SIZE_BYTES; |
| 29 | +import static io.dapr.config.Properties.GRPC_MAX_INBOUND_METADATA_SIZE_BYTES; |
28 | 30 | import static io.dapr.config.Properties.GRPC_PORT; |
29 | 31 | import static io.dapr.config.Properties.SIDECAR_IP; |
30 | 32 |
|
@@ -121,22 +123,34 @@ public static ManagedChannel buildGrpcManagedChannel(Properties properties, Clie |
121 | 123 | if (interceptors != null && interceptors.length > 0) { |
122 | 124 | builder = builder.intercept(interceptors); |
123 | 125 | } |
124 | | - return builder.build(); |
| 126 | + return builder.maxInboundMessageSize(settings.maxInboundMessageSize) |
| 127 | + .maxInboundMetadataSize(settings.maxInboundMetadataSize) |
| 128 | + .build(); |
125 | 129 | } |
126 | 130 |
|
127 | 131 | // Not private to allow unit testing |
128 | 132 | static final class GrpcEndpointSettings { |
129 | 133 | final String endpoint; |
130 | 134 | final boolean secure; |
131 | 135 |
|
132 | | - private GrpcEndpointSettings(String endpoint, boolean secure) { |
| 136 | + final int maxInboundMessageSize; |
| 137 | + final int maxInboundMetadataSize; |
| 138 | + |
| 139 | + private GrpcEndpointSettings( |
| 140 | + String endpoint, boolean secure, |
| 141 | + int maxInboundMessageSize, int maxInboundMetadataSize) { |
133 | 142 | this.endpoint = endpoint; |
134 | 143 | this.secure = secure; |
| 144 | + this.maxInboundMessageSize = maxInboundMessageSize; |
| 145 | + this.maxInboundMetadataSize = maxInboundMetadataSize; |
135 | 146 | } |
136 | 147 |
|
137 | 148 | static GrpcEndpointSettings parse(Properties properties) { |
138 | 149 | String address = properties.getValue(SIDECAR_IP); |
139 | 150 | int port = properties.getValue(GRPC_PORT); |
| 151 | + int maxInboundMessageSizeBytes = properties.getValue(GRPC_MAX_INBOUND_MESSAGE_SIZE_BYTES); |
| 152 | + int maxInboundMetadataSizeBytes = properties.getValue(GRPC_MAX_INBOUND_METADATA_SIZE_BYTES); |
| 153 | + |
140 | 154 | boolean secure = false; |
141 | 155 | String grpcEndpoint = properties.getValue(GRPC_ENDPOINT); |
142 | 156 | if ((grpcEndpoint != null) && !grpcEndpoint.isEmpty()) { |
@@ -172,21 +186,23 @@ static GrpcEndpointSettings parse(Properties properties) { |
172 | 186 |
|
173 | 187 | var authorityEndpoint = matcher.group("authorityEndpoint"); |
174 | 188 | if (authorityEndpoint != null) { |
175 | | - return new GrpcEndpointSettings(String.format("dns://%s/%s:%d", authorityEndpoint, address, port), secure); |
| 189 | + return new GrpcEndpointSettings(String.format("dns://%s/%s:%d", authorityEndpoint, address, port), |
| 190 | + secure, maxInboundMessageSizeBytes, maxInboundMetadataSizeBytes); |
176 | 191 | } |
177 | 192 |
|
178 | 193 | var socket = matcher.group("socket"); |
179 | 194 | if (socket != null) { |
180 | | - return new GrpcEndpointSettings(socket, secure); |
| 195 | + return new GrpcEndpointSettings(socket, secure, maxInboundMessageSizeBytes, maxInboundMetadataSizeBytes); |
181 | 196 | } |
182 | 197 |
|
183 | 198 | var vsocket = matcher.group("vsocket"); |
184 | 199 | if (vsocket != null) { |
185 | | - return new GrpcEndpointSettings(vsocket, secure); |
| 200 | + return new GrpcEndpointSettings(vsocket, secure, maxInboundMessageSizeBytes, maxInboundMetadataSizeBytes); |
186 | 201 | } |
187 | 202 | } |
188 | 203 |
|
189 | | - return new GrpcEndpointSettings(String.format("dns:///%s:%d", address, port), secure); |
| 204 | + return new GrpcEndpointSettings(String.format("dns:///%s:%d", address, port), secure, |
| 205 | + maxInboundMessageSizeBytes, maxInboundMetadataSizeBytes); |
190 | 206 | } |
191 | 207 |
|
192 | 208 | } |
|
0 commit comments