diff --git a/docs/README.md b/docs/README.md index 6efde74eb..3c88959d0 100644 --- a/docs/README.md +++ b/docs/README.md @@ -8,13 +8,15 @@ If you are a developer using Fn through the API, this section is for you. * [Usage](usage.md) * [Writing functions](writing.md) * [fn (CLI Tool)](https://github.com/fnproject/cli/blob/master/README.md) +* [Hot functions](hot-functions.md) +* [Async functions](async.md) +* [Organizing functions into an application](developers/apps.md) * [Function file (func.yaml)](function-file.md) * [Client Libraries](developers/clients.md) * [Packaging functions](packaging.md) * [Open Function Format](function-format.md) * API Reference (coming soon) -* [Hot functions](hot-functions.md) -* [Async functions](async.md) +* [Object Model](developers/model.md) * [FAQ](faq.md) ## For Operators diff --git a/docs/developers/apps.md b/docs/developers/apps.md new file mode 100644 index 000000000..634bcf710 --- /dev/null +++ b/docs/developers/apps.md @@ -0,0 +1,63 @@ +# Applications + +In `fn`, an application is a group of functions with path mappings (routes) to each function ([learn more](model.md)). +We've tried to make it easy to work with full applications by providing tools that work with all the applications functions. + +## Creating an Application + +All you have to do is create a file called `app.yaml` in your applications root directory, and the only required field is a name: + +```yaml +name: myawesomeapp +``` + +Once you have that file in place, the `fn` commands will work in the context of that application. + +## The Index Function (aka: Root Function) + +The root app directory can also contain a `func.yaml` which will be the function access at `/`. + +## Function paths + +By default, the function name and path will be the same as the directory structure. For instance, if you +have a structure like this: + +```txt +- app.yaml +- func.yaml +- func.go +- hello/ + - func.yaml + - func.js +- users/ + - func.yaml + - func.rb +``` + +The URL's to access those functions will be: + +``` +http://abc.io/ -> root function +http://abc.io/hello -> function in hello/ directory +http://abc.io/users -> function in users/ directory +``` + +## Deploying an entire app at once + +```sh +fn deploy --all +``` + +If you're just testing locally, you can speed it up with the `--local` flag. + +## Deploying a single function in the app + +To deploy the `hello` function only, from the root dir, run: + +```sh +fn deploy hello +``` + +## Example app + +See https://github.com/fnproject/fn/tree/master/examples/app for a simple example. diff --git a/docs/developers/model.md b/docs/developers/model.md new file mode 100644 index 000000000..46e50c6dc --- /dev/null +++ b/docs/developers/model.md @@ -0,0 +1,31 @@ +# Object Model + +This document describes the different objects we store and the relationships between them. + +## Applications + +At the root of everything are applications. In `fn`, an application is essentially a grouping of functions +with path mappings (routes) to each function. For instance, consider the following URLs for the app called `myapp`: + +``` +http://myapp.com/hello +http://myapp.com/users +``` + +This is an app with 2 routes: + +1. A mapping of the path `/hello` to a function called `hello` +1. A mapping of the path `/users` to a function called `users` + +## Routes + +An app consists of 1 or more routes. A route stores the mapping between URL paths and functions (ie: container iamges). + +## Calls + +A call represents an invocation of a function. Every request for a URL as defined in the routes, a call is created. +The `call_id` for each request will show up in all logs and the status of the call, as well as the logs, can be retrieved using the `call_id`. + +## Logs + +Logs are stored for each `call` that is made and can be retrieved with the `call_id`. diff --git a/examples/app/README.md b/examples/app/README.md index 4e823b5a6..bb36b194c 100644 --- a/examples/app/README.md +++ b/examples/app/README.md @@ -2,6 +2,4 @@ This shows you how to organize functions into a full application and deploy them easily with one command. -## TODOs - -* [ ] Use a header/footer endpoint and pull them into the functions? +See [apps documentation](/docs/developers/app.md) for details on how to use this. diff --git a/examples/app/footer/func.yaml b/examples/app/footer/func.yaml index c751bb3cf..0be32936c 100644 --- a/examples/app/footer/func.yaml +++ b/examples/app/footer/func.yaml @@ -1,5 +1,5 @@ name: footer -version: 0.0.12 +version: 0.0.13 runtime: ruby entrypoint: ruby func.rb headers: diff --git a/examples/app/func.yaml b/examples/app/func.yaml index 085ddb9f9..1be0af6b5 100644 --- a/examples/app/func.yaml +++ b/examples/app/func.yaml @@ -1,4 +1,4 @@ name: app -version: 0.0.69 +version: 0.0.70 runtime: go entrypoint: ./func diff --git a/examples/app/header/func.yaml b/examples/app/header/func.yaml index 0b428b0bb..dc5f8a747 100644 --- a/examples/app/header/func.yaml +++ b/examples/app/header/func.yaml @@ -1,5 +1,5 @@ name: header -version: 0.0.10 +version: 0.0.11 runtime: ruby entrypoint: ruby func.rb headers: diff --git a/examples/app/node/func.yaml b/examples/app/node/func.yaml index 5a240f6e1..2f9da8a07 100644 --- a/examples/app/node/func.yaml +++ b/examples/app/node/func.yaml @@ -1,4 +1,4 @@ name: node -version: 0.0.12 +version: 0.0.13 runtime: node entrypoint: node func.js diff --git a/examples/app/python/func.yaml b/examples/app/python/func.yaml index 0c16b932a..2f024290a 100644 --- a/examples/app/python/func.yaml +++ b/examples/app/python/func.yaml @@ -1,4 +1,4 @@ name: python -version: 0.0.10 +version: 0.0.11 runtime: python entrypoint: python2 func.py diff --git a/examples/app/ruby/func.yaml b/examples/app/ruby/func.yaml index fed7daa38..bfe65b96e 100644 --- a/examples/app/ruby/func.yaml +++ b/examples/app/ruby/func.yaml @@ -1,5 +1,5 @@ name: ruby -version: 0.0.22 +version: 0.0.23 runtime: ruby entrypoint: ruby func.rb headers: