Skip to content

Fn Function Basics Write Up

Michael J Williams edited this page Oct 4, 2018 · 7 revisions

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.

Old Wording

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:

New Wording

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: