mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Plan for func.yaml file changes for triggers. fnproject/cli#324 (#1115)
The changes aim to be as minimal as possible: * Remove no longer available options * Add a schema version to the file for validation * Add trigger list block
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
# Function files
|
||||
# Func files
|
||||
|
||||
Functions files are used to assist fn to help you when creating functions.
|
||||
Func files are used to assist the fn-project to help you when creating functions.
|
||||
|
||||
An example of a function file:
|
||||
An example of a func file:
|
||||
|
||||
```yaml
|
||||
schema_version: 20180708
|
||||
name: fnproject/hello
|
||||
version: 0.0.1
|
||||
type: sync
|
||||
runtime: java
|
||||
build_image: x/y
|
||||
run_image: x/y
|
||||
cmd: com.example.fn.HelloFunction::handleRequest
|
||||
memory: 128
|
||||
timeout: 30
|
||||
config:
|
||||
key: value
|
||||
key2: value2
|
||||
keyN: valueN
|
||||
headers:
|
||||
Content-Type:
|
||||
- text/html
|
||||
build_image: x/y
|
||||
run_image: x/y
|
||||
build:
|
||||
- make
|
||||
- make test
|
||||
@@ -27,40 +27,34 @@ expects:
|
||||
required: true
|
||||
- name: SECRET_2
|
||||
required: false
|
||||
triggers:
|
||||
- name: triggerOne
|
||||
type: http
|
||||
source: /trigger-path
|
||||
```
|
||||
`schema_version` represents the version of the specification for this file.
|
||||
|
||||
`name` is the name and tag to which this function will be pushed to and the
|
||||
route updated to use it.
|
||||
|
||||
`path` (optional) allows you to overwrite the calculated route from the path
|
||||
position. You may use it to override the calculated route. If you plan to use
|
||||
`fn test --remote=""`, this is mandatory.
|
||||
|
||||
`version` represents current version of the function. When deploying, it is
|
||||
appended to the image as a tag.
|
||||
`version` represents the current version of the function. When deploying, it is appended to the image as a tag.
|
||||
|
||||
`runtime` represents programming language runtime, for example,
|
||||
'go', 'python', 'java', etc. The runtime 'docker' will use the existing Dockerfile if one exists.
|
||||
|
||||
`build_image` (optional) base Docker image to use for building your function. Default images used are the `dev` tagged images from the [dockers repo](https://github.com/fnproject/dockers).
|
||||
|
||||
`type` (optional) allows you to set the type of the route. `sync`, for functions
|
||||
whose response are sent back to the requester; or `async`, for functions that
|
||||
are started and return a call ID to customer while it executes in background.
|
||||
Default: `sync`.
|
||||
`run_image` (optional) base Docker image to use for running your function, part of a multi-stage build. Function will be built with `build_image` and run with `run_image`. Default images used from the [dockers repo](https://github.com/fnproject/dockers).
|
||||
|
||||
`cmd` (optional) execution command for jvm based runtimes
|
||||
|
||||
`entrypoint` (optional) excution entry point for native runtimes
|
||||
|
||||
`memory` (optional) allows you to set a maximum memory threshold for this
|
||||
function. If this function exceeds this limit during execution, it is stopped
|
||||
and error message is logged. Default: `128`.
|
||||
|
||||
`cpus` (optional) is the amount of available CPU cores for this function. For example, `100m` or `0.1`
|
||||
+will allow the function to consume at most 1/10 of a CPU core on the running machine. It
|
||||
+expects to be a string in MilliCPUs format ('100m') or floating-point number ('0.5').
|
||||
+Default: unlimited.
|
||||
|
||||
`timeout` (optional) is the maximum time a function will be allowed to run. Default is 30 seconds.
|
||||
|
||||
`headers` (optional) is a set of HTTP headers to be returned in the response of
|
||||
this function calls.
|
||||
`timeout` (optional) is the maximum time a function will be allowed to run. Default is 30 seconds.
|
||||
|
||||
`config` (optional) is a set of configuration variables to be passed onto the function as environment variables.
|
||||
These configuration options shall override application configuration during functions execution. See [Configuration](configs.md)
|
||||
@@ -72,15 +66,4 @@ if found in your local environment. If these vars are not found, local testing w
|
||||
`build` (optional) is an array of local shell calls which are used to help
|
||||
building the function. TODO: Deprecate this?
|
||||
|
||||
`build_image` (optional) base Docker image to use for building your function. Default images used are the `dev` tagged images from the [dockers repo](https://github.com/fnproject/dockers).
|
||||
|
||||
`run_image` (optional) base Docker image to use for running your function, part of a multi-stage build. Function will be built with `build_image` and run with `run_image`. Default images used from the [dockers repo](https://github.com/fnproject/dockers).
|
||||
|
||||
## Hot functions
|
||||
|
||||
hot functions support also adds two extra options to this configuration file.
|
||||
|
||||
`format` (optional) is one of the streaming formats covered at [function-format.md](function-format.md).
|
||||
|
||||
`idle_timeout` (optional) is the time in seconds a container will remain alive without receiving any new requests;
|
||||
hot functions will stay alive as long as they receive a request in this interval. Default: `30`.
|
||||
`triggers` (optional) is an array of `trigger` entities that specific triggers for the function. See [Trigger](triggers.md).
|
||||
17
docs/developers/triggers.md
Normal file
17
docs/developers/triggers.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Trigger
|
||||
|
||||
A Trigger represents an entry point for function invocations. Each type of Trigger requires specific configuration. They should be defined within the func.yaml file, as specified in [FUNC YAML](func-file.md).
|
||||
|
||||
## Types
|
||||
|
||||
### http
|
||||
|
||||
Configures a http endpoint for function invocation.
|
||||
|
||||
```
|
||||
name: triggerOne
|
||||
type: http
|
||||
source: /trigger-path
|
||||
```
|
||||
|
||||
This will cause the system to route requests arriving at the fn service at `/trigger-path` to the function specified in the fn.yaml file.
|
||||
Reference in New Issue
Block a user