All Projects → yoyofx → Yoyogo

yoyofx / Yoyogo

Licence: mit
🦄🌈 YoyoGo is a simple, light and fast , dependency injection based micro-service framework written in Go. Support Nacos ,Consoul ,Etcd ,Eureka ,kubernetes.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Yoyogo

Dapr
Dapr is a portable, event-driven, runtime for building distributed applications across cloud and edge.
Stars: ✭ 16,274 (+5775.09%)
Mutual labels:  microservices, containers
Protodep
Collect necessary .proto files (Protocol Buffers IDL) and manage dependencies
Stars: ✭ 167 (-39.71%)
Mutual labels:  microservices, grpc
Kratos
A modular-designed and easy-to-use microservices framework in Go.
Stars: ✭ 15,844 (+5619.86%)
Mutual labels:  microservices, grpc
Go Micro Boilerplate
The boilerplate of the GoLang application with a clear microservices architecture.
Stars: ✭ 147 (-46.93%)
Mutual labels:  microservices, grpc
Nstack
Type-safe, composable microservices for data analytics
Stars: ✭ 219 (-20.94%)
Mutual labels:  microservices, containers
Zeebe
Distributed Workflow Engine for Microservices Orchestration
Stars: ✭ 2,165 (+681.59%)
Mutual labels:  microservices, grpc
Micro Starter Kit
Cloud Native GoLang Microservices - gRPC, GraphQL
Stars: ✭ 167 (-39.71%)
Mutual labels:  microservices, grpc
Kontena
The developer friendly container and micro services platform. Works on any cloud, easy to setup, simple to use.
Stars: ✭ 1,480 (+434.3%)
Mutual labels:  microservices, containers
Goku Api Gateway
A Powerful HTTP API Gateway in pure golang!Goku API Gateway (中文名:悟空 API 网关)是一个基于 Golang开发的微服务网关,能够实现高性能 HTTP API 转发、服务编排、多租户管理、API 访问权限控制等目的,拥有强大的自定义插件系统可以自行扩展,并且提供友好的图形化配置界面,能够快速帮助企业进行 API 服务治理、提高 API 服务的稳定性和安全性。
Stars: ✭ 2,773 (+901.08%)
Mutual labels:  microservices, middleware
Hello Auth Grpc
two grpc microservices with mutual TLS and token authentication in Go
Stars: ✭ 208 (-24.91%)
Mutual labels:  microservices, grpc
Coolstore Microservices
A full-stack .NET microservices build on Dapr and Tye
Stars: ✭ 1,903 (+587%)
Mutual labels:  microservices, grpc
Gloo
The Feature-rich, Kubernetes-native, Next-Generation API Gateway Built on Envoy
Stars: ✭ 3,219 (+1062.09%)
Mutual labels:  microservices, grpc
Dubbo Go Pixiu
Based on the proxy gateway service of dubbo-go, it solves the problem that the external protocol calls the internal Dubbo cluster. At present, it supports HTTP and gRPC[developing].
Stars: ✭ 124 (-55.23%)
Mutual labels:  microservices, grpc
Modernarchitectureshop
The Microservices Online Shop is an application with a modern software architecture that is cleanly designed and based on.NET lightweight technologies. The shop has two build variations. The first variant is the classic Microservices Architectural Style. The second one is with Dapr. Dapr has a comprehensive infrastructure for building highly decoupled Microservices; for this reason, I am using Dapr to achieve the noble goal of building a highly scalable application with clean architecture and clean code.
Stars: ✭ 154 (-44.4%)
Mutual labels:  microservices, grpc
Jib
🏗 Build container images for your Java applications.
Stars: ✭ 11,370 (+4004.69%)
Mutual labels:  microservices, containers
K8s App Engine
Application delivery engine for k8s
Stars: ✭ 166 (-40.07%)
Mutual labels:  microservices, containers
Grpcjsontranscoder
A filter which allows a RESTful JSON API client to send requests to .NET web server over HTTP and get proxied to a gRPC service
Stars: ✭ 97 (-64.98%)
Mutual labels:  microservices, grpc
Pipeline
Banzai Cloud Pipeline is a solution-oriented application platform which allows enterprises to develop, deploy and securely scale container-based applications in multi- and hybrid-cloud environments.
Stars: ✭ 1,445 (+421.66%)
Mutual labels:  microservices, containers
Grpc Go
The Go language implementation of gRPC. HTTP/2 based RPC
Stars: ✭ 15,042 (+5330.32%)
Mutual labels:  microservices, grpc
Service Fabric
We've moved!
Stars: ✭ 258 (-6.86%)
Mutual labels:  microservices, containers

中文 / English

YoyoGo 简单、轻量、快速、基于依赖注入的微服务框架

Release Go GoVersion Report Documentation Contributors License

特色

  • 漂亮又快速的路由器
  • 中间件支持 (handler func & custom middleware)
  • 微服务框架抽象了分层,在一个框架体系兼容各种server实现,如 rest,grpc等
  • 受到许多出色的 Go Web 框架的启发,server可替换,目前实现了 fasthttpnet.http

QQ交流群: 780385870 (Go浪文学院) , 在这里感谢贾国锦帮忙设计的logo很漂亮。

也可以加入我的公众号,通过公众号入群菜单进入微信群

感兴趣的朋友

框架安装

go get github.com/yoyofx/yoyogo

安装依赖 (由于某些原因国内下载不了依赖)

go version < 1.13

window 下在 cmd 中执行:
set GO111MODULE=on
set GOPROXY=https://goproxy.io,direct,https://mirrors.aliyun.com/goproxy/,https://goproxy.cn,https://athens.azurefd.net,https://gonexus.dev 
linux  下执行:
export GO111MODULE=on
export GOPROXY=https://goproxy.cn

go version >= 1.13

go env -w GOPROXY=https://goproxy.io,direct,https://mirrors.aliyun.com/goproxy/,https://goproxy.cn,https://athens.azurefd.net,https://gonexus.dev

vendor

go mod vendor       // 将依赖包拷贝到项目目录中去

简单的例子

package main
import ...

func main() {
	WebApplication.CreateDefaultBuilder(func(rb router.IRouterBuilder) {
        rb.GET("/info",func (ctx *context.HttpContext) {    // 支持Group方式
            ctx.JSON(200, context.H{"info": "ok"})
        })
    }).Build().Run()       //默认端口号 :8080
}

实现进度

标准功能

  • [X] 打印Logo和日志(YoyoGo)
  • [X] 统一程序输入参数和环境变量 (YoyoGo)
  • [X] 简单路由器绑定句柄功能
  • [X] HttpContext 上下文封装(请求,响应)
  • [X] 静态文件端点(静态文件服务器)
  • [X] JSON 序列化结构(Context.H)
  • [X] 获取请求文件并保存
  • [X] 获取请求数据(form-data,x-www-form-urlencoded,Json ,XML,Protobuf 等)
  • [X] Http 请求的绑定模型(Url, From,JSON,XML,Protobuf)

响应渲染功能

  • [X] Render Interface
  • [X] JSON Render
  • [X] JSONP Render
  • [X] Indented Json Render
  • [X] Secure Json Render
  • [X] Ascii Json Render
  • [X] Pure Json Render
  • [X] Binary Data Render
  • [X] TEXT
  • [X] Protobuf
  • [X] MessagePack
  • [X] XML
  • [X] YAML
  • [X] File
  • [X] Image
  • [X] Template
  • [X] Auto formater Render

中间件

  • [X] Logger
  • [X] StaticFile
  • [X] Router Middleware
  • [X] CORS
  • [X] Binding
  • [X] JWT
  • [X] RequestId And Tracker for SkyWorking

路由

  • [x] GET,POST,HEAD,PUT,DELETE 方法支持
  • [x] 路由解析树与表达式支持
  • [x] RouteData路由数据 (/api/:version/) 与 Binding的集成
  • [x] 路由组功能
  • [x] MVC默认模板功能
  • [x] 路由过滤器 Filter

MVC

  • [x] 路由请求触发Controller&Action
  • [x] Action方法参数绑定
  • [x] 内部对象的DI化
  • [x] 关键对象的参数传递

Dependency injection

  • [X] 抽象集成第三方DI框架
  • [X] MVC模式集成
  • [X] 框架级的DI支持功能

扩展

  • [X] 配置
  • [X] WebSocket
  • [X] JWT
  • [ ] swagger
  • [ ] GRpc
  • [X] Prometheus

进阶范例

package main

import
...

func main() {
	webHost := CreateCustomWebHostBuilder().Build()
	webHost.Run()
}

