Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lupino/func
a simple function as a service server write on haskell
https://github.com/lupino/func
Last synced: about 1 month ago
JSON representation
a simple function as a service server write on haskell
- Host: GitHub
- URL: https://github.com/lupino/func
- Owner: Lupino
- License: bsd-3-clause
- Created: 2017-04-22T13:19:52.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-25T01:56:26.000Z (over 6 years ago)
- Last Synced: 2024-06-19T03:13:43.505Z (6 months ago)
- Language: Haskell
- Homepage:
- Size: 13.7 KB
- Stars: 6
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Functions as a Service (FaaS)
A simple function as a service server write on haskell.
## Concept
* The `func` hosts a web server allowing a post request to be forwarded to a desired process via STDIN.
The response is sent back to the caller via STDOUT## Quick Start Guide
This section shows you how to quickly get set up to factor.
### Install `func` executer
Install from binary release:
* [Linux x86_64](https://github.com/Lupino/func/releases/download/v0.1/func_linux_x86_64.gz)
* [Mac OS x86_64](https://github.com/Lupino/func/releases/download/v0.1/func_maxos_x86_64.gz)Or build from source:
git clone https://github.com/Lupino/func.git
cd func
stack install### Run you own `func` instance
Make sure the `func` command is in you `PATH`.
func -c config.yaml
Request `cat` function
curl http://127.0.0.1:3000/function/cat -d "Hello World!"
### Write a new function
Open a file called `myfunc.go` then write sub code:
```golang
package mainimport (
"fmt"
"io/ioutil"
"log"
"os"
)func main() {
input, err := ioutil.ReadAll(os.Stdin)
if err != nil {
log.Fatalf("Unable to read standard input: %s", err.Error())
}
fmt.Println(string(input))
}
```Compile with command `go build -o myfunc`
Add the sub config to `config.yaml`
```yaml
- func: myfunc
proc: myfunc
```Use sign `HUP` to reload `func`
```bash
ps aux | grep func
# got the pid and send `HUP` sign
kill -HUP pid
```Test `myfunc`
```bash
curl http://127.0.0.1:3000/function/myfunc -d "Hello World!"
```More example please see [sample-functions](https://github.com/Lupino/func/tree/master/sample-functions)
## Config reference
```yaml
- func: func # function name.
proc: proc # command or command file path.
argv: [] # process arguments (optional).
content-type: "" # Response content type (optional).
```