Type: | Package |
Title: | FaaS (Function as a Service) Package |
Version: | 1.4.4 |
Maintainer: | Figueiredo Renato <renato.figueiredo@oregonstate.edu> |
Description: | Allows users to create and deploy the workflow with multiple functions in Function-as-a-Service (FaaS) cloud computing platforms. The 'FaaSr' package makes it simpler for R developers to use FaaS platforms by providing the following functionality: 1) Parsing and validating a JSON-based payload compliant to 'FaaSr' schema supporting multiple FaaS platforms 2) Invoking user functions written in R in a Docker container (derived from rocker), using a list generated from the parser as argument 3) Downloading/uploading of files from/to S3 buckets using simple primitives 4) Logging to files in S3 buckets 5) Triggering downstream actions supporting multiple FaaS platforms 6) Generating FaaS-specific API calls to simplify the registering of a user's workflow with a FaaS platform Supported FaaS platforms: Apache OpenWhisk https://openwhisk.apache.org/ GitHub Actions https://github.com/features/actions Amazon Web Services (AWS) Lambda https://aws.amazon.com/lambda/ Supported cloud data storage for persistent storage: Amazon Web Services (AWS) Simple Storage Service (S3) https://aws.amazon.com/s3/. |
License: | MIT + file LICENSE |
URL: | https://github.com/FaaSr/FaaSr-package |
BugReports: | https://github.com/FaaSr/FaaSr-package/issues |
Depends: | R (≥ 3.5.0) |
Imports: | jsonlite, httr, uuid, paws.application.integration, paws.compute, paws.storage, paws.security.identity, cli, jsonvalidate, base64enc, sodium, askpass |
Suggests: | arrow, glue, rmarkdown, paws.common, testthat, knitr, devtools, utils, methods, withr |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | no |
Packaged: | 2025-04-04 23:18:55 UTC; figueren |
Author: | Figueiredo Renato |
Repository: | CRAN |
Date/Publication: | 2025-04-04 23:30:02 UTC |
.faasr_get_svc
Description
Helper function to get the saved data for json, cred, and operations.
Usage
.faasr_get_svc()
Value
object containing all the information
check_lambda_exists
Description
check if a Lambda function exists
Usage
check_lambda_exists(function_name, cred, lambda_server_info)
Arguments
function_name |
a string for the function name |
cred |
a list form of the credentials |
lambda_server_info |
a list form of Lambda server information: id, keys, region |
check_user_image_exist
Description
check if user provided image exists, if not, return false then stop processing
Usage
check_user_image_exist(
faasr,
action_name,
server_name,
user_image_url,
current_lambda_server_info
)
Arguments
faasr |
a list form of the JSON file |
action_name |
a string for the target action name |
server_name |
a string for the target server |
user_image_url |
a string for FaaSr container image uri |
current_lambda_server_info |
a list form of current Lambda server information: id, keys, region |
Value
logical value TRUE/FALSE for the existence of user images.
execute_command_with_retry
Description
check if aws command run successfully, and retry
Usage
execute_command_with_retry(
function_name,
function_image_url,
cred,
current_lambda_instance,
max_retries = 3,
sleep_seconds = 5
)
Arguments
function_name |
a string for the function name |
function_image_url |
a string for FaaSr container image uri |
cred |
a list form of the credentials |
current_lambda_instance |
a list form of current Lambda server information: id, keys, region |
max_retries |
a integer for the number of maximum tries |
sleep_seconds |
a integer for the time for sleep between retries |
Value
a logical value
faasr
Description
FaaSr library client-side main function It's generating the instance for the user Users can use the functions with the instance generated by "faasr"
Usage
faasr(json_path = NULL, env_path = NULL)
Arguments
json_path |
a string for the json path |
env_path |
a string for the env(credentials) path |
Value
svc; a set of data consisting of functions and data
Examples
if (interactive()){
test <- faasr(json_path="json_path.json", env_path="env_path")
}
faasr_abort_on_multiple_invocations
Description
Ensures that only one Action proceeds to execute a User Function if there are multiple triggers This is necessary because if in the Workflow a function receives multiple triggers, multiple Actions are invoked; however, we don't want to execute the same function multiple times. This function aborts all but the last Action triggered.
Usage
faasr_abort_on_multiple_invocations(faasr, pre)
Arguments
faasr |
list with parsed and validated Payload |
pre |
list with names of functions and corresponding predecessors |
faasr_acquire
Description
Uses locking algorithm with S3 to enforce single User Function execution when there are multiple predecessors Acquire the lock leaving the file into the s3 bucket
Usage
faasr_acquire(faasr)
Arguments
faasr |
list with parsed and validated Payload |
faasr_release
Description
Uses locking algorithm with S3 to enforce single User Function execution when there are multiple predecessors Checking the flag to find any other nodes are seeking for the lock.
Usage
faasr_anyone_else_interested(faasr, target_s3, flag_path, flag_name)
Arguments
faasr |
list with parsed and validated Payload |
target_s3 |
the name of target server |
flag_path |
the string value of the path for the flag |
flag_name |
the string value of the name of the flag |
Value
a logical value if there are other nodes
faasr_arrow_s3_bucket
Description
'test' Uses "arrow" library to set up the configurations with given json file and provide the object to the users
Arguments
server_name |
for string, default value is faasr$DefaultDataStore |
faasr_config |
optional configuration to use instead of global .faasr |
Value
s3 representing object for "arrow"
Examples
# this function can be run only inside the container
if (interactive()){
arrow_s3 <- faasr_arrow_s3_bucket()
arrow_s3$ls
}
faasr_check_workflow_cycle
Description
Uses graph depth-first search algorithm to detect cycles
Usage
faasr_check_workflow_cycle(faasr)
Arguments
faasr |
list with parsed and validated Payload |
Value
graph a graph representation of the Workflow
faasr_collect_sys_env
Description
Collect system environment from the R studio If the credential name is property set (Servername + Key name), this function will use Sys.getenv to collect credentials. If there's already credentials in the list, it skips the procedure.
Usage
faasr_collect_sys_env(faasr, cred)
Arguments
faasr |
a list form of the JSON file |
cred |
a list form of the credentials |
Value
credential list
faasr_delete_file
Description
Helper function to delete a file in an S3 bucket
Arguments
server_name |
string with name of the S3 bucket to use; must match a name declared in the faasr list |
remote_folder |
string with the name of the remote folder where the file is to be deleted from |
remote_file |
string with the name for the file to be deleted |
faasr_config |
optional configuration to use instead of global .faasr |
Value
return nothing / delete the file in the bucket
Examples
# This function can be run only in the container
if (interactive()){
faasr_delete_file(remote_file="test.txt")
}
faasr_delete_log
Description
deletes a FaaSr log file stored in S3 This function deleted a specific FaaSr log file from the user's S3 FaaSrLog bucket
Usage
faasr_delete_log(uuid)
Arguments
uuid |
the UUID of the log to retrieve |
Value
nothing is returned
Examples
if (interactive()){
test <- faasr("test.json", "env")
logs <- test$faasr_delete_log('SOME-UUID')
}
faasr_delete_log_date
Description
deletes all FaaSr logs of a given date This function deleted all FaaSr log files in a given date from the user's S3 FaaSrLog bucket
Usage
faasr_delete_log_date(target_date)
Arguments
target_date |
the date (yyyy-mm-dd) of the log data |
Value
nothing is returned
Examples
if (interactive()){
test <- faasr("test.json", "env")
logs <- test$faasr_delete_log_date('2024-06-05')
}
faasr_get_file
Description
Helper function to download a file from an S3 bucket to local Action folder
Arguments
server_name |
string with name of the S3 bucket to use; must match a name declared in the faasr list |
remote_folder |
string with the name of the remote folder where the file is to be downloaded from |
remote_file |
string with the name for the file to be downloaded from the S3 bucket |
local_folder |
string with the name of the local folder where the file to be downloaded is stored |
local_file |
string with the name of the local file once downloaded |
faasr_config |
optional configuration to use instead of global .faasr |
Value
return nothing / delete the file in the bucket
Examples
# This function can be run only in the container
if (interactive()){
faasr_get_file("remote_folder", "remote_file", "local_folder", "local_file")
}
faasr_get_folder_list
Description
Helper function to get a list of objects in an S3 bucket
Arguments
server_name |
string with name of the S3 bucket to use; must match a name declared in the faasr list |
faasr_prefix |
string with prefix of objects in the S3 bucket |
faasr_config |
optional configuration to use instead of global .faasr |
Value
object_list a list of objects in the bucket
Examples
# This function can be run only in the container
if (interactive()){
faasr_get_folder_list(server_name="My_Minio_Bucket")
}
faasr_get_log
Description
downloads a FaaSr log file stored in S3 This function downloads a specific FaaSr log file from the user's S3 FaaSrLog bucket to local disk This can be useful in debugging by helping the user retrieve the specific log of a FaaSr run
Usage
faasr_get_log(uuid)
Arguments
uuid |
the UUID of the log to retrieve |
Value
nothing is returned; log is downloaded
Examples
if (interactive()){
test <- faasr("test.json", "env")
logs <- test$faasr_get_log('SOME-UUID')
}
faasr_get_log_df
Description
returns a data frame with FaaSr logs stored in S3 This function queries and aggregates FaaSr log information configured with the user's S3 bucket This can be useful in debugging by helping the user identify and download a particular log
Usage
faasr_get_log_df()
Value
this function returns nothing
Examples
if (interactive()){
test <- faasr("test.json", "env")
test$faasr_get_log_df()
}
faasr_get_storage_instance
Description
Helper function to assist log querying/downloading from S3 bucket
Usage
faasr_get_storage_instance(faasr, cred)
Arguments
faasr |
list with parsed and validated Payload |
cred |
credentials |
Value
a list with log server and s3 configuration for paws
faasr_get_user_function_args
Description
Helper function to extract arguments of a User Function from the faasr parsed Payload list
Usage
faasr_get_user_function_args(faasr)
Arguments
faasr |
list with parsed and validated Payload |
Value
args list of User Function arguments if no args provided, return empty list
faasr_httr_request
Description
the help function to send the curl request to the github by using the "httr" library.
Usage
faasr_httr_request(token, url, body = list(), type)
Arguments
token |
a string for the github token |
url |
a string of url |
body |
a list of body |
type |
REST API values; GET/PUT/DELETE/PATCH/POST |
Value
response: response status; 200/202/204/400/etc
faasr_init_log_folder
Description
This function creates an initial log folder in S3; it is called only at the entry point of a Workflow The folder name is a concatenation of FaaSrLog and InvocationID from the Payload. The folder name needs to be a unique ID. If the user doesn't provide InvocationID, generate a UUID If the folder already exists, abort with an error
Usage
faasr_init_log_folder(faasr)
Arguments
faasr |
list with parsed and validated Payload |
Value
faasr a list of json file, UUID updated.
faasr_invoke_workflow
Description
invoke workflow This function aggregates the invoke workflow function for openwhisk, github actions and lambda This can be used as a cross-platform function
Usage
faasr_invoke_workflow(FunctionInvoke = NULL, ...)
Arguments
FunctionInvoke |
a string for invoke function |
... |
a string for underlying functions |
Value
return nothing / invokes the FaaS platform.
Examples
if (interactive()){
test <- faasr("test.json", "env")
test$invoke_workflow
}
faasr_rsm
Description
Uses locking algorithm with S3 to enforce single User Function execution when there are multiple predecessors
Usage
faasr_rsm(faasr)
Arguments
faasr |
list with parsed and validated Payload |
faasr_log
Description
Helper function to append to the log file residing in an S3 bucket the name of the S3 server is implicit from the validated JSON payload, key LoggingServer the log file is a concatenation of folder "logs" and file name "faasr_log_" + InvocationID + ".txt"
Arguments
faasr |
list with parsed and validated Payload |
log_message |
string message to be appended to the log |
Value
return nothing / leave the log to the bucket
Examples
# This function can be run only in the container
if (interactive()){
log_message <- "test message"
faasr_log(log_message)
}
faasr_ow_httr_request
Description
the help function to send the curl request to the openwhisk by using the "httr" library.
Usage
faasr_ow_httr_request(
faasr,
server,
action,
type,
body = list(),
ssl = TRUE,
namespace = NULL
)
Arguments
faasr |
a list form of the JSON file |
server |
a string for the target server |
action |
a string for the target action: /actions, /triggers, /rules |
type |
REST API values; GET/PUT/DELETE/PATCH/POST |
body |
a list of body |
ssl |
SSL CA check; for the SSL certificate: FALSE |
namespace |
a string for the specific namespace e.g., /whisk.system |
Value
an integer value for the response
faasr_parse
Description
This function uses JSON parsing and validation to ensure the Payload is compliant Two checks are made here: 1) is it a valid JSON format? and 2) does it conform to the FaaSr JSON schema? If both checks pass, return a list with all the parsed key/value pairs Otherwise, abort
Usage
faasr_parse(faasr_payload)
Arguments
faasr_payload |
JSON Payload provided upon Action invocation by the FaaS platform |
Value
faasr list with parsed and validated Payload
Examples
# This function can be run only in the container
if (interactive()){
faasr <- faasr_parse(faasr_payload)
}
faasr_predecessors_list
Description
Get the predecessors list, by using the graph from faasr_check_workflow
Usage
faasr_predecessors_list(faasr, graph)
Arguments
faasr |
list with parsed and validated Payload |
graph |
graph constructed by the depth first search in faasr_check_workflow_cycle |
Value
a list of "function:predecessors" pairs.
faasr_put_file
Description
Helper function to upload a file from a local Action folder to an S3 bucket
Arguments
server_name |
string with name of the S3 bucket to use; must match a name declared in the faasr list |
local_folder |
string with the name of the local folder where the file to be uploaded resides |
local_file |
string with the name of the local file to be uploaded |
remote_folder |
string with the name of the remote folder where the file is to be uploaded to |
remote_file |
string with the name for the file once uploaded to the S3 bucket |
faasr_config |
optional configuration to use instead of global .faasr |
Value
return nothing / put the file into the bucket
Examples
# This function can be run only in the container
if (interactive()){
faasr_put_file("local_folder", "local_file", "remote_folder", "remote_file")
}
faasr_rank
Description
Helper function to let users identify the rank and max rank in the function This function is used by users in the container.
Usage
faasr_rank()
Value
return a list of Rank & MaxRank
Examples
# This function can be run only in the container
if (interactive()){
rank_info <- faasr_rank()
MaxRank <- rank_info$MaxRank
Rank <- rank_info$Rank
}
faasr_register_workflow
Description
Client tools for registering actions This aggregates openwhisk, github actions and lambda's register functions
Usage
faasr_register_workflow(...)
Arguments
... |
inputs for timeout, cron, and memory |
Value
return nothing / executes the FaaS
Examples
if (interactive()){
test <- faasr("test.json", "env")
test$register_workflow
}
faasr_register_workflow_aws_lambda
Description
starts to register functions in the JSON file for AWS-Lambda
Usage
faasr_register_workflow_aws_lambda(
faasr,
cred,
memory = 1024,
timeout = 600,
storage = 1024
)
Arguments
faasr |
a list form of the JSON file |
cred |
a list form of the credentials |
memory |
an integer for the max size of memory |
timeout |
an integer for the max length of timeout |
faasr_register_workflow_aws_lambda_function_build
Description
Create aws lambda functions
Usage
faasr_register_workflow_aws_lambda_function_build(
faasr,
lambda_function_info,
function_image_list,
aws_lambda_role_name,
cred,
lambda_server_info,
memory = 1024,
timeout = 600,
storage = 512
)
Arguments
faasr |
a list form of the JSON file |
lambda_function_info |
a list form of lambda function information: name, actions |
function_image_list |
a list form of lambda function information: name, images |
aws_lambda_role_name |
a string for the lambda role name |
cred |
a list form of the credentials |
lambda_server_info |
a list form of Lambda server information: id, keys, region |
memory |
an integer for the max size of memory |
timeout |
an integer for the max length of timeout |
faasr_register_workflow_aws_lambda_role_create
Description
create the aws-lambda role named "faasr-lambda-role"
Usage
faasr_register_workflow_aws_lambda_role_create(faasr, cred, lambda_server_info)
Arguments
faasr |
a list form of the JSON file |
cred |
a list form of the credentials |
lambda_server_info |
a list form of Lambda server information: id, keys, region |
Value
lambda-role-name a string for the lambda role name
faasr_register_workflow_git_local_repo
Description
Create a local git repository
Usage
faasr_register_workflow_git_local_repo(repo, ref)
Arguments
repo |
a string for the target repository name |
ref |
a string for the branch of target repository |
faasr_register_workflow_git_remote_env
Description
set env(secrets and variables) to the remote repository
Usage
faasr_register_workflow_git_remote_env(repo, cred, token)
Arguments
repo |
a string for the target repository name |
cred |
a list form of the credentials |
token |
a string for the github token |
faasr_register_workflow_git_remote_repo
Description
create / push git remote repository
Usage
faasr_register_workflow_git_remote_repo(token, check, private, repo, ref)
Arguments
token |
a string for the github token |
check |
a logical value whether the remote repository exists |
private |
a logical value to make repository private or not |
repo |
a string for the target repository name |
ref |
a string for the branch of target repository |
Value
a integer value for the result
faasr_register_workflow_github_actions
Description
register the workflow for github actions. parse faasr to get the repository list and actions. create a local/remote repository for the FaaSr actions.
Usage
faasr_register_workflow_github_actions(
faasr,
cred,
cron = NULL,
runner = FALSE
)
Arguments
faasr |
a list form of the JSON file |
cred |
a list form of the credentials |
cron |
a string for cron data e.g., */5 * * * * |
runner |
a logical value; enable runner |
faasr_register_workflow_github_create_dir
Description
Create the directory for the workflows
Usage
faasr_register_workflow_github_create_dir(server, repo)
Arguments
server |
a string for the server name |
repo |
a string for the target repository name |
faasr_register_workflow_github_create_env
Description
Create the environment file .gitignore
Usage
faasr_register_workflow_github_create_env(server, repo)
Arguments
server |
a string for the server name |
repo |
a string for the target repository name |
faasr_register_workflow_github_create_payload
Description
Create the payload JSON file named "payload.json"
Usage
faasr_register_workflow_github_create_payload(faasr, repo)
Arguments
faasr |
a list form of the JSON file |
repo |
a string for the target repository name |
faasr_register_workflow_github_create_readme
Description
create README.md file for repository description
Usage
faasr_register_workflow_github_create_readme(repo)
Arguments
repo |
a string for the target repository name |
faasr_register_workflow_github_create_yml_file
Description
Create a yaml workflow file with the container name
Usage
faasr_register_workflow_github_create_yml_file(
faasr,
actionname,
repo,
cron = NULL,
runner = FALSE
)
Arguments
faasr |
a list form of the JSON file |
actionname |
a string for the action name |
repo |
a string for the target repository name |
cron |
a string for cron data e.g., */5 * * * * |
runner |
a logical value; enable runner |
faasr_register_workflow_github_repo_exists
Description
Check the remote repository is existing on the github by sending the GET request. If it exists, return TRUE, doesn't exist, return FALSE
Usage
faasr_register_workflow_github_repo_exists(faasr_token, repo)
Arguments
faasr_token |
a string for the github token |
repo |
a string for the target repository name |
Value
a logical value; if exists, return TRUE, doesn't exist, return FALSE
faasr_register_workflow_github_repo_lists
Description
Parse the faasr and get the list of function:repository Find actions which is using "Github Actions" return value's key is action and value is server name.
Usage
faasr_register_workflow_github_repo_lists(faasr)
Arguments
faasr |
a list form of the JSON file |
Value
a list of "action:server name" pairs.
faasr_register_workflow_github_repo_question
Description
Ask users to update the repository
Usage
faasr_register_workflow_github_repo_question(check, repo)
Arguments
check |
a logical value |
repo |
a string for the target repository name |
Value
a logical value to make repository private or not
faasr_register_workflow_lambda_function_image
Description
Get aws lambda function image list
Usage
faasr_register_workflow_lambda_function_image(faasr, lambda_server_info)
Arguments
faasr |
a list form of the JSON file |
lambda_server_info |
a list form of Lambda server information: id, keys, region |
Value
function_image_list a list form of lambda function information: name, images
faasr_register_workflow_lambda_function_info
Description
Get aws lambda function information
Usage
faasr_register_workflow_lambda_function_info(
faasr,
cred,
lambda_server_info,
lambda_function_info
)
Arguments
faasr |
a list form of the JSON file |
cred |
a list form of the credentials |
lambda_server_info |
a list form of Lambda server information: id, keys, region |
lambda_function_info |
a list form of lambda function information: name, actions |
Value
lambda_function_info a list form of lambda function information: name, actions, create/update
faasr_register_workflow_lambda_function_lists
Description
Get aws lambda function list
Usage
faasr_register_workflow_lambda_function_lists(faasr)
Arguments
faasr |
a list form of the JSON file |
Value
lambda_function_info a list form of lambda function information: name, actions
faasr_register_workflow_lambda_server_info
Description
Get aws lambda server information
Usage
faasr_register_workflow_lambda_server_info(faasr, cred)
Arguments
faasr |
a list form of the JSON file |
cred |
a list form of the credentials |
Value
lambda_server_info a list form of Lambda server information: id, keys, region
faasr_register_workflow_openwhisk
Description
register the workflow for openwhisk. parse faasr to get the server list and actions. create a actions for the FaaSr actions.
Usage
faasr_register_workflow_openwhisk(
faasr,
cred,
ssl = TRUE,
memory = 1024,
timeout = 600,
storage = NULL
)
Arguments
faasr |
a list form of the JSON file |
cred |
a list form of the credentials |
ssl |
SSL CA check; for the SSL certificate: FALSE |
memory |
an integer for the max size of memory |
timeout |
an integer for the max length of timeout |
faasr_register_workflow_openwhisk_action_lists
Description
Parse the faasr and get the list of function:server Find actions which is using "OpenWhisk" return value's key is action and value is server name.
Usage
faasr_register_workflow_openwhisk_action_lists(faasr)
Arguments
faasr |
a list form of the JSON file |
Value
an list of "action name: server name" pairs
faasr_register_workflow_openwhisk_check_exists
Description
Check the remote repository is existing on the openwhisk by sending the GET request. If it exists, return TRUE, doesn't exist, return FALSE
Usage
faasr_register_workflow_openwhisk_check_exists(ssl, action, server, faasr)
Arguments
ssl |
SSL CA check; for the SSL certificate: FALSE |
action |
a string for the target action: /actions, /triggers, /rules |
server |
a string for the target server |
faasr |
a list form of the JSON file |
Value
a logical value; if exists, return TRUE, doesn't exist, return FALSE
faasr_register_workflow_openwhisk_check_user_input
Description
Ask user input for the openwhisk
Usage
faasr_register_workflow_openwhisk_check_user_input(check, actionname, type)
Arguments
check |
a logical value for target existence |
actionname |
a string for the target action name |
type |
a string for the action type; actions/triggers/rules |
Value
a logical value for the overwrite
faasr_register_workflow_openwhisk_create_action
Description
Create an action if it already exists and user wants, update the action
Usage
faasr_register_workflow_openwhisk_create_action(
ssl,
actionname,
server,
faasr,
memory,
timeout,
check
)
Arguments
ssl |
SSL CA check; for the SSL certificate: FALSE |
actionname |
a string for the target action name |
server |
a string for the target server |
faasr |
a list form of the JSON file |
memory |
an integer for the max size of memory |
timeout |
an integer for the max length of timeout |
check |
a logical value for target existence |
faasr_release
Description
Uses locking algorithm with S3 to enforce single User Function execution when there are multiple predecessors Release the lock by deleting the lock file in the bucket
Usage
faasr_release(faasr)
Arguments
faasr |
list with parsed and validated Payload |
faasr_replace_values
Description
replace dummy keys with real keys Dummy key format: Servername + "_" + Key Name with CAPITAL LETTER e.g., My_OW_Account + API.key = My_OW_Account_API_KEY
Usage
faasr_replace_values(faasr, cred)
Arguments
faasr |
a list form of the JSON file |
cred |
a list form of the credentials |
Value
faasr a list form of the JSON file with real keys
Examples
if (interactive()){
faasr_with_cred <- faasr_replace_values(faasr, cred)
}
faasr_run_user_function
Description
Run user functions and leave the state information
Usage
faasr_run_user_function(.faasr)
Arguments
.faasr |
list with parsed and validated Payload |
Value
return nothing / executes the given user function
Examples
# This function can be run only in the container
if (interactive()){
faasr_run_user_function(.faasr)
}
faasr_s3_check
Description
Check 1. server's Endpoint&Region and Endpoint has a valid form(http). 2. send a req for the head of the bucket to check the status of s3 servers. 3. Check that the bucket name exists.
Arguments
faasr |
list with parsed and validated Payload |
Value
faasr list with parsed and validated payload
faasr_set_workflow_timer
Description
set cron timer for workflow This function aggregates the set cron timer function for openwhisk, github actions and lambda This can be used as a cross-platform function
Usage
faasr_set_workflow_timer(cron, target = NULL, ...)
Arguments
cron |
a string for cron data e.g., */5 * * * * |
target |
a string for specific function |
... |
a string for underlying functions |
Value
return nothing / set the workflow timer
Examples
if (interactive()){
test <- faasr("test.json", "env")
test$set_workflow_timer("*/5 * * * *")
}
faasr_set_workflow_timer_gh
Description
set/unset cron timer for the github actions.
Usage
faasr_set_workflow_timer_gh(
faasr,
cred,
actionname,
cron = NULL,
unset = FALSE
)
Arguments
faasr |
a list form of the JSON file |
cred |
a list form of the credentials |
actionname |
a string for the target action name |
cron |
a string for cron data e.g., */5 * * * * |
unset |
a logical value; set timer(FALSE) or unset timer(TRUE) |
faasr_set_workflow_timer_ld
Description
# set/unset workflow cron timer for lambda
Usage
faasr_set_workflow_timer_ld(faasr, cred, target, cron, unset = FALSE)
Arguments
faasr |
a list form of the JSON file |
cred |
a list form of the credentials |
target |
a string for the target action |
cron |
a string for cron data e.g., */5 * * * * |
unset |
a logical value; set timer(FALSE) or unset timer(TRUE) |
faasr_set_workflow_timer_ow
Description
# set/unset workflow cron timer for openwhisk
Usage
faasr_set_workflow_timer_ow(
faasr,
cred,
target,
cron,
unset = FALSE,
ssl = TRUE
)
Arguments
faasr |
a list form of the JSON file |
cred |
a list form of the credentials |
target |
a string for the target action |
cron |
a string for cron data e.g., */5 * * * * |
unset |
a logical value; set timer(FALSE) or unset timer(TRUE) |
ssl |
SSL CA check; for the SSL certificate: FALSE |
faasr_start
Description
This is the entry-point FaaSr Function that is invoked by a FaaS platform when an Action is instantiated Terminology to clarify the various modules involved:
* Action: an instance of a Docker container instantiated by a FaaS platform * User Function: a single function written in R; at runtime, it is executed by a single Action * FaaSr Function: function implemented by the FaaSr package to implement all the logic necessary to manage the execution of a User Function within an Action. A FaaSr function has a prefix faasr_ * User Workflow: a graph where each vertex represents a single User Functions and each edge represents a trigger * Payload: a JSON-formatted text file that conforms to the FaaSr schema. It is delivered by the FaaS platform for each Action. It describes the entire User Workflow and may contain credentials for FaaS and S3 services
faasr_start calls other FaaSr Functions to go through the following steps:
* Parse the Payload and ensure that it conforms to the FaaSr JSON schema; otherwise, abort * Build the User Workflow graph from Payload and ensure it is cycle-free; otherwise, abort * Initialize the logs folder in an S3 bucket, only if this is the entry point to the User Workflow * Ensure only a single User Function runs if it has multiple predecessors; otherwise, abort * Invoke the User Function, supplying the parsed payload as a list argument * Update the logs folder to assert that this User Function has completed * Generate triggers to start Actions that will run the next User Functions, if there are any in the User Workflow
Arguments
faasr_payload |
JSON Payload provided upon Action invocation by the FaaS platform |
Value
faasr a list form of JSON payload
Examples
# This function can be run only in the container
if (interactive()){
faasr <- faasr_start(faasr_payload)
}
faasr_test
Description
Client tools for local tests Users can use local test by using both for Docker and local file system
Usage
faasr_test(
use_docker = list(use = FALSE, version = docker_default_version, image =
docker_default_image)
)
Arguments
use_docker |
a list of docker configuration - use, version and image. |
Value
return nothing / executes the FaaS
Examples
if (interactive()){
test <- faasr("test.json", "env")
test$faasr_test()
test$faasr_test(use_docker=list(use=TRUE, version="test", image="docker.io/test/test-docker:image"))
}
faasr_trigger
Description
Uses FaaS-specific APIs to generate triggers to execute downstream User Function Currently supports: * Apache OpenWhisk * AWS Lambda * GitHub Actions
Usage
faasr_trigger(faasr)
Arguments
faasr |
list with parsed and validated Payload |
Value
return nothing / send requests to the FaaS servers.
Examples
# This function can be run only in the container
if (interactive()){
faasr_trigger(faasr)
}
faasr_unset_workflow_timer
Description
unset cron timer for workflow This function aggregates the unset cron timer function for openwhisk, github actions and lambda This can be used as a cross-platform function
Usage
faasr_unset_workflow_timer(target = NULL, ...)
Arguments
target |
a string for specific function |
... |
a string for underlying functions |
Value
return nothing / unset the workflow timer
Examples
if (interactive()){
test <- faasr("test.json", "env")
test$unset_workflow_timer()
}
faasr_workflow_invoke_github
Description
invoke the github actions workflow on the github repository. Async version; does not wait for the result This will be invoked by faasr_workflow_invoke function
Usage
faasr_workflow_invoke_github(faasr, cred, faas_name, actionname)
Arguments
faasr |
a list form of the JSON file |
cred |
a list form of the credentials |
faas_name |
a string for the target server name |
actionname |
a string for the target action name |
faasr_workflow_invoke_lambda
Description
Invoke a workflow for the lambda this function is invoked by faasr_workflow_invoke
Usage
faasr_workflow_invoke_lambda(faasr, cred, faas_name, actionname)
Arguments
faasr |
a list form of the JSON file |
cred |
a list form of the credentials |
faas_name |
a string for the target server |
actionname |
a string for the target action name |
faasr_workflow_invoke_openwhisk
Description
Invoke a workflow for the openwhisk this function is invoked by faasr_workflow_invoke
Usage
faasr_workflow_invoke_openwhisk(faasr, cred, faas_name, actionname, ssl = TRUE)
Arguments
faasr |
a list form of the JSON file |
cred |
a list form of the credentials |
faas_name |
a string for the target server |
actionname |
a string for the target action name |
ssl |
SSL CA check; for the SSL certificate: FALSE |