Minghe Huang dbefe38dd6 init R support
2017-11-23 01:41:12 +08:00
2017-11-22 13:09:56 +08:00
2017-11-21 18:16:03 +08:00
2017-11-21 18:16:03 +08:00
2017-11-22 13:11:28 +08:00
2017-11-23 01:41:12 +08:00
2017-11-21 12:13:30 +08:00
2017-11-19 19:47:03 -05:00
2017-11-19 19:47:43 -05:00
2017-11-16 20:46:18 +08:00
2017-11-19 19:01:44 -05:00
2017-11-17 16:31:53 +00:00
2017-11-22 13:07:10 +08:00
2017-11-19 22:31:33 +08:00
2017-11-17 16:31:53 +00:00
2017-11-22 13:11:28 +08:00

fx

Poor man's function as a service.
build Go Report Card Go Doc Release

Introduction

fx is a tool to help you do Function as a Service on your own server. fx can make your stateless function a service in seconds. The most exciting thing is that you can write your functions with most programming languages.

Language Status Contributor
Go Supported fx
Node Supported fx
Python Supported fx
Ruby Supported fx
PHP Supported @chlins
Julia Supported @mbesancon
Java No
Scala No
Perl Working on
.Net Working on
R Working on
Rust Working on

tweet @_metrue or issue is welcome.

Usage

Requirements
  • Docker: make sure Docker installed and running on your server.
  • dep: fx project uses dep to do the golang dependency management.
Build and Run
$ git clone https://github.com/metrue/fx.git
$ cd fx
$ dep ensure
$ go install ./
  • start server
fx serve

now you can make a function to service in a second.

fx up ./examples/functions/func.js

the function defined in examples/functions/func.js is quite simple, it calculates the sum of two numbers then returns:

module.exports = (input) => {
    return parseInt(input.a, 10) + parseInt(input.b, 10)
}

then you can test your service:

curl -X POST <service url> -H "Content-Type: application/json" -d '{"a": 1, "b": 1}'

of course you can do more.

Usage:
$ fx serve                                      start f(x) server
$ fx up   func1.js func2.py func3.go ...        deploy a function or a group of functions
$ fx down [service ID] ...                      destroy a function or a group of functions
$ fx list                                       list deployed services
$ fx --version                                  show current version of f(x)

How to write your function

functions example with Go, Ruby, Python, Node, PHP.

  • Go
package main

type Input struct {
	A int32
	B int32
}

type Output struct {
	Sum int32
}

func Fx(input *Input) (output *Output) {
	output = &Output{
		Sum: input.A + input.B,
	}
	return
}
  • Ruby
def fx(input)
    return input['a'] + input['b']
end
  • Python
def fx(input):
    return input['a'] + input['b']
  • Node
module.exports = (input) => {
    return parseInt(input.a, 10) + parseInt(input.b, 10)
}
  • PHP
<?php
    function Fx($input) {
        return $input["a"]+$input["b"];
    }
  • Julia
struct Input
    a::Number
    b::Number
end

fx = function(input::Input)
    return input.a + input.b
end

Contributors

Thank you to all the people who already contributed to fx!

metrue pplam mbesancon avelino DaidoujiChen chlins

LICENSE

MIT

Description
A Function as a Service tool makes a function as a container-based service in seconds.
Readme MIT 69 MiB
Languages
Go 55.5%
D 38.6%
Shell 1.6%
Dockerfile 1.2%
Makefile 1%
Other 1.9%