// 自定义HostBuilder并支持 MVC 和 自动参数绑定功能,简单情况也可以直接使用CreateDefaultBuilder 。
func CreateCustomBuilder() *abstractions.HostBuilder {

	configuration := abstractions.NewConfigurationBuilder().
		AddEnvironment().
		AddYamlFile("config").Build()

	return WebApplication.NewWebHostBuilder().
		UseConfiguration(configuration).
		Configure(func(app *WebApplication.WebApplicationBuilder) {
			app.UseMiddleware(middlewares.NewCORS())
			//WebApplication.UseMiddleware(middlewares.NewRequestTracker())
			app.UseStaticAssets()
			app.UseEndpoints(registerEndpointRouterConfig)
			app.UseMvc(func(builder *mvc.ControllerBuilder) {
				//builder.AddViews(&view.Option{Path: "./static/templates"})
				builder.AddViewsByConfig()
				builder.AddController(contollers.NewUserController)
				builder.AddFilter("/v1/user/info", &contollers.TestActionFilter{})
			})
		}).
		ConfigureServices(func(serviceCollection *dependencyinjection.ServiceCollection) {
			serviceCollection.AddTransientByImplements(models.NewUserAction, new(models.IUserAction))
			//eureka.UseServiceDiscovery(serviceCollection)
			//consul.UseServiceDiscovery(serviceCollection)
			nacos.UseServiceDiscovery(serviceCollection)
		}).
		OnApplicationLifeEvent(getApplicationLifeEvent)
}

//region endpoint 路由绑定函数
func registerEndpoints(rb router.IRouterBuilder) {
	Endpoints.UseHealth(rb)
	Endpoints.UseViz(rb)
	Endpoints.UsePrometheus(rb)
	Endpoints.UsePprof(rb)
	Endpoints.UseJwt(rb)

	rb.GET("/error", func(ctx *context.HttpContext) {
		panic("http get error")
	})

	//POST 请求: /info/:id ?q1=abc&username=123
	rb.POST("/info/:id", func(ctx *context.HttpContext) {
		qs_q1 := ctx.Query("q1")
		pd_name := ctx.Param("username")

		userInfo := &UserInfo{}

		_ = ctx.Bind(userInfo) // 手动绑定请求对象

		strResult := fmt.Sprintf("Name:%s , Q1:%s , bind: %s", pd_name, qs_q1, userInfo)

		ctx.JSON(200, context.H{"info": "hello world", "result": strResult})
	})

	// 路由组功能实现绑定 GET 请求:  /v1/api/info
	rb.Group("/v1/api", func(router *router.RouterGroup) {
		router.GET("/info", func(ctx *context.HttpContext) {
			ctx.JSON(200, context.H{"info": "ok"})
		})
	})

	// GET 请求: HttpContext.RequiredServices获取IOC对象
	rb.GET("/ioc", func(ctx *context.HttpContext) {
		var userAction models.IUserAction
		_ = ctx.RequiredServices.GetService(&userAction)
		ctx.JSON(200, context.H{"info": "ok " + userAction.Login("zhang")})
	})
}

//endregion

//region 请求对象
type UserInfo struct {
	UserName string `param:"username"`
	Number   string `param:"q1"`
	Id       string `param:"id"`
}

// ----------------------------------------- MVC 定义 ------------------------------------------------------

// 定义Controller
type UserController struct {
	*mvc.ApiController
	userAction models.IUserAction // IOC 对象参数
}

// 构造器依赖注入
func NewUserController(userAction models.IUserAction) *UserController {
	return &UserController{userAction: userAction}
}

// 请求对象的参数化绑定
type RegiserRequest struct {
	mvc.RequestBody
	UserName string `param:"username"`
	Password string `param:"password"`
}

// Register函数自动绑定参数
func (this *UserController) Register(ctx *context.HttpContext, request *RegiserRequest) actionresult.IActionResult {
	result := mvc.ApiResult{Success: true, Message: "ok", Data: request}
	return actionresult.Json{Data: result}
}

// use userAction interface by ioc  
func (this *UserController) GetInfo() mvc.ApiResult {
	return this.OK(this.userAction.Login("zhang"))
}

// Web程序的开始与停止事件
func fireApplicationLifeEvent(life *abstractions.ApplicationLife) {
	printDataEvent := func(event abstractions.ApplicationEvent) {
		fmt.Printf("[yoyogo] Topic: %s; Event: %v\n", event.Topic, event.Data)
	}
	for {
		select {
		case ev := <-life.ApplicationStarted:
			go printDataEvent(ev)
		case ev := <-life.ApplicationStopped:
			go printDataEvent(ev)
			break
		}
	}
}

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].