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

Document Declarative Function Signatures #357

Closed
grant opened this issue Oct 15, 2021 · 2 comments · Fixed by #381
Closed

Document Declarative Function Signatures #357

grant opened this issue Oct 15, 2021 · 2 comments · Fixed by #381
Assignees

Comments

@grant
Copy link
Contributor

grant commented Oct 15, 2021

We should document the interface to declarative function signatures on the main README.md. It's not clear how to use the interface or how it interacts with non-declarative functions. There are many edge cases to consider, examples:

  • What happens if there are multiple functions with the same name?
  • What are valid function names? Do these align with GCF?
  • What if both a declarative and non-declarative function has been specified?

Implementation: #347

@grant
Copy link
Contributor Author

grant commented Oct 21, 2021

From what I can tell, the current implementation doesn't work as expected.

const FunctionsFramework = require('@google-cloud/functions-framework');

FunctionsFramework.http('function', async (req, res) => {
  res.send('Hello, World!');
});

Command:

functions-framework-nodejs

Error:

Function 'function' is not defined in the provided module.
Did you specify the correct target function to execute?
Could not load the function, shutting down.

@matthewrobertson
Copy link
Member

matthewrobertson commented Oct 25, 2021

From what I can tell, the current implementation doesn't work as expected.

For your example, you would still need to provide the target cli argument:

functions-framework-nodejs  --target=function

The fallback to the default function target is only implemented for non-declarative functions. I didn't included it in the declarative API because there is already a TODO questioning it's existence. As it is today, I don't think it is possible to use the default on GCF because you must provide a target name when you deploy your function.

Also function is a keyword in javascript, so it is a really weird thing to name a method (I'm not even sure it is allowed).

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