Skip to content

Commit

Permalink
feat: increase max receive message size (#399)
Browse files Browse the repository at this point in the history
* feat: increase max receive message size

This increases the gRPC maximum receive message size to 12MB, and also
makes both it and the max send size configurable.

* ChannelSettings needs to be annotated as public
* Export ChannelSettings from index

Co-authored-by: Johan Andrén <[email protected]>
Co-authored-by: Peter Vlugter <[email protected]>
  • Loading branch information
3 people authored Aug 30, 2022
1 parent ec88bba commit d78f4ee
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export {
ReplicatedWriteConsistency,
ServiceBinding,
PreStartSettings,
ChannelSettings,
} from './kalix';

export { Action } from './action';
Expand Down
40 changes: 39 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,22 @@ export interface PreStartSettings {
identificationInfo?: discovery.IdentificationInfo;
}

/**
* Settings for the gRPC channel used to communicate with the Kalix proxy
*
* @public
*/
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 +451,9 @@ export class Kalix {
);
}

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

/**
Expand Down Expand Up @@ -783,6 +806,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 d78f4ee

Please sign in to comment.