Skip to content

refactor: replace --gateway flag with --asgi boolean flag #383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 23, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 5 additions & 5 deletions .github/workflows/conformance-asgi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,39 +52,39 @@ jobs:
functionType: 'http'
useBuildpacks: false
validateMapping: false
cmd: "'functions-framework --source tests/conformance/async_main.py --target write_http --signature-type http --gateway asgi'"
cmd: "'functions-framework --source tests/conformance/async_main.py --target write_http --signature-type http --asgi'"

- name: Run CloudEvents conformance tests
uses: GoogleCloudPlatform/functions-framework-conformance/action@72a4f36b10f1c6435ab1a86a9ea24bda464cc262 # v1.8.6
with:
functionType: 'cloudevent'
useBuildpacks: false
validateMapping: false
cmd: "'functions-framework --source tests/conformance/async_main.py --target write_cloud_event --signature-type cloudevent --gateway asgi'"
cmd: "'functions-framework --source tests/conformance/async_main.py --target write_cloud_event --signature-type cloudevent --asgi'"

- name: Run HTTP conformance tests declarative
uses: GoogleCloudPlatform/functions-framework-conformance/action@72a4f36b10f1c6435ab1a86a9ea24bda464cc262 # v1.8.6
with:
functionType: 'http'
useBuildpacks: false
validateMapping: false
cmd: "'functions-framework --source tests/conformance/async_main.py --target write_http_declarative --gateway asgi'"
cmd: "'functions-framework --source tests/conformance/async_main.py --target write_http_declarative --asgi'"

- name: Run CloudEvents conformance tests declarative
uses: GoogleCloudPlatform/functions-framework-conformance/action@72a4f36b10f1c6435ab1a86a9ea24bda464cc262 # v1.8.6
with:
functionType: 'cloudevent'
useBuildpacks: false
validateMapping: false
cmd: "'functions-framework --source tests/conformance/async_main.py --target write_cloud_event_declarative --gateway asgi'"
cmd: "'functions-framework --source tests/conformance/async_main.py --target write_cloud_event_declarative --asgi'"

- name: Run HTTP concurrency tests declarative
uses: GoogleCloudPlatform/functions-framework-conformance/action@72a4f36b10f1c6435ab1a86a9ea24bda464cc262 # v1.8.6
with:
functionType: 'http'
useBuildpacks: false
validateConcurrency: true
cmd: "'functions-framework --source tests/conformance/async_main.py --target write_http_declarative_concurrent --gateway asgi'"
cmd: "'functions-framework --source tests/conformance/async_main.py --target write_http_declarative_concurrent --asgi'"

# Note: Event (legacy) and Typed tests are not supported in ASGI mode
# Note: validateMapping is set to false for CloudEvent tests because ASGI mode
Expand Down
13 changes: 6 additions & 7 deletions src/functions_framework/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@
@click.option("--port", envvar="PORT", type=click.INT, default=8080)
@click.option("--debug", envvar="DEBUG", is_flag=True)
@click.option(
"--gateway",
envvar="FUNCTION_GATEWAY",
type=click.Choice(["wsgi", "asgi"]),
default="wsgi",
help="Server gateway interface type (wsgi for sync, asgi for async)",
"--asgi",
envvar="FUNCTION_USE_ASGI",
is_flag=True,
help="Use ASGI server for function execution",
)
def _cli(target, source, signature_type, host, port, debug, gateway):
if gateway == "asgi": # pragma: no cover
def _cli(target, source, signature_type, host, port, debug, asgi):
if asgi: # pragma: no cover
from functions_framework.aio import create_asgi_app

app = create_asgi_app(target, source, signature_type)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def test_asgi_cli(monkeypatch):
monkeypatch.setattr(functions_framework._cli, "create_server", create_server)

runner = CliRunner()
result = runner.invoke(_cli, ["--target", "foo", "--gateway", "asgi"])
result = runner.invoke(_cli, ["--target", "foo", "--asgi"])

assert result.exit_code == 0
assert create_asgi_app.calls == [pretend.call("foo", None, "http")]
Expand Down
Loading