diff --git a/function/main.py b/function/main.py index 6ed41d7..3b5e2e2 100644 --- a/function/main.py +++ b/function/main.py @@ -32,7 +32,28 @@ "If you supply this flag --tls-certs-dir will be ignored." ), ) -def cli(debug: bool, address: str, tls_certs_dir: str, insecure: bool) -> None: # noqa:FBT001 # We only expect callers via the CLI. +@click.option( + "--max-recv-message-size", + default=4, + show_default=True, + type=click.INT, + help=("Maximum size of received messages in MB."), +) +@click.option( + "--max-send-message-size", + default=4, + show_default=True, + type=click.INT, + help=("Maximum size of sent messages in MB."), +) +def cli( # noqa: PLR0913 + debug: bool, # noqa: FBT001 + address: str, + tls_certs_dir: str, + insecure: bool, # noqa: FBT001 + max_recv_message_size: int, + max_send_message_size: int, +) -> None: # We only expect callers via the CLI. """A Crossplane composition function.""" try: level = logging.Level.INFO @@ -44,6 +65,16 @@ def cli(debug: bool, address: str, tls_certs_dir: str, insecure: bool) -> None: address, creds=runtime.load_credentials(tls_certs_dir), insecure=insecure, + options=[ + ( + "grpc.max_receive_message_length", + 1024 * 1024 * max_recv_message_size, + ), + ( + "grpc.max_send_message_length", + 1024 * 1024 * max_send_message_size, + ), + ], ) except Exception as e: click.echo(f"Cannot run function: {e}") diff --git a/pyproject.toml b/pyproject.toml index 6b43b77..419260b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,9 +18,9 @@ classifiers = [ ] dependencies = [ - "crossplane-function-sdk-python==0.9.0", + "crossplane-function-sdk-python==0.10.0", "click==8.2.1", - "grpcio==1.74.0", + "grpcio==1.76.0", ] dynamic = ["version"]