Funy is a Golang serverless framework using Plugin.
Can deploy Service or Function.
Idea from shuttle.rs
> Currently, Funy dones not support Apple Silicon, I got a issue like golang/go#58826.
Clone the repository, then make to build the binary.
makeStart funyd service
GIN_MODE=release USERNAME=<username> PASSWORD=<password> PORT=8080 ./bin/funydUse funy cli to create and deploy a server
You need to set same USERNAME and PASSWORD in environment.
- create a server, with
ld_flag_xto setPortand specifymain_file
./bin/funy app --server_address=http://localhost:8080 create --name=ginserver1 --ld_flag_x="main.Port=8081" --main_file=ginserver.go- can use
curlto get progress.
curl -su 'USERNAME:PASSWORD' localhost:8080/orchestrator/output
{"ginserver1":{"process_state":0,"tar_dir":"/tmp/funy2099804210/ginserver1","main_file":"ginserver.go","ld_flag_x":{"main.Port":"8081"}}}The process_state can be:
const (
Create ProcessState = iota
Queued
Built
Loaded
Deployed
Error
Deleted
)- deploy the server
./bin/funy app --server_address=http://localhost:8080 deploy --name=ginserver1 --dir=example/ginserver/- ping the server
after the
process_stateisDeployed, you can usecurlto call your server.
> curl localhost:8081
{"message":"Hello World!"}⏎
> curl localhost:8081/ping
{"ping count":"1"}⏎You also can deploy a function by funy
> ./bin/funy app --server_address=http://localhost:8080 --type=function create --name=hellohandler --main_file=handler.go
> ./bin/funy app --server_address=http://localhost:8080 --type=function deploy --name=hellohandler --dir=example/hellohandler
# When deploy success, you can use `curl` to call it
> curl -u '<username>:<password>' localhost:8080/func/hellohandler
Hello World!⏎Can use ld_flag_x do many of things.
I have a slightly more complex function, example/leetjump
Implemented so that when you call http://xxxx/xxx/:question_id to jump to the issue page.
It uses Cloudflare R2 to store the file containing the information underlying the Leetcode issue.
I declared some variables in main.go. You can set this using ld_flag_x.
var (
BUCKET string
ACCOUNTID string
ACCESSKEYID string
ACCESSKEYSECRET string
LOGPREFIX string
)
LOGPREFIXis a prefix for logs that may be used in the future.
