Jupiter是斗鱼开源的面向服务治理的Golang微服务框架

GoTest codecov go.dev reference Go Report Card license

JUPITER: Governance-oriented Microservice Framework

Introduction

JUPITER is a governance-oriented microservice framework, which is being used for years at Douyu.

Documentation

See the 中文文档 for the Chinese documentation.

Quick Start

func main() {
	var app jupiter.Application
	app.Startup()
	app.Serve(startHTTPServer())
	app.Serve(startGRPCServer())
	app.Schedule(startWorker())
	app.Run()
}

func startHTTPServer() server.Server {
	server := xecho.DefaultConfig().Build()
	server.GET("/hello", func(ctx echo.Context) error {
		return ctx.JSON(200, "Gopher Wuhan")
	})
	return server
}

func startGRPCServer() server.Server {
	server := xgrpc.DefaultConfig().Build()
	helloworld.RegisterGreeterServer(server.Server, new(greeter.Greeter))
	return server
}

func startWorker() worker.Worker {
	cron := xcron.DefaultConfig().Build()
	cron.Schedule(xcron.Every(time.Second*10), xcron.FuncJob(func() error {
		return nil
	}))
	return cron
}

More Example:

Bugs and Feedback

For bug report, questions and discussions please submit an issue.

Contributing

Contributions are always welcomed! Please see CONTRIBUTING for detailed guidelines.

You can start with the issues labeled with good first issue.

Contact

  • DingTalk:
Comments
  • [BUG] 当主机有多个网卡时,governor服务 panic

    [BUG] 当主机有多个网卡时,governor服务 panic

    F:\code\go\jupiter\example\http\register>go run main.go --config=config.toml

    panic:
       msg: governor start error
       loc: F:/code/go/jupiter/pkg/server/governor/server.go:23
       error: listen tcp4 169.254.98.129:19090: bind: The requested address is not valid in its context.
    1597118095      PANIC   governor start error                    {"error": "listen tcp4 169.254.98.129:19090: bind: The requested address is
    not valid in its context."}
    github.com/douyu/jupiter/pkg/xlog.(*Logger).Panic
           F:/code/go/jupiter/pkg/xlog/log.go:325
    github.com/douyu/jupiter/pkg/xlog.Panic
           F:/code/go/jupiter/pkg/xlog/api.go:65
    github.com/douyu/jupiter/pkg/server/governor.newServer
           F:/code/go/jupiter/pkg/server/governor/server.go:23
    github.com/douyu/jupiter/pkg/server/governor.(*Config).Build
           F:/code/go/jupiter/pkg/server/governor/config.go:67
    github.com/douyu/jupiter.(*Application).initGovernor
           F:/code/go/jupiter/jupiter.go:349
    github.com/douyu/jupiter/pkg/util/xgo.try
           F:/code/go/jupiter/pkg/util/xgo/init.go:47
    github.com/douyu/jupiter/pkg/util/xgo.SerialUntilError.func1
           F:/code/go/jupiter/pkg/util/xgo/serial.go:36
    github.com/douyu/jupiter.(*Application).startup.func1
           F:/code/go/jupiter/jupiter.go:145
    sync.(*Once).doSlow
           D:/Go/src/sync/once.go:66
    sync.(*Once).Do
           D:/Go/src/sync/once.go:57
    github.com/douyu/jupiter.(*Application).startup
           F:/code/go/jupiter/jupiter.go:135
    github.com/douyu/jupiter.(*Application).Startup
           F:/code/go/jupiter/jupiter.go:153
    main.NewEngine
           F:/code/go/jupiter/example/http/register/main.go:44
    
    
  • [feat] support p2c with least loaded algorithm.

    [feat] support p2c with least loaded algorithm.

    Describe what this PR does / why we need it

    Grpc load balance support p2c with least loaded algorithm.

    ok  	github.com/douyu/jupiter/pkg/client/grpc/balancer/p2c	2.356s	coverage: 92.9% of statements
    

    Does this pull request fix one issue?

    Describe how you did it

    Describe how to verify it

    Special notes for reviews

  • unified stub and cluster configuration #65

    unified stub and cluster configuration #65

    Describe what this PR does / why we need it

    Unified redis single client and cluster client configuration

    Does this pull request fix one issue?

    Fixes #65

    Describe how you did it

    • rename redis.go to stub.go, redis_test.go to stub_test.go
    • add interface Redis and RedisConfig
    • make RedisStub and RedisClusterStub implement interface Redis
    • add function RawRedisConfig unified cluster and single configuration
    • compatible with past configuration

    Describe how to verify it

    example/client/redis/main.go run: go run main.go -config=config.toml

    Special notes for reviews

    • maybe we can clean old config if compatibility is not so important
    • remember to update doc, or leave it to me
  • fix: update go mod version to go1.16

    fix: update go mod version to go1.16

    Describe what this PR does / why we need it

    在使用当前项目的 go.mod 规定的最小go版本,不能正确处理依赖相关的库。

    Does this pull request fix one issue?

    这个 pr 已经修复上述问题

    Describe how you did it

    修改 go.mod 最低支持的版本为 go1.16

    Describe how to verify it

    执行 go mod tidy

    Special notes for reviews

  • fix: 传入Variable时,flag重复调用导致失败

    fix: 传入Variable时,flag重复调用导致失败

    Describe what this PR does / why we need #it

    #281

    Does this pull request fix one issue?

    Describe how you did it

    Describe how to verify it

    Special notes for reviews

  • support apollo configuration center for datasource

    support apollo configuration center for datasource

    Describe what this PR does / why we need it

    Apollo is a very common and useful microservice configuration center.

    Does this pull request fix one issue?

    no

    Describe how you did it

    Refer to the rep apollo and agollo

    Describe how to verify it

    run go test

    Special notes for reviews

  • mac go 1.19 下面报错了

    mac go 1.19 下面报错了

    golang.org/x/sys 这个依赖库版本低了

    ❯ GOPROXY=https://goproxy.cn/,direct go install github.com/douyu/jupiter/tools/jupiter@latest

    golang.org/x/sys/unix

    ../../../libs/pkg/mod/golang.org/x/[email protected]/unix/syscall_darwin.1_13.go:29:3: //go:linkname must refer to declared function or variable ../../../libs/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.1_13.go:27:3: //go:linkname must refer to declared function or variable ../../../libs/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.1_13.go:40:3: //go:linkname must refer to declared function or variable ../../../libs/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:28:3: //go:linkname must refer to declared function or variable ../../../libs/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:43:3: //go:linkname must refer to declared function or variable ../../../libs/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:59:3: //go:linkname must refer to declared function or variable ../../../libs/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:75:3: //go:linkname must refer to declared function or variable ../../../libs/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:90:3: //go:linkname must refer to declared function or variable ../../../libs/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:105:3: //go:linkname must refer to declared function or variable ../../../libs/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:121:3: //go:linkname must refer to declared function or variable ../../../libs/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:121:3: too many errors

  • [BUG]执行   go get -u github.com/douyu/jupiter/cmd/jupiter 出错

    [BUG]执行 go get -u github.com/douyu/jupiter/cmd/jupiter 出错

    Issue Description

    执行 go get -u github.com/douyu/jupiter/cmd/jupiter 报下面的错:

    github.com/douyu/jupiter/cmd/jupiter: ambiguous import: found package github.com/douyu/jupiter/cmd/jupiter in multiple modules: github.com/douyu/jupiter v0.3.2 (D:\Go\GoPath\pkg\mod\github.com\douyu\[email protected]\cmd\jupiter) github.com/douyu/jupiter/cmd/jupiter v0.0.0-20210716055700-612e8e9696ae (D:\Go\GoPath\pkg\mod\github.com\douyu\jupiter\cmd\[email protected])

    Describe what you expected to happen

    What version of Go are you using (go version)?

    1.16.4
    
    

    What operating system and processor architecture are you using (go env)?

    go env Output
    $ go env
    

    Anything else we need to know?

  • 关于grpc服务注册的server-name问题

    关于grpc服务注册的server-name问题

    // 2. 通过resolver获取服务器地址 func dialServer() { config := grpc.DefaultConfig() config = config.WithDialOption() config.Address = "etcd:///server-name" // 注意必须填写etcd:/// client := helloworld.NewGreeterClient(config.Build()) rep, err := client.SayHello(context.Background(), &helloworld.HelloRequest{ Name: "hi", }) }

    我看客户端通过 config.Address = "etcd:///server-name" 获取对应的grpc服务端信息,请问下服务端那边怎么指定这个server-name,我没有找到相关例子

  • example: add uuid server for example

    example: add uuid server for example

    Describe what this PR does / why we need it

    增加一个使用新模板的例子,实现 grpc 和 http 的 两种方式。

    Does this pull request fix one issue?

    Describe how you did it

    Describe how to verify it

    cd example/uuid

    jupiter run -c cmd/uuidserver/.jupiter.toml
    or go run .\cmd\uuidserver\main.go --config=./config/uuidserver-local-live.toml

    Special notes for reviews

  • WIP: Update config.toml

    WIP: Update config.toml

    Describe what this PR does / why we need it

    set logger async = false will be nice for developer, when i debug with etcd client and i can not get the result, because i need to wait for almost 30s for the log, but i do not kown that, this waste me last of time.

    Does this pull request fix one issue?

    Describe how you did it

    Describe how to verify it

    Special notes for reviews

  • build(deps): bump github.com/labstack/echo/v4 from 4.9.1 to 4.10.0

    build(deps): bump github.com/labstack/echo/v4 from 4.9.1 to 4.10.0

    Bumps github.com/labstack/echo/v4 from 4.9.1 to 4.10.0.

    Release notes

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

    v4.10.0

    Security

    • We are deprecating JWT middleware in this repository. Please use https://github.com/labstack/echo-jwt instead.

      JWT middleware is moved to separate repository to allow us to bump/upgrade version of JWT implementation (github.com/golang-jwt/jwt) we are using which we can not do in Echo core because this would break backwards compatibility guarantees we try to maintain.

    • This minor version bumps minimum Go version to 1.17 (from 1.16) due golang.org/x/ packages we depend on. There are several vulnerabilities fixed in these libraries.

      Echo still tries to support last 4 Go versions but there are occasions we can not guarantee this promise.

    Enhancements

    • Bump x/text to 0.3.8 #2305
    • Bump dependencies and add notes about Go releases we support #2336
    • Add helper interface for ProxyBalancer interface #2316
    • Expose middleware.CreateExtractors function so we can use it from echo-contrib repository #2338
    • Refactor func(Context) error to HandlerFunc #2315
    • Improve function comments #2329
    • Add new method HTTPError.WithInternal #2340
    • Replace io/ioutil package usages #2342
    • Add staticcheck to CI flow #2343
    • Replace relative path determination from proprietary to std #2345
    • Remove square brackets from ipv6 addresses in XFF (X-Forwarded-For header) #2182
    • Add testcases for some BodyLimit middleware configuration options #2350
    • Additional configuration options for RequestLogger and Logger middleware #2341
    • Add route to request log #2162
    • GitHub Workflows security hardening #2358
    • Add govulncheck to CI and bump dependencies #2362
    • Fix rate limiter docs #2366
    • Refactor how e.Routes() work and introduce e.OnAddRouteHandler callback #2337
    Changelog

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

    v4.10.0 - 2022-12-27

    Security

    • We are deprecating JWT middleware in this repository. Please use https://github.com/labstack/echo-jwt instead.

      JWT middleware is moved to separate repository to allow us to bump/upgrade version of JWT implementation (github.com/golang-jwt/jwt) we are using which we can not do in Echo core because this would break backwards compatibility guarantees we try to maintain.

    • This minor version bumps minimum Go version to 1.17 (from 1.16) due golang.org/x/ packages we depend on. There are several vulnerabilities fixed in these libraries.

      Echo still tries to support last 4 Go versions but there are occasions we can not guarantee this promise.

    Enhancements

    • Bump x/text to 0.3.8 #2305
    • Bump dependencies and add notes about Go releases we support #2336
    • Add helper interface for ProxyBalancer interface #2316
    • Expose middleware.CreateExtractors function so we can use it from echo-contrib repository #2338
    • Refactor func(Context) error to HandlerFunc #2315
    • Improve function comments #2329
    • Add new method HTTPError.WithInternal #2340
    • Replace io/ioutil package usages #2342
    • Add staticcheck to CI flow #2343
    • Replace relative path determination from proprietary to std #2345
    • Remove square brackets from ipv6 addresses in XFF (X-Forwarded-For header) #2182
    • Add testcases for some BodyLimit middleware configuration options #2350
    • Additional configuration options for RequestLogger and Logger middleware #2341
    • Add route to request log #2162
    • GitHub Workflows security hardening #2358
    • Add govulncheck to CI and bump dependencies #2362
    • Fix rate limiter docs #2366
    • Refactor how e.Routes() work and introduce e.OnAddRouteHandler callback #2337
    Commits
    • f36d566 Changelog for 4.10.0
    • a69727e Mark JWT middleware deprecated
    • 0056cc8 Improve comments wording
    • 45402bb Add echo.OnAddRouteHandler field. As name says - this handler is called when ...
    • f1cf1ec Fix adding route with host overwrites default host route with same method+pat...
    • 895121d Fix rate limiter docs (#2366)
    • abecadc Merge pull request #2362 from aldas/add_govulncheck_2_ci
    • bc75cc2 Add govulncheck to CI and bump dependencies. Refactor GitHub workflows.
    • 40eb889 build: harden echo.yml permissions
    • 135c511 Add request route with "route" tag to logger middleware (#2162)
    • 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)
  • feat: support clickhouse client

    feat: support clickhouse client

    Issue Description

    Type: feature request

    Describe what feature you want

    Additional context

    Add any other context or screenshots about the feature request here.

  • feat: support convert protobuf enum to error

    feat: support convert protobuf enum to error

    Issue Description

    Type: feature request

    Describe what feature you want

    Additional context

    Add any other context or screenshots about the feature request here.

  • feat: rocketmq support pull consumer

    feat: rocketmq support pull consumer

    Issue Description

    Type: feature request

    Describe what feature you want

    Additional context

    Add any other context or screenshots about the feature request here.

  • feat: support json-schema for configs

    feat: support json-schema for configs

    Issue Description

    Type: feature request

    Describe what feature you want

    Additional context

    Add any other context or screenshots about the feature request here.