Skip to content
This repository has been archived by the owner on Nov 16, 2024. It is now read-only.

Tarocch1/aliyun-fc-go-runtime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Aliyun fc go runtime

阿里云函数计算 golang custom runtime 框架。

Install

go get github.com/Tarocch1/aliyun-fc-go-runtime

Event Function

package main

import (
	"fmt"

	gr "github.com/Tarocch1/aliyun-fc-go-runtime"
)

func initialize(ctx *gr.FCContext) error {
	fmt.Println("init golang!")
	return nil
}

func invoke(ctx *gr.FCContext, event []byte) ([]byte, error) {
	fmt.Println(fmt.Sprintf("hello golang!\ncontext = %+v", ctx))
	return event, nil
}

func main() {
	handler := &gr.Handler{
		Initialize: initialize,
		Invoke:     invoke,
	}
	gr.Start(handler)
}

HTTP Function

package main

import (
	"fmt"
	"net/http"

	gr "github.com/Tarocch1/aliyun-fc-go-runtime"
)

func initialize(ctx *gr.FCContext) error {
	fmt.Println("init golang!")
	return nil
}

func httpInvoke(ctx *gr.FCContext, w http.ResponseWriter) error {
	w.Write([]byte(fmt.Sprintf("hello golang!\ncontext = %+v", ctx)))
	return nil
}

func main() {
	handler := &gr.Handler{
		Initialize: initialize,
		HttpInvoke: httpInvoke,
	}
	gr.Start(handler)
}

About

Go runtime for aliyun function compute.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages