All Projects → tal-tech → Gaea

tal-tech / Gaea

Licence: apache-2.0
Gaea is a Gin-based web framework, reference gin https://github.com/gin-gonic/gin

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Gaea

Vaxic
Node HTTP server framework
Stars: ✭ 45 (-57.14%)
Mutual labels:  api, web-framework, http-server
Totoval
An out-of-the-box artisan API web-framework written in go.
Stars: ✭ 110 (+4.76%)
Mutual labels:  api, web-framework, gin
Go Book Store Api
Go Sample project to understand Mysql CRUD operation with best practises Includes logging, JWT, Swagger and Transactions
Stars: ✭ 18 (-82.86%)
Mutual labels:  api, http-server
Farwest
Framework for building RESTful HATEOAS-driven applications.
Stars: ✭ 18 (-82.86%)
Mutual labels:  web-framework, http-server
Jiny
Lightweight, modern, simple JVM web framework for rapid development in the API era
Stars: ✭ 40 (-61.9%)
Mutual labels:  web-framework, http-server
Takes
True Object-Oriented Java Web Framework
Stars: ✭ 670 (+538.1%)
Mutual labels:  web-framework, http-server
Cowboy
Small, fast, modern HTTP server for Erlang/OTP.
Stars: ✭ 6,533 (+6121.9%)
Mutual labels:  web-framework, http-server
Nodemcu Espress
Ultra-Lightweight and modular Node.js express like http server for NodeMCU. web - ESP8266
Stars: ✭ 39 (-62.86%)
Mutual labels:  api, http-server
Diet
A tiny, fast and modular node.js web framework. Good for making fast & scalable apps and apis.
Stars: ✭ 394 (+275.24%)
Mutual labels:  api, http-server
Hprose Golang
Hprose is a cross-language RPC. This project is Hprose for Golang.
Stars: ✭ 1,143 (+988.57%)
Mutual labels:  api, rpc-client
Generator Http Fake Backend
Yeoman generator for building a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 49 (-53.33%)
Mutual labels:  api, http-server
Foal
Elegant and all-inclusive Node.Js web framework based on TypeScript. 🚀.
Stars: ✭ 1,176 (+1020%)
Mutual labels:  api, web-framework
Snake
🐍 一款小巧的基于Go构建的开发框架,可以快速构建API服务或者Web网站进行业务开发,遵循SOLID设计原则
Stars: ✭ 615 (+485.71%)
Mutual labels:  api, gin
Hprose Java
Hprose is a cross-language RPC. This project is Hprose 2.0 for Java
Stars: ✭ 542 (+416.19%)
Mutual labels:  api, rpc-client
Goyave
🍐 Elegant Golang REST API Framework
Stars: ✭ 811 (+672.38%)
Mutual labels:  api, web-framework
Go Gin Example
An example of gin
Stars: ✭ 4,992 (+4654.29%)
Mutual labels:  api, gin
Server
Serve your Rubix ML models in production with scalable stand-alone model inference servers.
Stars: ✭ 30 (-71.43%)
Mutual labels:  api, http-server
Armeria
Your go-to microservice framework for any situation, from the creator of Netty et al. You can build any type of microservice leveraging your favorite technologies, including gRPC, Thrift, Kotlin, Retrofit, Reactive Streams, Spring Boot and Dropwizard.
Stars: ✭ 3,392 (+3130.48%)
Mutual labels:  rpc-client, http-server
Comet
Modern PHP framework for building blazing fast REST APIs, CRUDs and microservices
Stars: ✭ 328 (+212.38%)
Mutual labels:  api, http-server
Ppgo api demo gin
API接口应用Demo 基于Gin
Stars: ✭ 90 (-14.29%)
Mutual labels:  api, gin

简介

Gaea Logo

Gaea是一基于Gin的Web框架。 在实际工作中,在将项目应用于生产环境之前,还需要解决一系列其他工程问题, 否则,系统的可移植性将很差,并且开发人员将无法专注于业务开发。 集成到一套完整的解决方案中:依赖关系管理,配置管理,编译和部署,监视和警报,并支持一键式快速构建Web应用程序。 如果您正在考虑用Golang编写Web服务器,那么Gaea无疑是您的最佳选择!

Document

Documentation

中文文档

安装

安装脚手架

通过 rigger脚手架可一键创建Gaea模板的api项目

生成框架

