百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
F

functions-framework-ruby

> 编程语言
开源

FaaS(函数即服务)框架,用于编写可移植的 Ruby 函数

164 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

FaaS(函数即服务)框架,用于编写可移植的 Ruby 函数

Functions Framework for 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:

  • Google Cloud Run functions
  • Any other Knative-based environment
  • Your local development machine

The framework allows you to go from:

ruby
FunctionsFramework.http("hello") do |request|
  "Hello, world!\n"
end

To:

bash
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.

Features

  • Define named functions using normal Ruby constructs.
  • Invoke functions in response to requests.
  • Automatically unmarshal events conforming to the CloudEvents spec.
  • Automatically convert most legacy events from Google Cloud services such as Cloud Pub/Sub and Cloud Storage, to CloudEvents.
  • Spin up a local development server for quick testing.
  • Integrate with standard Ruby libraries such as Rack and Minitest.
  • Portable between serverless platforms.
  • Supports all non-end-of-life versions of Ruby.

Supported Ruby versions

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.

Quickstart

Here is how to run a Hello World function on your local machine.

Create a Gemfile listing the Functions Framework as a dependency:

ruby
# 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".

ruby
# app.rb
require "functions_framework"

FunctionsFramework.http("hello") do |request|
  "Hello, world!\n"
end

Install the bundle, and start the framework. This spins up a local web server running your "hello" function:

bash
bundle install
# ...installs the functions_framework gem and other dependencies
bundle exec functions-framework-ruby --target hello
# ...starts the web server in the foreground

In a separate shell, you can send requests to this function using curl:

bash
curl http://localhost:8080
# Output: Hello, world!

Stop the server with CTRL+C.

Documentation

These guides provide additional getting-started information.

  • Writing Functions : How to write functions that respond to HTTP requests, industry-standard CloudEvents, as well as events sent from Google Cloud services such as Pub/Sub and Storage.
  • Testing Functions : How to use the testing features of the Functions Framework to write local unit tests for your functions using standard Ruby testing frameworks such as Minitest and RSpec.
  • Running a Functions Server : How to use the functions-framework-ruby executable to run a local functions server.
  • Deploying Functions : How to deploy functions to Google Cloud Run functions

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/

Development

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· 12 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言