Skip to content

Commit

Permalink
feat: increase max receive message size
Browse files Browse the repository at this point in the history
This increases the gRPC maximum receive message size to 12MB, and also
makes both it and the max send size configurable.
  • Loading branch information
jroper committed Aug 2, 2022
1 parent 2b071aa commit be936f7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
34 changes: 33 additions & 1 deletion sdk/src/kalix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -430,7 +449,7 @@ export class Kalix {
);
}

this.server = new grpc.Server();
this.server = new grpc.Server(this.channelSettingsToGrpcChannelOptions(options?.channelSettings));
}

/**
Expand Down Expand Up @@ -780,6 +799,19 @@ 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) {
Expand Down
3 changes: 2 additions & 1 deletion tck/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit be936f7

Please sign in to comment.