此处以"myproject"为项目名称

$ rigger new api myproject
正克隆到 '/winshare/go/src/myproject'...
myprojec项目已创建完成, 使用:
 cd /winshare/go/src/myproject && rigger build 

编译

//Will use makefile to compile and generate binary files to the bin directory
$ cd gaea
$ make

help

$ ./bin/myproject --help
Usage of ./bin/myproject:
  -c string
    	指定ini配置文件以程序的二进制文件(myproject)为相对目录正确的相对目录加载方式 -c ../conf/conf_xxx.ini 默认为加载 ../conf/conf.ini
  -p string
        配置文件的前缀设置用于以绝对路径形式加载  -c conf.ini -p /usr/pathto/myproject/conf
  -cfg string
    	json config path (default "conf/config.json")		
  -extended string
    	扩展参数程序未定义使用用途用户可自行处理
  -f	foreground
  -m	mock 开关	
  -s string
    	start or stop
  -usr1 string
    	user defined flag -usr1
  -usr2 string
    	user defined flag -usr2
  -usr3 string
    	user defined flag -usr3
  -usr4 string
    	user defined flag -usr4
  -usr5 string
    	user defined flag -usr5
  -v	version

Example

1.Config server port

//conf/conf.ini
[Server]
;Gin启动的模式,可选debug/release
mode=debug
;http server 监听端口
addr=:9898
;是否开启平滑重启
grace=true
readTimeout=3s
writeTimeout=3s
;...

2.Add router

//app/router/router.go is the file that manage all URI
func RegisterRouter(router *gin.Engine) {
	entry := router.Group("/demo", middleware.PerfMiddleware(), middleware.XesLoggerMiddleware())
	entry.GET("/test", democontroller.GaeaDemo)
}

4.Controller (mvc programming style)

//app/router/
func GaeaDemo(ctx *gin.Context) {
	goCtx := xesgin.TransferToContext(ctx)
	param := ctx.PostForm("param")
	ret, err := demoservice.DoFun(goCtx, param)
	if err != nil {
		resp := xesgin.Error(err)
		ctx.JSON(http.StatusOK, resp)
	} else {
		resp := xesgin.Success(ret)
		ctx.JSON(http.StatusOK, resp)
	}
}

运行

$ rigger start
2019/11/06 21:50:03 CONF INIT,path:../conf/conf.ini
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:    export GIN_MODE=release
 - using code:    gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /demo/test                --> myproject/app/controller/democontroller.MyXesGoDemo (3 handlers)
2019/11/06 21:50:03 [overseer master] run
2019/11/06 21:50:04 [overseer master] starting /winshare/go/src/myproject/bin/myproject
2019/11/06 21:50:04 CONF INIT,path:../conf/conf.ini
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:    export GIN_MODE=release
 - using code:    gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /demo/test                --> myproject/app/controller/democontroller.MyXesGoDemo (3 handlers)
2019/11/06 21:50:04 [overseer slave#1] run
2019/11/06 21:50:04 [overseer slave#1] start program

测试

$ curl  http://127.0.0.1:9898/demo/test
{"code":0,"data":{"ret1":"Welcome to use myproject!"},"msg":"ok","stat":1}

至此,我们已经通过Gaea搭建了一个web服务! 接下来我们进一步学习Gaea 相关配置、特性、组件应用等主题

各大主流框架路由性能对比

Gaea Logo

(图片来自于网络)

Gaea性能压测

Gaea框架相比于原生Gin 影响性能的点其实是全部集中在中间件上,因为每次http请求都会跑一边,所以,观测下在各个中间开启时对整体性能的影响情况

压测条件

条件
系统 virtualbox 虚拟机上 centos7
内存 1GB
CPU 单核
请求数量 10万
并发数量 100
传输数据 {"code":0,"data":"hell world","msg":"ok","stat":1}

压测结果

Gaea Logo

从图中我们可以明显看出:

  • Gaea的默认配置会带来一定的性能耗损,大约30%
  • 其中Logger中间件在各个中间件影响性能比重最大,其它中间件几乎可以忽略不计

在实际项目应用中,当Logger 中间件是瓶颈点时,我们可以关闭它,毕竟请求日志在网关层也会记录!

此外,对日志库使用建议日志级别设定为WARNING

联系我们

Contact Us

(微信扫一扫,申请加入开发讨论微信群)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].