Ironfunctions-ServerlessResearch

command module
v0.0.0-...-5ccd8dd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

README

Get Start

  1. docker build -f Dockerfile.2690 -t 2690 .

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

  3. cd test-function

  4. touch function.go

  5. add code

Example

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)
}
  1. Install CLI tools

For Linux

curl -LSs git.io/ironfn | sh

For macOS

brew install iron-functions
  1. Init function with runtime
fn init --runtime go hello
  1. Buld function - fn build is used to build the Docker image of the function
fn build
  1. Create app - Create application, organization and management multiple functions
fn apps create myapp
  1. Creates a route and maps the specified path to the newly created function
fn routes create myapp /hello
  1. If update function.go, then build and update route again
fn build
fn routes update myapp /hello
  1. Invoke function
curl http://localhost:8080/r/myapp/hello
  1. Frontend Access
docker run -d --rm -it --link functions:api -p 4000:4000 -e "API_URL=http://api:8080" iron/functions-ui:0.0.2

Access http://localhost:4000/

Documentation

Overview

IronFunctions daemon

Refer to detailed documentation at https://github.com/iron-io/functions/tree/master/docs

Environment Variables: DB_URL The database URL to use in URL format. See [Databases](databases/README.md) for more information. Default: BoltDB in current working directory `bolt.db`.

MQ_URL The message queue to use in URL format. See [Message Queues](mqs/README.md) for more information. Default: BoltDB in current working directory `queue.db`.

API_URL The primary IronFunctions API URL to that this instance will talk to. In a production environment, this would be your load balancer URL.

PORT Sets the port to run on. Default: `8080`.

NUM_ASYNC The number of async runners in the functions process (default 1).

LOG_LEVEL Set to `DEBUG` to enable debugging. Default: INFO.

Directories

Path Synopsis
api
mqs
server
TODO: it would be nice to move these into the top level folder so people can use these with the "functions" package, eg: functions.ApiHandler
TODO: it would be nice to move these into the top level folder so people can use these with the "functions" package, eg: functions.ApiHandler
server/internal/routecache
Package routecache is meant to assist in resolving the most used routes at an application.
Package routecache is meant to assist in resolving the most used routes at an application.
benchmarks
examples
jwt
fn
app
lb
test

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL