diff --git a/sdk/src/kalix.ts b/sdk/src/kalix.ts index ce90d764a..f235f4d81 100644 --- a/sdk/src/kalix.ts +++ b/sdk/src/kalix.ts @@ -66,6 +66,11 @@ export interface KalixOptions { * Delay completing discovery until proxyPort has been set by the testkit. */ delayDiscoveryUntilProxyPortSet?: boolean; + + /** + * Channel settings. + */ + channelSettings?: ChannelSettings; } /** @internal */ @@ -266,6 +271,20 @@ export interface PreStartSettings { identificationInfo?: discovery.IdentificationInfo; } +/** + * Settings for the gRPC channel used to communicate with the Kalix proxy + */ +export interface ChannelSettings { + /** + * The maximum number of bytes a gRPC message may be when receiving + */ + maxReceiveMessageLength?: number; + /** + * The maximum number of bytes a gRPC message may be when sending + */ + maxSendMessageLength?: number; +} + /** * Kalix Entity. * @@ -430,7 +449,9 @@ export class Kalix { ); } - this.server = new grpc.Server(); + this.server = new grpc.Server( + this.channelSettingsToGrpcChannelOptions(options?.channelSettings), + ); } /** @@ -780,6 +801,21 @@ export class Kalix { return spec; } + private channelSettingsToGrpcChannelOptions( + settings?: ChannelSettings, + ): grpc.ChannelOptions { + const opts = { + 'grpc.max_receive_message_length': settings?.maxReceiveMessageLength, + 'grpc.max_send_message_length': settings?.maxSendMessageLength, + }; + if (!opts['grpc.max_receive_message_length']) { + // Default to 12 mb + opts['grpc.max_receive_message_length'] = 12 * 1024 * 1024; + } + + return opts; + } + private proxyTerminatedLogic() { this.proxyHasTerminated = true; if (this.waitingForProxyTermination) { diff --git a/tck/package.json b/tck/package.json index 3ba49e40a..62248f2c3 100644 --- a/tck/package.json +++ b/tck/package.json @@ -11,7 +11,8 @@ }, "devDependencies": { "testcontainers": "7.10.0", - "typescript": "4.3.4" + "typescript": "4.3.4", + "protobufjs": "6.11.3" }, "scripts": { "clean": "rimraf ./proto ./generated ./dist",