• Stars
    star
    3,182
  • Rank 14,120 (Top 0.3 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

IronFunctions - the serverless microservices platform by

IronFunctions

CircleCI GoDoc

Welcome to IronFunctions! The open source serverless platform.

What is IronFunctions?

IronFunctions is an open source serverless platform, or as we like to refer to it, Functions as a Service (FaaS) platform that you can run anywhere.

What is Serverless/FaaS?

Serverless is a new paradigm in computing that enables simplicity, efficiency and scalability for both developers and operators. It's important to distinguish the two, because the benefits differ:

Benefits for developers

The main benefits that most people refer to are on the developer side and they include:

  • No servers to manage (serverless) -- you just upload your code and the platform deals with the infrastructure
  • Super simple coding -- no more monoliths! Just simple little bits of code
  • Pay by the milliseconds your code is executing -- unlike a typical application that runs 24/7, and you're paying 24/7, functions only run when needed

Since you'll be running IronFunctions yourself, the paying part may not apply, but it does apply to cost savings on your infrastructure bills as you'll read below.

Benefits for operators

If you will be operating IronFunctions (the person who has to manage the servers behind the serverless), then the benefits are different, but related.

  • Extremely efficient use of resources
    • Unlike an app/API/microservice that consumes resources 24/7 whether they are in use or not, functions are time sliced across your infrastructure and only consume resources while they are actually doing something
  • Easy to manage and scale
    • Single system for code written in any language or any technology
    • Single system to monitor
    • Scaling is the same for all functions, you don't scale each app independently
    • Scaling is simply adding more IronFunctions nodes

There is a lot more reading you can do on the topic, just search for "what is serverless" and you'll find plenty of information. We have pretty thorough post on the Iron.io blog called What is Serverless Computing and Why is it Important.

Join Our Community

Join our Slack community to get help and give feedback.

Slack Status

Quickstart

This guide will get you up and running in a few minutes.

Prequisites

  • Docker 1.12 or later installed and running
  • Logged into Docker Hub (docker login)

Run IronFunctions

To get started quickly with IronFunctions, just fire up an iron/functions container:

docker run --rm -it --name functions -v ${PWD}/data:/app/data -v /var/run/docker.sock:/var/run/docker.sock -p 8080:8080 iron/functions

where ${PWD}/data is the directory where the functions application data files will be stored

This will start IronFunctions in single server mode, using an embedded database and message queue. You can find all the configuration options here. If you are on Windows, check here.

CLI tool

Install the IronFunctions CLI tool:

curl -LSs git.io/ironfn | sh

This will download a shell script and execute it. If the script asks for a password, that is because it invokes sudo.

Once installed close and re-open the terminal so the installed command fn is in your path.

on OSX with HomeBrew:

brew install iron-functions

Write a Function

Functions are small, bite sized bits of code that do one simple thing. Forget about monoliths when using functions, just focus on the task that you want the function to perform.

The following is a Go function that just returns "Hello ${NAME}!":

package main

import (
	"encoding/json"
	"fmt"
	"os"
)

type Person struct {
	Name string
}

func main() {
	p := &Person{Name: "World"}
	json.NewDecoder(os.Stdin).Decode(p)
	fmt.Printf("Hello %v!", p.Name)
}

Make a new folder and cd into that folder then copy and paste the code above into a file called func.go. From that folder run the following commands to build your function and deploy it:

# create func.yaml file, replace $USERNAME with your Docker Hub username.
fn init $USERNAME/hello
# build the function
fn build
# test it - you can pass data into it too by piping it in, eg: `cat hello.payload.json | fn run`
fn run
# Once it's ready, build and push it to Docker Hub
fn build && fn push
# create an app - you only do this once per app
fn apps create myapp
# create a route that maps /hello to your new function
fn routes create myapp /hello

Now you can call your function:

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

Or surf to it: http://localhost:8080/r/myapp/hello

To update your function:

# update a function with a new version and push it
fn bump && fn build && fn push
# then update the route
fn routes update myapp /hello

See below for more details. And you can find a bunch of examples in various languages in the examples directory. You can also write your functions in AWS's Lambda format.

Usage

This is a more detailed explanation of the main commands you'll use in IronFunctions as a developer.

Create an Application

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

fn apps create myapp

Or using a cURL:

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

More on apps.

Now that we have an app, we can route endpoints to functions.

Add a Route

A route is a way to define a path in your application that maps to a function. In this example, we'll map /hello to a simple Hello World! function called iron/hello which is a function we already made that you can use -- yes, you can share functions! The source code for this function is in the examples directory. You can read more about writing your own functions here.

fn routes create myapp /hello -i iron/hello

Or using cURL:

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

More on routes.

Authentication

Iron Functions API supports two levels of Authentication in two seperate scopes, service level authentication, (Which authenticates all requests made to the server from any client) and route level authentication. Route level authentication is applied whenever a function call made to a specific route.

Please check Authentication documentation for more information.

Calling your Function

Calling your function is as simple as requesting a URL. Each app has its own namespace and each route mapped to the app. The app myapp that we created above along with the /hello route we added would be called via the following URL: http://localhost:8080/r/myapp/hello

Either surf to it in your browser or use fn:

fn call myapp /hello

Or using a cURL:

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

Passing data into a function

Your function will get the body of the HTTP request via STDIN, and the headers of the request will be passed in as env vars. You can test a function with the CLI tool:

echo '{"name":"Johnny"}' | fn call myapp /hello

Or using cURL:

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

You should see it say Hello Johnny! now instead of Hello World!.

Add an asynchronous function

IronFunctions supports synchronous function calls like we just tried above, and asynchronous for background processing.

Asynchronous function calls are great for tasks that are CPU heavy or take more than a few seconds to complete. For instance, image processing, video processing, data processing, ETL, etc. Architecturally, the main difference between synchronous and asynchronous is that requests to asynchronous functions are put in a queue and executed on upon resource availability so that they do not interfere with the fast synchronous responses required for an API. Also, since it uses a message queue, you can queue up millions of function calls without worrying about capacity as requests will just be queued up and run at some point in the future.

To add an asynchronous function, create another route with the "type":"async", for example:

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

Now if you request this route:

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

You will get a call_id in the response:

{"call_id":"572415fd-e26e-542b-846f-f1f5870034f2"}

If you watch the logs, you will see the function actually runs in the background:

async log

Read more on logging.

Functions UI

docker run --rm -it --link functions:api -p 4000:4000 -e "API_URL=http://api:8080" iron/functions-ui

For more information, see: https://github.com/iron-io/functions-ui

Writing Functions

See Writing Functions.

And you can find a bunch of examples in the /examples directory.

More Documentation

See docs/ for full documentation.

Roadmap

These are the high level roadmap goals. See milestones for detailed issues.

  • Alpha 1 - November 2016
    • Initial release of base framework
    • Lambda support
  • Alpha 2 - December 2016
    • Streaming input for hot functions #214
    • Logging endpoint(s) for per function debugging #263
  • Beta 1 - January 2017
    • Smart Load Balancer #151
  • Beta 2 - February 2017
    • Cron like scheduler #100
  • GA - March 2017

Support

You can get community support via:

You can get commercial support by contacting Iron.io

Want to contribute to IronFunctions?

See contributing.

More Repositories

1

dockers

Uber tiny Docker images for all the things.
HTML
1,591
star
2

dockerworker

The new IronWorker workflow examples. Test locally, then upload and start queuing jobs!
Scala
233
star
3

functions-ui

User interface for IronFunctions - http://github.com/iron-io/functions
Vue
95
star
4

iron_mq_php

PHP client for IronMQ.
PHP
89
star
5

iron_go

Iron.io API libraries
Go
79
star
6

lambda

All Iron.io open source AWS Lambda code.
Go
69
star
7

iron_worker_ruby_ng

Next Gen Ruby gem for IronWorker
Ruby
58
star
8

iron_worker_php

PHP client for IronWorker
PHP
56
star
9

iron_mq_node

CoffeeScript
51
star
10

laraworker

Easily add IronWorker to Laravel Applications
PHP
45
star
11

iron_mq_java

Java library for IronMQ.
Java
44
star
12

iron_worker_python

Python client for IronWorker
Python
42
star
13

iron_worker_ruby

Official IronWorker gem.
Ruby
39
star
14

iron_mq_ruby

Ruby library for IronMQ.
Ruby
35
star
15

ironcli

Command line tool for the Iron.io platform.
Go
35
star
16

iron_mq_python

Python client for IronMQ.
Python
35
star
17

docs

Iron.io Dev Center documentation.
CSS
30
star
18

iron_celery

IronMQ broker and IronCache results store for Python's Celery project.
Python
30
star
19

iron_worker_rails_example

Rails Application Demonstrating IronWorker Usage
Ruby
26
star
20

iron_worker_node

CoffeeScript
25
star
21

rest

HTTP/REST client wrapper that provides a standard interface for making http requests using different http clients.
Ruby
23
star
22

iron_core_php

PHP
19
star
23

iron_dotnet

C#
18
star
24

picasso

Project Picasso (Functions-as-a-Service) for OpenStack
17
star
25

heroku_sinatra_example

This is an example Sinatra application ready to run on Heroku using IronWorker and IronMQ Add Ons.
Ruby
17
star
26

iron_go3

Go lib for IronMQ v3.
Go
15
star
27

iron_cache_php

PHP
15
star
28

iron_cache_ruby

Ruby client for IronCache
Ruby
14
star
29

runner

Go
11
star
30

iron_worker_java

Java
9
star
31

iron_cache_python

Python
9
star
32

functions_js

JavaScript library for IronFunctions.
JavaScript
9
star
33

ironcasts-series-1

All code examples used in IronWorker 101 in IronCast Episode 1 to Episode 4
Ruby
8
star
34

slackbots

A repository of Slack bots that run on IronWorker
Ruby
8
star
35

abt

ABT - Always Be Testing - A ruby gem that uses IronWorker to continously run tests.
Ruby
8
star
36

functions_go

Go library for IronFunctions.
Go
7
star
37

golog

Simple logging helper for Go.
Go
7
star
38

iron_mq_go

DEPRECATED! Use https://github.com/iron-io/iron_go
Go
7
star
39

iron_core_ruby

Ruby
7
star
40

iron_mq_clojure

Clojure client for IronMQ
Clojure
7
star
41

iron_cache_rails

Rails cache store and session store using IronCache by www.iron.io
Ruby
7
star
42

heroku-iron-celery-demo

A demo of running Celery on Heroku. Downloads an RSS feed and parses the items. http://iron-celery-demo.herokuapp.com
JavaScript
7
star
43

workers

Ruby
6
star
44

iron_core_python

Python
6
star
45

iron_core_node

CoffeeScript
6
star
46

ironmq-openshift-quickstart

Shell
5
star
47

ironcasts-series-1-samplecode

Ruby
5
star
48

gosqs

SQS interface for Go
Go
5
star
49

issues

For Iron.io services issue tracking. Public facing issue tracking for behind the scenes issues.
5
star
50

rackspace-django-demo

Python
5
star
51

lambda-vs-ironworker

Examples of using Lambda and IronWorker to do the same thing.
JavaScript
4
star
52

functions_ruby

Ruby library for IronFunctions.
Ruby
4
star
53

newrelic_platform

Ruby library for the new New Relic Platform - http://newrelic.com/platform
Ruby
4
star
54

image_processor

PHP
4
star
55

glock

Boom
Go
4
star
56

rails-nginx-unicorn

A dead simple base image for dockerizing Rails apps using unicorn/foreman/nginx
Nginx
4
star
57

iron_cache_dotnet

C#
3
star
58

microcontainers

Reference site for Microcontainers.
3
star
59

koders

A Ruby app using Sinatra and IronWorker to pull top Stackoverflow users then finds the languages they use on Github to get the top languages for the top SO users.
JavaScript
3
star
60

iron_combine

Ruby
3
star
61

iron-worker-examples

Top uses of IW with examples
HTML
3
star
62

gridiron

Python
2
star
63

heroku_iron_boomi_salesforce

Heroku -> Iron.io -> Boomi -> Salesforce Integration Demo
JavaScript
2
star
64

python-picassoclient

OpenStack SDK & CLI plugin for Picasso (Functions-as-a-Service)
2
star
65

splunk-ironmq-mi

Python
2
star
66

simple_worker_redirect

Redirects SimpleWorker to IronWorker
Ruby
2
star
67

logspout-statsd

A statsd adapter for logspout.
Go
2
star
68

worker_ruby

Ruby sdk for Titan.
Ruby
2
star
69

iron_cache_node

CoffeeScript
1
star
70

newrelic_parse_plugin

A New Relic Platform agent for Parse.
Ruby
1
star
71

maven

For hosting our java jars for Maven central.
Shell
1
star
72

worker_go

Go library for Titan.
Go
1
star
73

gobson_temp

Go
1
star
74

fn-go

A library for handling Go Language functions input and output
Go
1
star
75

monger

Go
1
star
76

ironmq-openshift-cartridge

Ruby
1
star
77

r-lang-worker-example

Hello world for R on IronWorker
R
1
star
78

iron_twilio_insanity

Iron.io and Twilio present: Beachbody Insanity Reminder
Ruby
1
star
79

codegen

JavaScript
1
star
80

sfbeta

Ruby
1
star
81

iron_mq_rust

⚙️ Rust client for IronMQ
Rust
1
star
82

iron_mq_groovy

Groovy client for IronMQ
Groovy
1
star
83

worker_js

JavaScript
1
star
84

platform_performance

PHP
1
star
85

function-fork-me

An example function to fork and modify.
JavaScript
1
star
86

newrelic_ironmq_plugin

A New Relic Platform agent for IronMQ.
Ruby
1
star
87

iron_core_java

1
star
88

iron_consumer

Ruby
1
star
89

php_example_app

A PHP application that uses Iron.io services.
PHP
1
star
90

build_worker

Standard build worker for doing remote builds on IronWorker.
Ruby
1
star
91

newrelic_airbrake_plugin

A New Relic Platform agent for Airbrake.
Ruby
1
star
92

buckets

Go
1
star
93

ironfunctions-murano

Murano application package for IronFunctions on OpenStack
1
star
94

newrelic_saas_agent

Template for easily creating NewRelic Platform agents for SaaS services. No servers required.
Ruby
1
star