3 ms·
Procs can be used anywhere a block can. my_proc = proc { |request| "Hello, world!" } FunctionsFramework.http("hello", &my_proc)
by dazuma 6y ago
Procs can be used anywhere a block can.
my_proc = proc { |request| "Hello, world!" }
FunctionsFramework.http("hello", &my_proc)
- crazydoggers 6y agoI’m asking though why FunctionsFramework is needed in the first place, since Procs and Lambdas are basically first class functions. What’s gained by the library. The article never goes into that aspect.
- dazuma 6y agoAh yes, good point. I neglected to cover that. Well, in a nutshell: * FunctionsFramework allows us to open-source the parts of the runtime not tied to the Google Cloud Functions hosting environment itself, meaning it should be possible to port it to other hosting, such as Kubernetes, Google Cloud Run, even FaaS products from other vendors. * Procs work, but they're just objects. We'd still need some kind of interface to name them, load them, etc. Otherwise we'd be limited to, e.g., setting a special constant or global variable to the proc, which is messy, makes testing harder, etc. * Speaking of which, a FunctionsFramework library gives us a place to put the unit testing library, tools to spin up a functions server locally for testing, and whatever tools developers might find useful in the future. For reasons such as these, Google's overall Cloud Functions team decided to produce framework libraries for all supported languages. There's a contract and everything that our Ruby gem follows. (https://github.com/GoogleCloudPlatform/functions-framework https://github.com/GoogleCloudPlatform/functions-framework)