diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff3fa4c..7217c0c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ env: jobs: lint: - runs-on: ubuntu-24.04 + runs-on: ubuntu-26.04 steps: - name: Checkout uses: actions/checkout@v7 @@ -52,7 +52,7 @@ jobs: run: hatch fmt unit-test: - runs-on: ubuntu-24.04 + runs-on: ubuntu-26.04 steps: - name: Checkout uses: actions/checkout@v7 @@ -70,7 +70,7 @@ jobs: build: - runs-on: ubuntu-24.04 + runs-on: ubuntu-26.04 steps: - name: Checkout uses: actions/checkout@v7 @@ -111,7 +111,7 @@ jobs: if: ${{ inputs.version != '' }} needs: - build - runs-on: ubuntu-24.04 + runs-on: ubuntu-26.04 steps: - name: Download Sdist and Wheel from GitHub uses: actions/download-artifact@v8 @@ -133,7 +133,7 @@ jobs: # The simple docs tool we're using doesn't support versions, so our docs # will only reflect what's in main. if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - runs-on: ubuntu-24.04 + runs-on: ubuntu-26.04 steps: - name: Checkout uses: actions/checkout@v7 diff --git a/crossplane/function/cli.py b/crossplane/function/cli.py index ee22bdf..e18967c 100644 --- a/crossplane/function/cli.py +++ b/crossplane/function/cli.py @@ -56,12 +56,21 @@ def cli(cache_size, **kwargs): def standard_options(func: F) -> F: """Apply the standard Composition Function CLI options to a Click command.""" + @click.option( + "--max-send-message-size", + type=int, + default=None, + envvar="MAX_SEND_MESSAGE_SIZE", + help="Maximum size of sent gRPC messages in MB. " + "Defaults to --max-recv-message-size.", + ) @click.option( "--max-recv-message-size", + "--max-grpc-message-size", type=int, default=DEFAULT_MAX_RECV_MESSAGE_SIZE, show_default=True, - envvar="MAX_RECV_MESSAGE_SIZE", + envvar=["MAX_RECV_MESSAGE_SIZE", "MAX_GRPC_MESSAGE_SIZE"], help="Maximum size of received gRPC messages in MB.", ) @click.option( @@ -107,15 +116,18 @@ def run( # noqa: PLR0913 tls_certs_dir: str | None, insecure: bool, max_recv_message_size: int, + max_send_message_size: int | None, ) -> None: """Start a composition function gRPC server with standard options.""" level = logging.Level.DEBUG if debug else logging.Level.INFO logging.configure(level=level) - size_bytes = max_recv_message_size * 1024 * 1024 + if max_send_message_size is None: + max_send_message_size = max_recv_message_size + options = [ - ("grpc.max_receive_message_length", size_bytes), - ("grpc.max_send_message_length", size_bytes), + ("grpc.max_receive_message_length", max_recv_message_size * 1024 * 1024), + ("grpc.max_send_message_length", max_send_message_size * 1024 * 1024), ] runtime.serve( diff --git a/crossplane/function/runtime.py b/crossplane/function/runtime.py index a6e465e..827460a 100644 --- a/crossplane/function/runtime.py +++ b/crossplane/function/runtime.py @@ -99,6 +99,7 @@ def serve( loop = asyncio.get_event_loop() except RuntimeError: loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) server = grpc.aio.server(options=options) diff --git a/pyproject.toml b/pyproject.toml index a2d3368..29866f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ dependencies = [ "click==8.*", "grpcio==1.84.0", "grpcio-reflection==1.*", - "protobuf==7.36.1", # Must be compatible with grpcio-tools. + "protobuf==7.36.2", # Must be compatible with grpcio-tools. "pydantic==2.*", "structlog==26.*", ]