Skip to content

abcdlsj/funy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Funy

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.

Usage

demo.gif

Build

Clone the repository, then make to build the binary.

make

Start Daemon funyd

Start funyd service

GIN_MODE=release USERNAME=<username> PASSWORD=<password> PORT=8080 ./bin/funyd

Start Server

Use funy cli to create and deploy a server

You need to set same USERNAME and PASSWORD in environment.

  1. create a server, with ld_flag_x to set Port and specify main_file
./bin/funy app --server_address=http://localhost:8080 create --name=ginserver1 --ld_flag_x="main.Port=8081" --main_file=ginserver.go
  1. can use curl to 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
)
  1. deploy the server
./bin/funy app --server_address=http://localhost:8080 deploy --name=ginserver1 --dir=example/ginserver/
  1. ping the server after the process_state is Deployed, you can use curl to call your server.
> curl localhost:8081
{"message":"Hello World!"}⏎
> curl localhost:8081/ping
{"ping count":"1"}⏎

Function

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!⏎

More

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
)

LOGPREFIX is a prefix for logs that may be used in the future.

About

A `Go` serverless framework using plugin.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published