- Notifications
You must be signed in to change notification settings - Fork45
FaaS (Function as a service) framework for writing portable Ruby functions
License
GoogleCloudPlatform/functions-framework-ruby
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
An open source framework for writing lightweight, portable Ruby functions thatrun in a serverless environment. Functions written to this Framework will runin many different environments, including:
- Google Cloud Run functions
- Any otherKnative-based environment
- Your local development machine
The framework allows you to go from:
FunctionsFramework.http("hello")do |request|"Hello, world!\n"end
To:
curl http://my-url# Output: Hello, world!
Running on a fully-managed or self-managed serverless environment, withoutrequiring an HTTP server or complicated request handling logic.
- Define named functions using normal Ruby constructs.
- Invoke functions in response to requests.
- Automatically unmarshal events conforming to theCloudEvents spec.
- Automatically convert most legacy events from Google Cloud services suchas 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.
This library is supported on Ruby 3.0+.
Google provides official support for Ruby versions that are actively supportedby Ruby Core—that is, Ruby versions that are either in normal maintenance orin security maintenance, and not end of life. Older versions of Rubymaystill work, but are unsupported and not recommended. Seehttps://www.ruby-lang.org/en/downloads/branches/ for details about the Rubysupport schedule.
Here is how to run a Hello World function on your local machine.
Create aGemfile
listing the Functions Framework as a dependency:
# Gemfilesource"https://rubygems.org"gem"functions_framework","~> 1.0"
Create a file calledapp.rb
and include the following code. This defines asimple function called "hello".
# app.rbrequire"functions_framework"FunctionsFramework.http("hello")do |request|"Hello, world!\n"end
Install the bundle, and start the framework. This spins up a local web serverrunning your "hello" function:
bundle install# ...installs the functions_framework gem and other dependenciesbundleexec 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:
curl http://localhost:8080# Output: Hello, world!
Stop the server withCTRL+C
.
These guides provide additional getting-started information.
- Writing Functions: How to write functions that respond to HTTP requests, industry-standardCloudEvents, as well as events sent from GoogleCloud services such asPub/Sub andStorage.
- Testing Functions: How to use the testing features of the Functions Framework to write localunit tests for your functions using standard Ruby testing frameworks suchasMinitest andRSpec.
- Running a Functions Server: How to use the
functions-framework-ruby
executable to run a localfunctions server. - Deploying Functions: How to deploy functions toGoogle Cloud Run functions
The library reference documentation can be found at:https://googlecloudplatform.github.io/functions-framework-ruby
Additional examples are available in theexamples
directory:https://github.com/GoogleCloudPlatform/functions-framework-ruby/blob/master/examples/
The source for the Ruby Functions Framework is available on GitHub athttps://github.com/GoogleCloudPlatform/functions-framework-ruby. For moreinformation on the Functions Framework contract implemented by this framework,as well as links to Functions Frameworks for other languages, seehttps://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 athttps://github.com/GoogleCloudPlatform/functions-framework-ruby/blob/master/.github/CONTRIBUTING.md.
Report issues athttps://github.com/GoogleCloudPlatform/functions-framework-ruby/issues.
About
FaaS (Function as a service) framework for writing portable Ruby functions
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.