Skip to content
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

Implement Declarative Function Signatures #159

Closed
grant opened this issue Oct 20, 2021 · 1 comment · Fixed by #160
Closed

Implement Declarative Function Signatures #159

grant opened this issue Oct 20, 2021 · 1 comment · Fixed by #160
Assignees

Comments

@grant
Copy link
Contributor

grant commented Oct 20, 2021

This issue is tracking implementing declarative function signatures in python.

This feature allows a functions framework to optionally detect the user code's function signature without specifying a --signature-type / FUNCTION_SIGNATURE_TYPE config. It may require a code change for the user.

A possible implementation for python may look like this:

@functions_framework.http("hello")
def hello(request):
    return "Hello world!"

@functions_framework.cloudevent("ce")
def function_name_does_not_matter(cloudevent):
    print(f"Received event with ID: {cloudevent['id']}")

The function (i.e. hello) would be invoked at localhost:8080/hello.

The functions-framework CLI would load all/any registered functions if available.

Note: The function name would not change the URL route or be used.

I think a decorator like this would be most clear, but other designs would be fine. As noted in the FF contract, event is not a requirement.

See:

CC: @matthewrobertson @anniefu

@grant
Copy link
Contributor Author

grant commented Oct 21, 2021

Also, feel free to refactor

https://github.com/GoogleCloudPlatform/functions-framework-python/blob/master/src/functions_framework/__init__.py

if it's getting a bit too large of a surface area.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants