-
Notifications
You must be signed in to change notification settings - Fork 64
Fn Function Basics Write Up
The following is a write up to replace the STDIN/STDOUT discussion in the Fn introduction. Once we get the wording right, we use that to update other documents and tutorials.
Writing a function for Fn is easy. You just create a small chunk of code that does the following:
- Gets input via STDIN
- Produces output to STDOUT
- Logs any errors to STERR
Your code is deployed to an Fn server where it is staged and ready to go when a call is made for that function. For example, to create deploy an Fn function create a myfunc directory, change into it, and execute these commands:
A function is a small piece of code that takes an input and and writes an output. Our language FDKs make this easy, you just create a small handler function that does the following:
- Reads data passed to the function from Fn and processes it
- Writes output back to Fn
- Logs any errors to STERR
Note: See the tutorial for your language for an example of the function name used for that language.
Your code is deployed to an Fn server where it is staged and ready to go when that function is invoked. For example, to create deploy an Fn function create a myfunc directory, change into it, and execute these commands: