stack-rpc 快速开发包

Overview

Micro 快速开发工具包

项目进行中

本仓库旨在提供面向 stack-rpc 生产环境的快速开发包。

目录

架构设计

系统架构图

业务架构图

Console示例

领域模型&整洁架构参考

目录结构

├── console             控制台示例
│   ├── account         go.micro.srv.account,Account服务
│   │   ├── domain              领域
│   │   │   ├── model           模型
│   │   │   ├── repository      存储接口
│   │   │   │   └── persistence ①存储接口实现
│   │   │   └── service         领域服务
│   │   ├── interface           接口
│   │   │   ├── handler         micro handler接口
│   │   │   └── persistence     ②存储接口实现
│   │   ├── registry            依赖注入,根据使用习惯,一般Go中不怎么喜欢这种方式
│   │   └── usecase             应用用例
│   │       ├── event           消息事件
│   │       └── service         应用服务
│   ├── api             go.micro.api.console,API服务
│   ├── pb              服务协议统一.proto
│   └── web             go.micro.api.console,Web服务,集成gin、echo、iris等web框架
├── deploy              部署
│   ├── docker
│   └── k8s
├── doc                 文档资源
├── gateway             网关,自定义micro
└── pkg                 公共资源包

目标功能

开发环境

TODO

  • 本地
  • 在线
    • CICD
    • Kubernetes
    • 本地服务接入
      • Network代理 + 流量染色

部署环境

Kubernetes环境

可选服务

Jaeger

浏览器访问:http://localhost:16686/

$ docker run -d --name=jaeger -e COLLECTOR_ZIPKIN_HTTP_PORT=9411 -p5775:5775/udp -p6831:6831/udp -p6832:6832/udp   -p5778:5778 -p16686:16686 -p14268:14268 -p9411:9411 jaegertracing/all-in-one:latest
Prometheus

浏览器访问:http://localhost:9090/

prometheus.yml参考gateway插件`metrics/prometheus.yml

$ docker run -d --name prometheus -p 9090:9090 -v ~/tmp/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
Grafana

浏览器访问:http://localhost:3000/

Grafana仪表盘importmetrics/grafan.json

$ docker run --name grafana -d -p 3000:3000 grafana/grafana

参与贡献

代码格式

  • IDE IDEA/Goland,Go->imports 设置
    • Sorting type gofmt
    • Group stdlib imports
      • Move all stdlib imports in a single group
    • Move all imports in a single declaration
Comments
  • Error to span

    Error to span

    It's a way to put errors from example func (*Account) Login(ctx context.Context, req *pb.LoginRequest, rsp *pb.Response) error { automaticaly to span ? Maybe some changes in warrper ?

    I added

    	return func(h server.HandlerFunc) server.HandlerFunc {
    		return func(ctx context.Context, req server.Request, rsp interface{}) error {
    			if ot == nil {
    				ot = opentracing.GlobalTracer()
    			}
    			name := fmt.Sprintf("%s", req.Endpoint())
    			ctx, span, err := SpanFromContext(ctx, ot, name)
    
    			span.LogKV("reg", req)
    			span.LogKV("rsp", rsp)
    

    but i don't know how to catch error from Login func

    opened by sobiso 5
  • cannot find module statik

    cannot find module statik

    starter-kit/app/console/web/statik: cannot find module providing package github.com/micro-in-cn/starter-kit/app/console/web/statik

    go:generate statik -src=./vue/dist -dest=./ -f 怎么操作?

    opened by hesen2006cn 4
  • rancher 配置文件自动生成 配合k8s 使用

    rancher 配置文件自动生成 配合k8s 使用

    Rancher是开源软件,它结合了组织需要采用的所有组件,并在生产环境中运行容器。Rancher基于Kubernetes构建,使DevOps团队可以轻松测试、部署和管理他们的应用程序。运维团队使用Rancher来部署、管理和维护各个Kubernetes集群,而不需关心它运行在何处。

    参考yaml 文件

    • 支持流水线
    • 基于 k8s yaml 文件
    stages:
    # 依赖 redis 部署 
    - name: Redis
      steps:
      - applyAppConfig:
          catalogTemplate: cattle-global-data:library-redis
          version: 3.0.2
          answers:
            master.persistence.enabled: "true"
            cluster.slaveCount: "2"
          name: redis
          targetNamespace: api
    # 配置部署
    - name: Config
      steps:
      - applyYamlConfig:
          path: ./config.yaml
    # rpc 接口部署
    - name: Micro
      steps:
      - applyYamlConfig:
          path: ./app/micro-api.yaml
    # user 用户数据库
    - name: UserMariadb
      steps:
      - applyAppConfig:
          catalogTemplate: cattle-global-data:library-mariadb
          version: 5.0.9
          answers:
            db.name: user
            db.user: user
            service.type: ClusterIP
            slave.replicas: "2"
          name: user
          targetNamespace: srv
    # user 用户服务
    - name: User
      steps:
      - applyYamlConfig:
          path: ./app/user.yaml
    # user-api 用户 API 服务
    - name: UserApi
      steps:
      - applyYamlConfig:
          path: ./app/user-api.yaml
    

    k8s 部分例子

    # 负载均衡
    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
      name: micro-ingress
      namespace: api
    spec:
      rules:
      - host: xip.io
        http:
          paths:
            - backend:
                serviceName: micro
                servicePort: http
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: micro
      namespace: api
    spec:
      selector:
        app: micro
      type: ClusterIP
      ports:
        - name: http
          port: 8080
          protocol: TCP
          targetPort: 8080
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: micro
      namespace: api
      labels:
        app: micro
    spec:
      replicas: 3
      selector:
        matchLabels:
          app: micro
      template:
        metadata:
          labels:
            app: micro
        spec:
          serviceAccountName: micro-services
          containers:
            - name: micro
              image: microhq/micro:kubernetes
              args:
                - "api"
                - "--handler=rpc"
                - "--address=0.0.0.0:8080"
              env:
              - name: MICRO_SERVER_NAME
                value: micro
              - name: MICRO_SERVER_ADDRESS
                value: 0.0.0.0:8989
              ports:
              - containerPort: 8080
                name: http
                protocol: TCP
            - name: health
              command: [
                "/health",
                "--health_address=0.0.0.0:8081",
                "--server_name=micro",
                "--server_address=0.0.0.0:8989"
    	        ]
              image: microhq/health:kubernetes
              livenessProbe:
                httpGet:
                  path: /health
                  port: 8081
                initialDelaySeconds: 3
                periodSeconds: 3
    
    
    
    
    
    
    kind: Service
    apiVersion: v1
    metadata:
      name: user
      namespace: srv
    spec:
      selector:
        app: user
      type: ClusterIP
      ports:
        - protocol: TCP
          port: 8080
          name: micro
          targetPort: 8080
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: user
      namespace: srv
      labels:
        app: user
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: user
      template:
        metadata:
          labels:
            app: user
        spec:
          serviceAccountName: micro-services
          imagePullSecrets:
          - name: pipeline-docker-registry
          containers:
            - name: user
              image: gmsa/user:latest
              imagePullPolicy: Always
              command: [
                "service",
                "--selector=static",
                "--server_address=:8080",
              ]
              env:
                - name: ADMIN_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      key: admin-password
                      name: user
                - name: APP_KEY
                  valueFrom:
                    secretKeyRef:
                      key: app-key
                      name: user
                - name: TOKEN_VALIDITY_PERIOD
                  value: "15"
                - name: DB_HOST
                  value: "user-mariadb"
                - name: DB_USER
                  value: "user"
                - name: DB_NAME
                  value: "user"
                - name: DB_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      key: mariadb-password
                      name: user-mariadb
              ports:
              - containerPort: 8080
                name: micro
                protocol: TCP
            - name: health
              image: microhq/health:kubernetes
              command: [
                "/health",
                "--health_address=0.0.0.0:8081",
                "--server_name=user",
                "--server_address=0.0.0.0:8080"
              ]
              livenessProbe:
                httpGet:
                  path: /health
                  port: 8081
                initialDelaySeconds: 3
                periodSeconds: 3
    
    
    enhancement help wanted 
    opened by bigrocs 4
  • go 1.13.4下启动gateway报找不到字段

    go 1.13.4下启动gateway报找不到字段

    错误码

    \pkg\mod\github.com\micro\[email protected]\runtime\process\os\os.go:29:41: unknown field 'Setpgid' in struct literal of type syscall.SysProcAttr
    

    我点击进去的时候,发现这个版本下已经没有这些对应的属性值了unknown field 'Setpgid'undefined: syscall.Getpgidundefined: syscall.Kill, 想问一下 这个启动的go版本是?

    opened by JUSTZWH 2
  • 网关代理不成功

    网关代理不成功

    只开gateway与web,网关应该也是可以代理的吧。但是报找不到服务 curl http://localhost:8080/v1/gin 返回:{"id":"go.micro.api","code":500,"detail":"service not found","status":"Internal Server Error"}

    opened by gq-tang 1
  • 找不到api.proto 文件

    找不到api.proto 文件

    protoc --proto_path=/Users/ln/gopath/src:. --micro_out=. --go_out=. proto/*/*.proto
    
    
    github.com/micro/go-micro/api/proto/api.proto: File not found.
    proto/api/account.proto:5:1: Import "github.com/micro/go-micro/api/proto/api.proto" was not found or had errors.
    proto/api/account.proto:8:16: "go.api.Request" is not defined.
    proto/api/account.proto:8:41: "go.api.Response" is not defined.
    proto/api/account.proto:10:17: "go.api.Request" is not defined.
    proto/api/account.proto:10:42: "go.api.Response" is not defined.
    proto/api/account.proto:12:15: "go.api.Request" is not defined.
    proto/api/account.proto:12:40: "go.api.Response" is not defined.
    
    opened by taianrc 1
  • Bump github.com/labstack/echo/v4 from 4.1.11 to 4.9.0

    Bump github.com/labstack/echo/v4 from 4.1.11 to 4.9.0

    Bumps github.com/labstack/echo/v4 from 4.1.11 to 4.9.0.

    Release notes

    Sourced from github.com/labstack/echo/v4's releases.

    v4.9.0

    Security

    • Fix open redirect vulnerability in handlers serving static directories (e.Static, e.StaticFs, echo.StaticDirectoryHandler) #2260

    Enhancements

    • Allow configuring ErrorHandler in CSRF middleware #2257
    • Replace HTTP method constants in tests with stdlib constants #2247

    v4.8.0

    Most notable things

    You can now add any arbitrary HTTP method type as a route #2237

    e.Add("COPY", "/*", func(c echo.Context) error 
      return c.String(http.StatusOK, "OK COPY")
    })
    

    You can add custom 404 handler for specific paths #2217

    e.RouteNotFound("/*", func(c echo.Context) error { return c.NoContent(http.StatusNotFound) })
    

    g := e.Group("/images") g.RouteNotFound("/*", func(c echo.Context) error { return c.NoContent(http.StatusNotFound) })

    Enhancements

    • Add new value binding methods (UnixTimeMilli,TextUnmarshaler,JSONUnmarshaler) to Valuebinder #2127
    • Refactor: body_limit middleware unit test #2145
    • Refactor: Timeout mw: rework how test waits for timeout. #2187
    • BasicAuth middleware returns 500 InternalServerError on invalid base64 strings but should return 400 #2191
    • Refactor: duplicated findStaticChild process at findChildWithLabel #2176
    • Allow different param names in different methods with same path scheme #2209
    • Add support for registering handlers for different 404 routes #2217
    • Middlewares should use errors.As() instead of type assertion on HTTPError #2227
    • Allow arbitrary HTTP method types to be added as routes #2237

    v4.7.2

    Fixes

    • Fix nil pointer exception when calling Start again after address binding error #2131
    • Fix CSRF middleware not being able to extract token from multipart/form-data form #2136
    • Fix Timeout middleware write race #2126

    Enhancements

    ... (truncated)

    Changelog

    Sourced from github.com/labstack/echo/v4's changelog.

    v4.9.0 - 2022-09-04

    Security

    • Fix open redirect vulnerability in handlers serving static directories (e.Static, e.StaticFs, echo.StaticDirectoryHandler) #2260

    Enhancements

    • Allow configuring ErrorHandler in CSRF middleware #2257
    • Replace HTTP method constants in tests with stdlib constants #2247

    v4.8.0 - 2022-08-10

    Most notable things

    You can now add any arbitrary HTTP method type as a route #2237

    e.Add("COPY", "/*", func(c echo.Context) error 
      return c.String(http.StatusOK, "OK COPY")
    })
    

    You can add custom 404 handler for specific paths #2217

    e.RouteNotFound("/*", func(c echo.Context) error { return c.NoContent(http.StatusNotFound) })
    

    g := e.Group("/images") g.RouteNotFound("/*", func(c echo.Context) error { return c.NoContent(http.StatusNotFound) })

    Enhancements

    • Add new value binding methods (UnixTimeMilli,TextUnmarshaler,JSONUnmarshaler) to Valuebinder #2127
    • Refactor: body_limit middleware unit test #2145
    • Refactor: Timeout mw: rework how test waits for timeout. #2187
    • BasicAuth middleware returns 500 InternalServerError on invalid base64 strings but should return 400 #2191
    • Refactor: duplicated findStaticChild process at findChildWithLabel #2176
    • Allow different param names in different methods with same path scheme #2209
    • Add support for registering handlers for different 404 routes #2217
    • Middlewares should use errors.As() instead of type assertion on HTTPError #2227
    • Allow arbitrary HTTP method types to be added as routes #2237

    v4.7.2 - 2022-03-16

    Fixes

    • Fix nil pointer exception when calling Start again after address binding error #2131
    • Fix CSRF middleware not being able to extract token from multipart/form-data form #2136
    • Fix Timeout middleware write race #2126

    ... (truncated)

    Commits
    • 16d3b65 Changelog for 4.9.0
    • 0ac4d74 Fix #2259 open redirect vulnerability in echo.StaticDirectoryHandler (used by...
    • d77e8c0 Added ErrorHandler and ErrorHandlerWithContext in CSRF middleware (#2257)
    • 534bbb8 replace POST constance with stdlib constance
    • fb57d96 replace GET constance with stdlib constance
    • d48197d Changelog for 4.8.0
    • cba12a5 Allow arbitrary HTTP method types to be added as routes
    • a327884 add:README.md-Third-party middlewares-github.com/go-woo/protoc-gen-echo
    • 61422dd Update CI-flow (Go 1.19 +deps)
    • a9879ff Middlewares should use errors.As() instead of type assertion on HTTPError
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies go 
    opened by dependabot[bot] 0
  • service name change

    service name change

    I want to rename some services for test I am working on in Linkerd, so instead of using adservice in services.yaml, I will have adservice-east. so the frontend will send request to adservice-east instead of adservice

    I am not a GO programmer, I would be grateful if anybody can point me where this can be done in the frontservice source code

    opened by ezemegwara 0
  • codahale/hdrhistogram repo url has been transferred under the github HdrHstogram umbrella

    codahale/hdrhistogram repo url has been transferred under the github HdrHstogram umbrella

    Problem

    The codahale/hdrhistogram repo has been transferred under the github HdrHstogram umbrella with the help from the original author in Sept 2020 (new repo url https://github.com/HdrHistogram/hdrhistogram-go). The main reasons are to group all implementations under the same roof and to provide more active contribution from the community as the original repository was archived several years ago.

    The dependency URL should be modified to point to the new repository URL. The tag "v0.9.0" was applied at the point of transfer and will reflect the exact code that was frozen in the original repository.

    If you are using Go modules, you can update to the exact point of transfer using the @v0.9.0 tag in your go get command.

    go mod edit -replace github.com/codahale/hdrhistogram=github.com/HdrHistogram/[email protected]
    

    Performance Improvements

    From the point of transfer, up until now (mon 16 aug 2021), we've released 3 versions that aim support the standard HdrHistogram serialization/exposition formats, and deeply improve READ performance. We recommend to update to the latest version.

    opened by filipecosta90 0
Releases(v2.4.0)
Owner
Stack Labs
Micro Stack Lab
Stack Labs
RPC explained by writing simple RPC framework in 300 lines of pure Golang.

Simple GoRPC Learning RPC basic building blocks by building a simple RPC framework in Golang from scratch. RPC In Simple Term Service A wants to call

Ankur Anand 545 Nov 25, 2022
Sample full stack micro services application built using the go-Micro framework.

goTemp goTemp is a full stack Golang microservices sample application built using go-micro. The application is built as a series of services that prov

null 63 Oct 18, 2022
goTempM is a full stack Golang microservices sample application built on top of the Micro platform.

goTempM is a full stack Golang microservices sample application built on top of the Micro platform.

null 30 Sep 24, 2022
The Full-Stack Web Framework for Go

Bud The Full-Stack Web Framework for Go. Bud writes the boring code for you, helping you launch your website faster. Video Demo Watch a video demonstr

Live Bud 4.9k Nov 28, 2022
A code generator that turns plain old Go services into RPC-enabled (micro)services with robust HTTP APIs.

Frodo is a code generator and runtime library that helps you write RPC-enabled (micro) services and APIs.

Monadic 21 Oct 25, 2022
Automatic Service Mesh and RPC generation for Go micro services, it's a humble alternative to gRPC with Istio.

Mesh RPC MeshRPC provides automatic Service Mesh and RPC generation for Go micro services, it's a humble alternative to gRPC with Istio. In a nutshell

AstraNet Toolkit 69 Aug 22, 2022
Kitex byte-dance internal Golang microservice RPC framework with high performance and strong scalability, customized extensions for byte internal.

Kitex 字节跳动内部的 Golang 微服务 RPC 框架,具有高性能、强可扩展的特点,针对字节内部做了定制扩展。

CloudWeGo 5.3k Nov 28, 2022
Solution & Framework for JSON-RPC over HTTP

JROH Solution & Framework for JSON-RPC over HTTP Why not OpenAPI? OpenAPI addresses the definition of RESTful APIs, when it comes to JSON-RPCs, some i

Go Toolkit 11 Mar 13, 2022
Golang client for Ethereum and Flashbots JSON-RPC API calls.

Flashbots RPC client Fork of ethrpc with additional Flashbots RPC methods: FlashbotsGetUserStats FlashbotsCallBundle FlashbotsSendBundle FlashbotsSimu

Chris Hager 101 Nov 20, 2022
Rpcx-framework - An RPC microservices framework based on rpcx, simple and easy to use, ultra fast and efficient, powerful, service discovery, service governance, service layering, version control, routing label registration.

RPCX Framework An RPC microservices framework based on rpcx. Features: simple and easy to use, ultra fast and efficient, powerful, service discovery,

ZYallers 1 Jan 5, 2022
This project implements p11-kit RPC server protocol, allowing Go programs to act as a PKCS #11 module without the need for cgo

PKCS #11 modules in Go without cgo This project implements p11-kit RPC server protocol, allowing Go programs to act as a PKCS #11 module without the n

Google 43 Oct 8, 2022
Package gostackparse parses goroutines stack traces as produced by panic() or debug.Stack() at ~300 MiB/s.

gostackparse Package gostackparse parses goroutines stack traces as produced by panic() or debug.Stack() at ~300 MiB/s. Parsing this data can be usefu

Datadog, Inc. 84 Nov 10, 2022
Elastic Stack Docker + Sample Go AppElastic Stack Docker + Sample Go App

?? Elastic Stack Docker + Sample Go App Test Elastic Stack which includes Elasticsearch, Kibana, Filebeat and Metricbeat. It comes with a very simple

Ruben Delgado 0 Jan 14, 2022
Cap'n Proto library and parser for go. This is go-capnproto-1.0, and does not have rpc. See https://github.com/zombiezen/go-capnproto2 for 2.0 which has rpc and capabilities.

Version 1.0 vs 2.0 Update 2015 Sept 20: Big news! Version 2.0 of the go-bindings, authored by Ross Light, is now released and newly available! It feat

Jason E. Aten, Ph.D. 286 Nov 29, 2022
RPC explained by writing simple RPC framework in 300 lines of pure Golang.

Simple GoRPC Learning RPC basic building blocks by building a simple RPC framework in Golang from scratch. RPC In Simple Term Service A wants to call

Ankur Anand 545 Nov 25, 2022
Antenna RPC is an RPC protocol for distributed computing, it's based on QUIC and Colfer. its currently an WIP.

aRPC - Antenna Remote Procedure Call Antenna remote procedure call (aRPC) is an RPC protocol focused on distributed processing and HPC. aRPC is implem

Raphael de Carvalho Almeida 3 Jun 16, 2021
rpc/v2 support for JSON-RPC 2.0 Specification.

rpc rpc/v2 support for JSON-RPC 2.0 Specification. gorilla/rpc is a foundation for RPC over HTTP services, providing access to the exported methods of

High Performance, Kubernetes Native Object Storage 3 Jul 4, 2021
Go Substrate RPC Client (GSRPC)Go Substrate RPC Client (GSRPC)

Go Substrate RPC Client (GSRPC) Substrate RPC client in Go. It provides APIs and types around Polkadot and any Substrate-based chain RPC calls. This c

Chino Chang 1 Nov 11, 2021
RPC Framework abstraction layer. Provides foundation of the RonyDesc to generate RPC server/client codes.

RonyKit RonyKit provides the abstraction layer for creating a cluster aware API server. By defining separate components for each task, you are almost

Ronak Software Group 5 Nov 1, 2022
A slice-based implementation of a stack. In Go!

Stackgo Stackgo is a slice-based implementation of a simple stack in Go. It uses a pre-alloc pagination strategy which adds little memory overhead to

Alessandro Diaferia 16 Nov 3, 2022