Skip to content

leewckk/go-kit-micro-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-kit-micro-service

go-kit-micro-service是基于项目go kit开发的微服务系统框架,集成了服务注册/服务发现/负载均衡/限流/断流/链路追踪等相关微服务治理的封装,可以通过插件protoc-gen-gokit-micro实现业务代码以及接口HTTP + GRPC的自动生成,完成微服务应用的快速搭建。

官方参考架构模型

官方参考架构

go-kit-micro-service架构模型

go-kit-micro-service参考模型

功能概要

使用方法

环境准备

依赖环境如下:

  • protobuf
  • protoc-gen-go
  • protoc-gen-go-grpc
  • protoc-gen-gprc-gateway
  • protoc-gen-openapiv2
  • protoc-gen-gokit-micro

protobuf安装

编译环境
$ sudo apt-get install autoconf automake libtool make g++
下载源码并编译

通过github下载对应版本的protobuf

$ wget https://github.com/protocolbuffers/protobuf/releases/download/v21.5/protobuf-cpp-3.21.5.tar.gz
$ tar -xvf ./protobuf-cpp-3.21.5.tar.gz
protobuf-3.21.5/
protobuf-3.21.5/WORKSPACE
...

编译安装

$ cd protobuf-3.21.5/
protobuf-3.21.5 $ ./autogen.sh
protobuf-3.21.5 $ ./configure
protobuf-3.21.5 $ make
protobuf-3.21.5 $ sudo make install
protobuf-3.21.5 $ sudo ldconfig

protoc-gen相关插件

$ go get -u github.com/golang/protobuf/protoc-gen-go
$ go get -u github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway
$ go get -u github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2
$ go install github.com/golang/protobuf/protoc-gen-go
$ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest

protoc-gen-gokit-micro插件

$ go get -u github.com/leewckk/protoc-gen-gokit-micro

所有需要的prtoc插件如下:

protobuf-3.21.5 $ ls ~/go/bin/ -alh | grep protoc
-rwxrwxr-x 1 liwenchao liwenchao 6.8M Aug 15 16:17 protoc-gen-go
-rwxrwxr-x 1 liwenchao liwenchao 6.7M Aug 15 16:17 protoc-gen-go-grpc
-rwxrwxr-x 1 liwenchao liwenchao  12M Aug 15 16:12 protoc-gen-gokit-micro
-rwxrwxr-x 1 liwenchao liwenchao 9.3M Aug 15 16:15 protoc-gen-grpc-gateway
-rwxrwxr-x 1 liwenchao liwenchao 9.9M Aug 15 16:15 protoc-gen-openapiv2

插件说明

参考代码

服务端

客户端

API网关

快速构建服务

模块介绍

服务注册与发现

链路追踪

限流

断流

protoc-gen-go-kit-micro插件使用

项目模板的使用

go-kit-micro-service-template,是go-kit-micro-service使用的参考模板,使用方法如下:

step 1 clone代码

$ git clone https://github.com/leewckk/go-kit-micro-service-template.git

step 2 初始化项目

假设项目名称为一个处理订单的业务,项目名称service-bill

go-kit-micro-service-template git:(master) $ ./init.sh service-bill

About

Integrated go-kit + http(gin) + grpc + ratelimit(uber ratelimit + juju ratelimit) can be used as the basic development framework for golang microservices

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages