faas

package module
v0.0.0-...-53cbaea Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

README

faas-api

faas api

1. mode 1

just functions to run

  • create a package and service
  • import "github.com/moetang-arch/faas-api" for initialization
  • ONLY the packages in the allowed list can be used

2. mode 2

Not Yet Implement

3. Example - mode 1

package demo

import (
	"context"
	"errors"

	"github.com/moetang-arch/faas-api"
)

func init() {
	faas.SetGlobalServicePrefix("set.if.need")
	faas.Register("demo", HandleRequest)
}

type Request struct {
	Name string
}

type Response struct {
	Result string
}

func HandleRequest(ctx context.Context, request *Request) (response *Response, err error) {
	if len(request.Name) == 0 {
		return nil, errors.New("name is empty")
	}
	resp := new(Response)
	resp.Result = "Hello, " + request.Name
	return resp, nil
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGlobalServiceNameSpace

func GetGlobalServiceNameSpace() string

func GetServiceMap

func GetServiceMap() map[string]interface{}

func Register

func Register(serviceName string, function interface{})

func SetGlobalServiceNameSpace

func SetGlobalServiceNameSpace(namespace string)

default is configured via control panel

Types

type Deserializable

type Deserializable interface {
	ToJson() (string, error)
	ToBytes() ([]byte, error)
}

custom deserialization

type Serializable

type Serializable interface {
	FromJson(json string) error
	FromBytes(data []byte) error
}

custom serialization

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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