github.com/iron-io/functions@v0.0.0-20180820112432-d59d7d1c40b2/docs/function-file.md (about) 1 # Function files 2 3 Functions files are used to assist fn to help you when creating functions. 4 5 The files can be named as: 6 7 - func.yaml 8 - func.json 9 10 An example of a function file: 11 12 ```yaml 13 name: iron/hello 14 version: 0.0.1 15 type: sync 16 memory: 128 17 config: 18 key: value 19 key2: value2 20 keyN: valueN 21 headers: 22 content-type: 23 - text/plain 24 build: 25 - make 26 - make test 27 ``` 28 29 `name` is the name and tag to which this function will be pushed to and the 30 route updated to use it. 31 32 `path` (optional) allows you to overwrite the calculated route from the path 33 position. You may use it to override the calculated route. If you plan to use 34 `fn test --remote=""`, this is mandatory. 35 36 `version` represents current version of the function. When deploying, it is 37 appended to the image as a tag. 38 39 `type` (optional) allows you to set the type of the route. `sync`, for functions 40 whose response are sent back to the requester; or `async`, for functions that 41 are started and return a task ID to customer while it executes in background. 42 Default: `sync`. 43 44 `memory` (optional) allows you to set a maximum memory threshold for this 45 function. If this function exceeds this limit during execution, it is stopped 46 and error message is logged. Default: `128`. 47 48 `headers` (optional) is a set of HTTP headers to be returned in the response of 49 this function calls. 50 51 `config` (optional) is a set of configurations to be passed onto the route 52 setup. These configuration options shall override application configuration 53 during functions execution. 54 55 `build` (optional) is an array of local shell calls which are used to help 56 building the function. 57 58 ## Hot functions 59 60 hot functions support also adds two extra options to this configuration file. 61 62 `format` (optional) is one of the streaming formats covered at [function-format.md](function-format.md). 63 64 `max_concurrency` (optional) is the maximum of hot functions per node to be 65 started for a certain function. It defaults to one per function. If you 66 understand you need more processing power, make sure to raise this number. 67 Keep in mind that if there is not available memory to execute the configured 68 workload, it will fail to start new hot functions. 69 70 ## Testing functions 71 72 `tests` (optional) is an array of tests that can be used to valid functions both 73 locally and remotely. It has the following structure 74 75 ```yaml 76 tests: 77 - name: envvar 78 in: "inserted stdin" 79 out: "expected stdout" 80 err: "expected stderr" 81 env: 82 envvar: trololo 83 ``` 84 85 `in` (optional) is a string that is going to be sent to the file's declared 86 function. 87 88 `out` (optional) is the expected output for this function test. It is present 89 both in local and remote executions. 90 91 `err` (optional) similar to `out`, however it read from `stderr`. It is only 92 available for local machine tests. 93 94 `env` (optional) is a map of environment variables that are injected during 95 tests.