Skip to content

Commit 1fa83a7

Browse files
authored
Merge pull request #34 from P0t4T0o/support-grpc-msg-length-options
allow setting grpc message sizes
2 parents 0517189 + 2435cb0 commit 1fa83a7

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

function/main.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,28 @@
3232
"If you supply this flag --tls-certs-dir will be ignored."
3333
),
3434
)
35-
def cli(debug: bool, address: str, tls_certs_dir: str, insecure: bool) -> None: # noqa:FBT001 # We only expect callers via the CLI.
35+
@click.option(
36+
"--max-recv-message-size",
37+
default=4,
38+
show_default=True,
39+
type=click.INT,
40+
help=("Maximum size of received messages in MB."),
41+
)
42+
@click.option(
43+
"--max-send-message-size",
44+
default=4,
45+
show_default=True,
46+
type=click.INT,
47+
help=("Maximum size of sent messages in MB."),
48+
)
49+
def cli( # noqa: PLR0913
50+
debug: bool, # noqa: FBT001
51+
address: str,
52+
tls_certs_dir: str,
53+
insecure: bool, # noqa: FBT001
54+
max_recv_message_size: int,
55+
max_send_message_size: int,
56+
) -> None: # We only expect callers via the CLI.
3657
"""A Crossplane composition function."""
3758
try:
3859
level = logging.Level.INFO
@@ -44,6 +65,16 @@ def cli(debug: bool, address: str, tls_certs_dir: str, insecure: bool) -> None:
4465
address,
4566
creds=runtime.load_credentials(tls_certs_dir),
4667
insecure=insecure,
68+
options=[
69+
(
70+
"grpc.max_receive_message_length",
71+
1024 * 1024 * max_recv_message_size,
72+
),
73+
(
74+
"grpc.max_send_message_length",
75+
1024 * 1024 * max_send_message_size,
76+
),
77+
],
4778
)
4879
except Exception as e:
4980
click.echo(f"Cannot run function: {e}")

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ classifiers = [
1818
]
1919

2020
dependencies = [
21-
"crossplane-function-sdk-python==0.9.0",
21+
"crossplane-function-sdk-python==0.10.0",
2222
"click==8.2.1",
23-
"grpcio==1.74.0",
23+
"grpcio==1.76.0",
2424
]
2525

2626
dynamic = ["version"]

0 commit comments

Comments
 (0)