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 authored and octonato committed Aug 4, 2022
1 parent 1038241 commit 1aa0f77
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 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,9 @@ export class Kalix {
);
}

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

/**
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 1aa0f77

Please sign in to comment.