openfaas

package module
v0.0.0-...-dceaa68 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2020 License: MIT Imports: 8 Imported by: 0

README

OpenFaaS

OpenFaaS® (Functions as a Service) is a framework for building Serverless functions with Docker and Kubernetes which has first-class support for metrics. Any process can be packaged as a function enabling you to consume a range of web events without repetitive boiler-plate coding.

How it works

With OpenFaaS you can create your own Go-based functions and that means your Flogo apps (built with the Golang API) can be deployed there too! To make it work, OpenFaaS leverages a dockerfile that executes the build of the function and makes the docker image available to wherever you're running OpenFaaS.

Schema

Settings, Outputs:

{
  "settings": [
  ],
  "output": [
    {
      "name": "context",
      "type": "object"
    },
    {
      "name": "evt",
      "type": "object"
    }
  ]
}

Dockerfile

Due to the build process of OpenFaaS and the required metadata for Project Flogo, the dockerfile to build these Go based apps needs to be modified slightly. The dockerfile in the sampleapp folder has been modified to accomodate for those changes. On line 17, a small statement will update the metadata files with the correct ID for OpenFaaS.

Sample app

As with the Lambda trigger, Flogo apps using the OpenFaaS trigger will break down into a few parts as you can see in the handler.go file

Handle

This method takes care of starting and enabling the Flogo app to handle requests from the OpenFaaS environment

init

This method takes care of the initialization of the Flogo app

shimApp

This method takes care of creating the Flogo app and registering the OpenFaaS trigger with the Flogo engine

RunActivities

RunActivities is where the magic happens. This is where you get the input from any event that might trigger your OpenFaaS function in a map called evt

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Invoke

func Invoke() (map[string]interface{}, error)

Invoke starts the trigger and invokes the action registered in the handler

func NewFactory

func NewFactory(md *trigger.Metadata) trigger.Factory

NewFactory create a new Trigger factory

Types

type OpenFaaSFactory

type OpenFaaSFactory struct {
	// contains filtered or unexported fields
}

OpenFaaSFactory OpenFaaS Trigger factory

func (*OpenFaaSFactory) New

func (t *OpenFaaSFactory) New(config *trigger.Config) trigger.Trigger

New Creates a new trigger instance for a given id

type OpenFaaSTrigger

type OpenFaaSTrigger struct {
	// contains filtered or unexported fields
}

OpenFaaSTrigger OpenFaaS trigger struct

func (*OpenFaaSTrigger) Initialize

func (t *OpenFaaSTrigger) Initialize(ctx trigger.InitContext) error

Initialize initializes the trigger

func (*OpenFaaSTrigger) Metadata

func (t *OpenFaaSTrigger) Metadata() *trigger.Metadata

Metadata implements trigger.Trigger.Metadata

func (*OpenFaaSTrigger) Start

func (t *OpenFaaSTrigger) Start() error

Start implements util.Managed.Start

func (*OpenFaaSTrigger) Stop

func (t *OpenFaaSTrigger) Stop() error

Stop implements util.Managed.Stop

Directories

Path Synopsis
sampleapp
code
Package function implements the main logic of the function
Package function implements the main logic of the function

Jump to

Keyboard shortcuts

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