Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion function/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
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
Expand All @@ -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}")
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,6 @@ convention = "google"
[tool.ruff.lint.pep8-naming]
# gRPC requires this PascalCase function name.
extend-ignore-names = ["RunFunction"]

[tool.ruff.lint.pylint]
max-args = 6
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of allowing 6 parameters in general, we can just extend the noqa codes of the cli function like
# noqa: FBT001, PLR0913

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I'd prefer to make a one-time exception for the specific cli function.