An open source FaaS (Function as a service) framework for writing portable R functions.
The Functions Framework lets you write lightweight functions that run in many different environments, including:
The framework allows you to go from:
hello <- function(req, res){ return("Hello World!") }
To:
curl http://my-url # Output: Hello world!
All without needing to worry about writing an HTTP server or complicated request handling logic.
install.packages("devtools", repos='http://cran.us.r-project.org') library(devtools) install_github("averikitsch/functions-framework-r/src/functionsframework")Quickstart: Hello, World on your local machine
Create a main.R
file with the following contents:
hello <- function(req, res){ return("Hello World!") }
Create a create-app.R
file with the following contents:
library(functionsframework) createApp()
or add to the end of main.R
.
Run the following command:
Rscript create-app.R --target=hello
Open http://localhost:8080/ in your browser and see Hello world!.
Run your function on serverless platformsOnce you've written your function and added the Functions Framework to your file, all that's left is to create a container image. Check out the Cloud Run quickstart to create a container image and deploy it to Cloud Run. You'll write a Dockerfile
when you build your container. This Dockerfile
allows you to specify exactly what goes into your container (including custom binaries, a specific operating system, and more).
Cloud Run implements the Knative Serving API. The Functions Framework is designed to be compatible with Knative environments. Just build and deploy your container to a Knative environment.
Configure the Functions FrameworkYou can configure the Functions Framework using command-line flags or environment variables. If you specify both, the environment variable will be ignored.
Command-line flag Environment variable Description--port
PORT
The port on which the Functions Framework listens for requests. Default: 8080
--target
FUNCTION_TARGET
The name of the exported function to be invoked in response to requests. Default: function
--signature_type
FUNCTION_SIGNATURE_TYPE
The signature used when writing your function. Controls unmarshalling rules and determines which arguments are used to invoke your function. Default: http
; accepted values: http
or event
--source
FUNCTION_SOURCE
The path to the file containing your function. Default: main.R
(in the current working directory)
Contributions to this library are welcome and encouraged. See CONTRIBUTING for more information on how to get started.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4