C Cirello 4cbfb3ccfd Reduce test log verbosity (#150)
* Reduce test verbosity
* Divert gin's log to the test buffer
* Divert stdlib's log to the test buffer
* Add bolt tests into log buffer

* Add a linebreak to improve log output layout
2016-10-13 00:06:02 +02:00
2016-10-13 00:06:02 +02:00
2016-10-06 20:46:29 +02:00
2016-10-12 09:36:44 -07:00
2016-10-07 20:44:20 +02:00
2016-10-06 20:46:29 +02:00
2016-07-14 09:18:43 -07:00
2016-10-11 18:18:06 -07:00

IronFunctions

Run functions

docker run --rm --name functions --privileged -it -v $PWD/data:/app/data -p 8080:8080 iron/functions

Note: A list of configurations via env variables can be found here.

Using Functions

Create an Application

An application is essentially a grouping of functions, that put together, form an API. Here's how to create an app.

curl -H "Content-Type: application/json" -X POST -d '{
    "app": { "name":"myapp" }
}' http://localhost:8080/v1/apps

Now that we have an app, we can map routes to functions.

Add a route to a Function

curl -H "Content-Type: application/json" -X POST -d '{
    "route": {
        "path":"/hello",
        "image":"iron/hello"
    }
}' http://localhost:8080/v1/apps/myapp/routes

Calling your Function

Just hit the URL you got back from adding a route above:

curl http://localhost:8080/r/myapp/hello

To pass in data to your function

Your function will get the body of the request as is, and the headers of the request will be passed in as env vars. Try this:

curl -H "Content-Type: application/json" -X POST -d '{
    "name":"Johnny"
}' http://localhost:8080/r/myapp/hello

Adding a route with URL params

You can create a route with dynamic URL parameters that will be available inside your function by prefixing path segments with a :, for example:

$ curl -H "Content-Type: application/json" -X POST -d '{
     "route": {
         "path":"/comments/:author_id/:num_page",
         "image":"IMAGE_NAME"
     }
}' http://localhost:8080/v1/apps/myapp/routes

:author_id and :num_page in the path will be passed into your function as PARAM_AUTHOR_ID and PARAM_NUM_PAGE.

See the Blog Example.

Adding Asynchronous Data Processing Support

Data processing is for functions that run in the background. This type of functionality is good for functions that are CPU heavy or take more than a few seconds to complete. Architecturally, the main difference between synchronous you tried above and asynchronous is that requests to asynchronous functions are put in a queue and executed on upon resource availablitiy on the same process or a remote functions process so that they do not interfere with the fast synchronous responses required by an API. Also, since it uses a queue, you can queue up millions of jobs without worrying about capacity as requests will just be queued up and run at some point in the future.

TODO: Add link to differences here in README.io docs here.

Running remote functions process

Coming soon...

Using IronFunctions Hosted by Iron.io

Simply point to https://functions.iron.io instead of localhost and add your Iron.io Authentication header (TODO: link), like this:

curl -H "Authorization: Bearer IRON_TOKEN" -H "Content-Type: application/json" -X POST -d '{"app": {"name":"myapp"}}' https://functions.iron.io/v1/apps

And you'll get an ironfunctions.com host for your app:

myapp.USER_ID.ironfunctions.com/hello

API Reference

https://swaggerhub.com/api/iron/functions

Full Documentation

http://docs-new.iron.io/docs

Join Our Community

Slack Status

Description
The container native, cloud agnostic serverless platform.
Readme Apache-2.0 170 MiB
Languages
Go 97.4%
Shell 1.2%
Ruby 0.5%
Makefile 0.4%
Dockerfile 0.4%
Other 0.1%