Skip to content

feat: Declarative function signatures for python - #160

Merged
KaylaNguyen merged 13 commits into
masterfrom
declarative-ff
Oct 26, 2021
Merged

KaylaNguyen merged 13 commits into
masterfrom
declarative-ff

Conversation

@KaylaNguyen

@KaylaNguyen KaylaNguyen commented Oct 22, 2021

Copy link
Copy Markdown
Contributor

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
Comment thread src/functions_framework/__init__.py Outdated
Comment thread src/functions_framework/__init__.py
Comment thread src/functions_framework/_function_registry.py

@grant grant left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread examples/cloud_run_decorator/send_cloudevent.py Outdated
Comment thread examples/cloud_run_http/main.py
Comment thread src/functions_framework/__init__.py
Comment thread src/functions_framework/__init__.py Outdated
Comment thread src/functions_framework/_function_registry.py
Comment thread examples/cloud_run_decorator/README.md Outdated

@grant grant left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread src/functions_framework/_function_registry.py Outdated
Comment thread src/functions_framework/_function_registry.py
Comment thread src/functions_framework/__init__.py Outdated
Comment thread README.md Outdated
Comment thread examples/cloud_run_decorator/README.md

@matthewrobertson matthewrobertson left a comment

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.

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