GithubHelp home page GithubHelp logo

Comments (3)

kevmoo avatar kevmoo commented on June 10, 2024 1

The default function is function. See https://github.com/GoogleCloudPlatform/functions-framework#specification-summary

You need to provide the --target flag to specify either foo or bar

from functions-framework-dart.

cubuspl42 avatar cubuspl42 commented on June 10, 2024

I've tried setting up a simple experiment with two functions, foo and bar. Nothing fancy.

@CloudFunction()
Response foo(Request request) => Response.ok('Hello, World! (foo)');

@CloudFunction()
Response bar(Request request) => Response.ok('Hello, World! (bar)');

The server.dart got generated correctly, indicating that this is supported.

FunctionTarget? _nameToFunctionTarget(String name) {
  switch (name) {
    case 'foo':
      return FunctionTarget.http(
        function_library.foo,
      );
    case 'bar':
      return FunctionTarget.http(
        function_library.bar,
      );
    default:
      return null;
  }
}

But after building a container using the provided Dockerfile, it fails to start:

$ docker container run --name my-container-1 -p 8081:8080 my-image-1
There is no handler configured for FUNCTION_TARGET `function`.

How can I build (& deploy to the Cloud Run, preferably) such trivial two-functions package?

from functions-framework-dart.

cubuspl42 avatar cubuspl42 commented on June 10, 2024

@kevmoo Thank you very much for your answer, but please be aware that from my perspective this issue is not closed.

Thank you for a link to the functions-framework project. Would you point me to the place in the functions-framework-dart project that states that these two projects are interconnected? I can see that the names are similar and I can guess the relationship between them, but stating such relationship in the readme / docs is necessary, in my opinion. I wouldn't know how the functions-framework-dart user is expected to guess that they should look for information in the functions-framework#specification-summary document.

I might should have noted, that such direct docker container run invocation was just a "MCVE". I don't intend to invoke this code in such way. In a real life scenario, a similar (cryptic, for me) message was buried deeply in a Cloud Run logs, when my container exploded during start-up.

I'll also repeat the questions from my original posts.

Am I correct to assume that the intended usage (of functions-framework-dart) is similar to the official Firebase Functions JavaScript SDK, where you can define dozens of functions in the single file?

Should I conclude that the answer is "yes"?

How can I build (& deploy to the Cloud Run, preferably) such trivial two-functions package?

Does the provided Dockerfile, which is picked up by gcloud beta run deploy command as per Quickstart: Cloud Run docs support a project with multiple functions (or, in other words, multiple functions with non-default names)?

Am I right to assume that if I have multiple functions in my functions-framework-dart -based project, I'll need a separate Cloud Run service per single in-code @CloudFunction()?

from functions-framework-dart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.