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

feat: Declarative function signatures for python #160

Merged
merged 13 commits into from Oct 26, 2021
Merged

Conversation

KaylaNguyen
Copy link
Contributor

@KaylaNguyen KaylaNguyen commented Oct 22, 2021

Allow users to systematically register their function signature type:

import functions_framework 

@function_framework.cloudevent
def hello_cloudevent(cloudevent):
    print("Hello")

@function_framework.http
def hello_http(request):
    print("Hello")

User signature type is searched in the following order:

  • Decorator user used to register their function (new behavior)
  • --signature-type flag (current behavior)
  • environment variable FUNCTION_SIGNATURE_TYPE (current behavior)

If none of the above is set, signature type defaults to be "http".

@google-cla google-cla bot added the cla: yes label Oct 22, 2021
@KaylaNguyen KaylaNguyen linked an issue Oct 22, 2021 that may be closed by this pull request
@KaylaNguyen KaylaNguyen changed the title Declarative function signatures for python feat!: Declarative function signatures for python Oct 22, 2021
src/functions_framework/__init__.py Outdated Show resolved Hide resolved
src/functions_framework/__init__.py Show resolved Hide resolved
src/functions_framework/_function_registry.py Show resolved Hide resolved
Copy link
Contributor

@grant grant left a comment

Choose a reason for hiding this comment

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

Great PR. I've requested a few changes.

examples/cloud_run_decorator/send_cloudevent.py Outdated Show resolved Hide resolved
examples/cloud_run_http/main.py Show resolved Hide resolved
src/functions_framework/__init__.py Show resolved Hide resolved
src/functions_framework/__init__.py Outdated Show resolved Hide resolved
src/functions_framework/_function_registry.py Outdated Show resolved Hide resolved
examples/cloud_run_decorator/README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@grant grant left a comment

Choose a reason for hiding this comment

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

Reviewing further, I don't think we want to support @function_framework.event, following the Node implementation and CloudEvent future interface for events.

src/functions_framework/_function_registry.py Outdated Show resolved Hide resolved
src/functions_framework/_function_registry.py Show resolved Hide resolved
src/functions_framework/__init__.py Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
examples/cloud_run_decorator/README.md Show resolved Hide resolved
Copy link
Member

@matthewrobertson matthewrobertson left a comment

Choose a reason for hiding this comment

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

LGTM!

@KaylaNguyen KaylaNguyen merged commit 52b2a28 into master Oct 26, 2021
@KaylaNguyen KaylaNguyen deleted the declarative-ff branch October 26, 2021 22:21
@KaylaNguyen KaylaNguyen changed the title feat!: Declarative function signatures for python feat: Declarative function signatures for python Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Declarative Function Signatures
5 participants