Skip to content

Implement Declarative Function Signatures #159

Description

@grant

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions