FaaS(函数即服务)框架,用于编写可移植的 Ruby 函数
An open source framework for writing lightweight, portable Ruby functions that run in a serverless environment. Functions written to this Framework will run in many different environments, including:
The framework allows you to go from:
FunctionsFramework.http("hello") do |request|
"Hello, world!\n"
endTo:
curl http://my-url
# Output: Hello, world!Running on a fully-managed or self-managed serverless environment, without requiring an HTTP server or complicated request handling logic.
This library is supported on Ruby 3.0+.
Google provides official support for Ruby versions that are actively supported by Ruby Core—that is, Ruby versions that are either in normal maintenance or in security maintenance, and not end of life. Older versions of Ruby may still work, but are unsupported and not recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details about the Ruby support schedule.
Here is how to run a Hello World function on your local machine.
Create a Gemfile listing the Functions Framework as a dependency:
# Gemfile
source "https://rubygems.org"
gem "functions_framework", "~> 1.0"Create a file called app.rb and include the following code. This defines a
simple function called "hello".
# app.rb
require "functions_framework"
FunctionsFramework.http("hello") do |request|
"Hello, world!\n"
endInstall the bundle, and start the framework. This spins up a local web server running your "hello" function:
bundle install
# ...installs the functions_framework gem and other dependencies
bundle exec functions-framework-ruby --target hello
# ...starts the web server in the foregroundIn a separate shell, you can send requests to this function using curl:
curl http://localhost:8080
# Output: Hello, world!Stop the server with CTRL+C.
These guides provide additional getting-started information.
functions-framework-ruby executable to run a local
functions server.The library reference documentation can be found at: https://googlecloudplatform.github.io/functions-framework-ruby
Additional examples are available in the examples directory:
https://github.com/GoogleCloudPlatform/functions-framework-ruby/blob/master/examples/
The source for the Ruby Functions Framework is available on GitHub at https://github.com/GoogleCloudPlatform/functions-framework-ruby. For more information on the Functions Framework contract implemented by this framework, as well as links to Functions Frameworks for other languages, see https://github.com/GoogleCloudPlatform/functions-framework.
The Functions Framework is open source under the Apache 2.0 license. Contributions are welcome. Please see the contributing guide at https://github.com/GoogleCloudPlatform/functions-framework-ruby/blob/master/.github/CONTRIBUTING.md.
Report issues at https://github.com/GoogleCloudPlatform/functions-framework-ruby/issues.
暂无开放 Issues,或尚未同步最近议题。