Introducing Ruby on Google Cloud Functions
Cloud Functions, Google Cloud’s Function as a Service (FaaS) offering, is a lightweight compute platform for creating single-purpose, stand-alone functions that respond to events, without having to manage a server or runtime environment. Cloud functions are a great fit for serverless, application, mobile or IoT backends, real-time data processing systems, video, image and sentiment analysis and even things like chatbots, or virtual assistants.
Today we’re bringing support for Ruby, a popular, general-purpose programming language, to Cloud Functions. With the Functions Framework for Ruby, you can write idiomatic Ruby functions to build business-critical applications and integration layers. And with Cloud Functions for Ruby, now in Preview, you can deploy functions in a fully managed Ruby 2.6 or Ruby 2.7 environment, complete with access to resources in a private VPC network. Ruby functions scale automatically based on your load. You can write HTTP functions to respond to HTTP events, and CloudEvent functions to process events sourced from various cloud and Google Cloud services including Pub/Sub, Cloud Storage and Firestore.
You can develop functions using the Functions Framework for Ruby, an open source functions-as-a-service framework for writing portable Ruby functions. With Functions Framework you develop, test, and run your functions locally, then deploy them to Cloud Functions, or to another Ruby environment.
Writing Ruby functions
The Functions Framework for Ruby supports HTTP functions and CloudEvent functions. A HTTP cloud function is very easy to write in idiomatic Ruby. Below, you’ll find a simple HTTP function for Webhook/HTTP use cases.
CloudEvent functions on the Ruby runtime can also respond to industry standard CNCF CloudEvents. These events can be from various Google Cloud services, such as Pub/Sub, Cloud Storage and Firestore.
Here is a simple CloudEvent function working with Pub/Sub.
The Ruby Functions Framework fits comfortably with popular Ruby development processes and tools. In addition to writing functions, you can test functions in isolation using Ruby test frameworks such as Minitest and RSpec, without needing to spin up or mock a web server. Here is a simple RSpec example:
Try Cloud Functions for Ruby today
Cloud Functions for Ruby is ready for you to try today. Read the Quickstart guide, learn how to write your first functions, and try it out with a Google Cloud free trial. If you want to dive a little bit deeper into the technical aspects, you can also read our Ruby Functions Framework documentation. If you’re interested in the open-source Functions Framework for Ruby, please don’t hesitate to have a look at the project and potentially even contribute. We’re looking forward to seeing all the Ruby functions you write!
Related Google News:
- Solve for the United Nations’ Sustainable Development Goals with Google technologies in this… January 12, 2021
- Migrating data, technology and people to Google Cloud January 12, 2021
- 4 best practices for ensuring privacy and security of your data in Cloud Storage January 12, 2021
- Introducing Google News performance report January 12, 2021
- Deploy and manage Google Credential Provider for Windows via the Admin console January 11, 2021
- Streaming augmented reality with Google Cloud January 11, 2021
- Google Cloud and SAP demonstrate massive scalability for financial services customers January 11, 2021
- Going global: Workday uses Google Cloud AI to accelerate document processing January 11, 2021