Skip to content

Commit

Permalink
Feat/app runtime (#251)
Browse files Browse the repository at this point in the history
* refactor application; remove multi register; polish codes; fix tests bugs;
  • Loading branch information
gorexlv authored Aug 19, 2021
1 parent 3d1b311 commit 2356308
Show file tree
Hide file tree
Showing 40 changed files with 1,117 additions and 568 deletions.
8 changes: 0 additions & 8 deletions example/all/cmd/demo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,11 @@ import (
"log"

"github.com/douyu/jupiter/example/all/internal/app/demo"
"github.com/douyu/jupiter/pkg/registry/compound"
"github.com/douyu/jupiter/pkg/registry/etcdv3"
)

func main() {
eng := demo.NewEngine()

eng.SetRegistry( // 多注册中心
compound.New(
etcdv3.StdConfig("wh01").MustBuild(),
),
)

if err := eng.Run(); err != nil {
log.Fatal(err)
}
Expand Down
12 changes: 0 additions & 12 deletions example/all/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@
port = 20105
[jupiter.server.grpc]
port = 20102

[jupiter.etcdv3.default]
endpoints=["127.0.0.1:2379"]
secure = false

[jupiter.registry.wh01]
configKey="jupiter.etcdv3.default"
timeout = "1s"

[jupiter.registry.wh02]
configKey="jupiter.etcdv3.default"
timeout = "1s"

[jupiter.cron.demo]
immediatelyRun = true
Expand Down
4 changes: 2 additions & 2 deletions example/all/internal/app/demo/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package demo
import (
"time"

sentinel_echo "github.com/alibaba/sentinel-golang/adapter/echo"
"github.com/alibaba/sentinel-golang/core/flow"
"github.com/douyu/jupiter"
"github.com/douyu/jupiter/example/all/internal/app/greeter"
Expand All @@ -28,9 +27,10 @@ import (
"github.com/douyu/jupiter/pkg/worker/xcron"
"github.com/douyu/jupiter/pkg/xlog"
"github.com/labstack/echo/v4"
sentinel_echo "github.com/sentinel-group/sentinel-go-adapters/echo"
"google.golang.org/grpc/examples/helloworld/helloworld"

sentinel_grpc "github.com/alibaba/sentinel-golang/adapter/grpc"
sentinel_grpc "github.com/sentinel-group/sentinel-go-adapters/grpc"
)

type Engine struct {
Expand Down
7 changes: 0 additions & 7 deletions example/build/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,13 @@ package main

import (
"github.com/douyu/jupiter"
compound_registry "github.com/douyu/jupiter/pkg/registry/compound"
etcdv3_registry "github.com/douyu/jupiter/pkg/registry/etcdv3"
"github.com/douyu/jupiter/pkg/server/xecho"
"github.com/douyu/jupiter/pkg/xlog"
"github.com/labstack/echo/v4"
)

func main() {
eng := NewEngine()
eng.SetRegistry(
compound_registry.New(
etcdv3_registry.StdConfig("test").Build(),
),
)
if err := eng.Run(); err != nil {
xlog.Error(err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion example/client/etcd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func main() {
eng := &jupiter.Application{}
err := eng.Startup(
func() error {
client := etcdv3.StdConfig("myetcd").Build()
client := etcdv3.StdConfig("myetcd").MustBuild()

ctx, cancel := context.WithTimeout(context.Background(), time.Second*2)
defer cancel()
Expand Down
2 changes: 1 addition & 1 deletion example/grpc/direct/direct-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewEngine() *Engine {
}

func (eng *Engine) serveGRPC() error {
server := xgrpc.StdConfig("grpc").Build()
server := xgrpc.StdConfig("grpc").MustBuild()
helloworld.RegisterGreeterServer(server.Server, new(Greeter))
return eng.Serve(server)
}
Expand Down
9 changes: 1 addition & 8 deletions example/grpc/etcd/etcd-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,13 @@ package main
import (
"context"
"github.com/douyu/jupiter"
compound_registry "github.com/douyu/jupiter/pkg/registry/compound"
etcdv3_registry "github.com/douyu/jupiter/pkg/registry/etcdv3"
"github.com/douyu/jupiter/pkg/server/xgrpc"
"github.com/douyu/jupiter/pkg/xlog"
"google.golang.org/grpc/examples/helloworld/helloworld"
)

func main() {
eng := NewEngine()
eng.SetRegistry(
compound_registry.New(
etcdv3_registry.StdConfig("wh").Build(),
),
)
//eng.SetGovernor("0.0.0.0:0")
if err := eng.Run(); err != nil {
xlog.Error(err.Error())
Expand All @@ -52,7 +45,7 @@ func NewEngine() *Engine {
}

func (eng *Engine) serveGRPC() error {
server := xgrpc.StdConfig("grpc").Build()
server := xgrpc.StdConfig("grpc").MustBuild()
helloworld.RegisterGreeterServer(server.Server, &Greeter{
server: server,
})
Expand Down
7 changes: 0 additions & 7 deletions example/http/all/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ package main

import (
"github.com/douyu/jupiter"
compound_registry "github.com/douyu/jupiter/pkg/registry/compound"
etcdv3_registry "github.com/douyu/jupiter/pkg/registry/etcdv3"
"github.com/douyu/jupiter/pkg/server/xecho"
"github.com/douyu/jupiter/pkg/xlog"
"github.com/labstack/echo/v4"
Expand All @@ -26,11 +24,6 @@ import (
func main() {
eng := NewEngine()
// 多注册中心
eng.SetRegistry(
compound_registry.New(
etcdv3_registry.StdConfig("wh").Build(),
),
)

if err := eng.Run(); err != nil {
xlog.Panic(err.Error())
Expand Down
7 changes: 0 additions & 7 deletions example/http/register/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,13 @@ package main

import (
"github.com/douyu/jupiter"
compound_registry "github.com/douyu/jupiter/pkg/registry/compound"
etcdv3_registry "github.com/douyu/jupiter/pkg/registry/etcdv3"
"github.com/douyu/jupiter/pkg/server/xecho"
"github.com/douyu/jupiter/pkg/xlog"
"github.com/labstack/echo/v4"
)

func main() {
eng := NewEngine()
eng.SetRegistry(
compound_registry.New(
etcdv3_registry.StdConfig("wh").Build(),
),
)
if err := eng.Run(); err != nil {
xlog.Panic(err.Error())
}
Expand Down
11 changes: 2 additions & 9 deletions example/monitor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,13 @@ import (

"github.com/douyu/jupiter"
"github.com/douyu/jupiter/pkg/client/etcdv3"
compound_registry "github.com/douyu/jupiter/pkg/registry/compound"
etcdv3_registry "github.com/douyu/jupiter/pkg/registry/etcdv3"
"github.com/douyu/jupiter/pkg/server/xgrpc"
"github.com/douyu/jupiter/pkg/xlog"
"google.golang.org/grpc/examples/helloworld/helloworld"
)

func main() {
eng := NewEngine()
eng.SetRegistry(
compound_registry.New(
etcdv3_registry.StdConfig("wh").Build(),
),
)
if err := eng.Run(); err != nil {
xlog.Error(err.Error())
}
Expand All @@ -49,7 +42,7 @@ func NewEngine() *Engine {
if err := eng.Startup(
eng.serveGRPC,
func() error {
client := etcdv3.StdConfig("myetcd").Build()
client := etcdv3.StdConfig("myetcd").MustBuild()

ctx, cancel := context.WithTimeout(context.Background(), time.Second*2)
defer cancel()
Expand All @@ -67,7 +60,7 @@ func NewEngine() *Engine {
}

func (eng *Engine) serveGRPC() error {
server := xgrpc.StdConfig("grpc").Build()
server := xgrpc.StdConfig("grpc").MustBuild()
helloworld.RegisterGreeterServer(server.Server, new(Greeter))
return eng.Serve(server)
}
Expand Down
2 changes: 1 addition & 1 deletion example/startup/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func startHTTPServer() server.Server {
}

func startGRPCServer() server.Server {
server := xgrpc.DefaultConfig().Build()
server := xgrpc.DefaultConfig().MustBuild()
// helloworld.RegisterGreeterServer(server.Server, new(greeter.Greeter))
return server
}
Expand Down
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ module github.com/douyu/jupiter
go 1.14

require (
cirello.io/pglock v1.8.0 // indirect
github.com/BurntSushi/toml v0.3.1
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/alibaba/sentinel-golang v1.0.2
github.com/alicebob/miniredis/v2 v2.15.1
github.com/apache/rocketmq-client-go/v2 v2.0.0
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0
Expand Down Expand Up @@ -41,6 +43,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.6.0
github.com/robfig/cron/v3 v3.0.1
github.com/sentinel-group/sentinel-go-adapters v1.0.1 // indirect
github.com/sirupsen/logrus v1.7.0 // indirect
github.com/smallnest/weighted v0.0.0-20200122032019-adf21c9b8bd1
github.com/smartystreets/assertions v0.0.0-20190401211740-f487f9de1cd3 // indirect
Expand All @@ -53,9 +56,11 @@ require (
github.com/uber/jaeger-client-go v2.23.1+incompatible
github.com/uber/jaeger-lib v2.2.0+incompatible // indirect
github.com/urfave/cli v1.22.5
go.etcd.io/etcd v3.3.25+incompatible // indirect
go.mongodb.org/mongo-driver v1.5.1
go.uber.org/atomic v1.6.0 // indirect
go.uber.org/automaxprocs v1.3.0
go.uber.org/goleak v1.1.10
go.uber.org/multierr v1.5.0
go.uber.org/zap v1.15.0
golang.org/x/crypto v0.0.0-20201124201722-c8d3bf9c5392 // indirect
Expand Down
22 changes: 22 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cirello.io/pglock v1.8.0 h1:YmXjZ+zE2c6cuRP2efbRDKnk/qu36g0wbshlJetRIzM=
cirello.io/pglock v1.8.0/go.mod h1:iO/b3K4gTIIKO3DhR8t1mYjtjI6tQJhAED2o9oXtP4I=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
Expand Down Expand Up @@ -34,6 +36,7 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802 h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/Jeffail/gabs v1.1.0/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc=
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
Expand Down Expand Up @@ -74,8 +77,13 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4 h1:Hs82Z41s6SdL1C
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alibaba/sentinel-golang v0.6.0 h1:YapgS9Obe8ML7+uiIDPq4BktdGb+5WmTDQEIDPVZhUI=
github.com/alibaba/sentinel-golang v0.6.0/go.mod h1:kxBXAyz2RXPFTjgcfnHKPlMaKb9BQrTbd9Qs02MNHKA=
github.com/alibaba/sentinel-golang v1.0.1/go.mod h1:QsB99f/z35D2AiMrAWwgWE85kDTkBUIkcmPrRt+61NI=
github.com/alibaba/sentinel-golang v1.0.2 h1:Acopq74hOtZN4MV1v811MQ6QcqPFLDSczTrRXv9zpIg=
github.com/alibaba/sentinel-golang v1.0.2/go.mod h1:QsB99f/z35D2AiMrAWwgWE85kDTkBUIkcmPrRt+61NI=
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a h1:HbKu58rmZpUGpz5+4FfNmIU+FmZg2P3Xaj2v2bfNWmk=
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
github.com/alicebob/miniredis/v2 v2.15.1 h1:Fw+ixAJPmKhCLBqDwHlTDqxUxp0xjEwXczEpt1B6r7k=
github.com/alicebob/miniredis/v2 v2.15.1/go.mod h1:gquAfGbzn92jvtrSC69+6zZnwSODVXVpYDRaGhWaL6I=
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190808125512-07798873deee/go.mod h1:myCDvQSzCW+wB1WAlocEru4wMGJxy+vlxHdhegi1CDQ=
github.com/aliyun/alibaba-cloud-sdk-go v1.61.18/go.mod h1:v8ESoHo4SyHmuB4b1tJqDHxfTGEciD+yhvOU/5s1Rfk=
github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
Expand Down Expand Up @@ -119,6 +127,9 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag=
github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
github.com/clbanning/mxj v1.8.5-0.20200714211355-ff02cfb8ea28 h1:LdXxtjzvZYhhUaonAaAKArG3pyC67kGL3YY+6hGG8G4=
Expand Down Expand Up @@ -608,6 +619,7 @@ github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042/go.mod h1:TPp
github.com/lib/pq v0.0.0-20180523175426-90697d60dd84/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU=
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/linode/linodego v0.10.0/go.mod h1:cziNP7pbvE3mXIPneHj0oRY8L1WtGEIKlZ8LANE4eXA=
Expand Down Expand Up @@ -802,6 +814,8 @@ github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/sentinel-group/sentinel-go-adapters v1.0.1 h1:2RcslVCtIuku+MKLnDB5cPWNmPWL8nqIfhXavrjgJPM=
github.com/sentinel-group/sentinel-go-adapters v1.0.1/go.mod h1:hA8nOCLTDnp4Scf3PLDjMe3XoXZ1Anw53iWJnfzqgi0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shirou/gopsutil v0.0.0-20181107111621-48177ef5f880/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil v2.19.12+incompatible h1:WRstheAymn1WOPesh+24+bZKFkqrdCR8JOc77v4xV3Q=
Expand Down Expand Up @@ -933,13 +947,17 @@ github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7Jul
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32 h1:5tjfNdR2ki3yYQ842+eX2sQHeiwpKJ0RnHO4IYOc4V8=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da h1:NimzV1aGyq29m5ukMK0AMWEhFaL/lrEOaephfuoiARg=
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da/go.mod h1:E1AXubJBdNmFERAOucpDIxNzeGfLzg0mYh+UfMWdChA=
github.com/zouyx/agollo v0.0.0-20191114083447-dde9fc9f35b8/go.mod h1:S1cAa98KMFv4Sa8SbJ6ZtvOmf0VlgH0QJ1gXI0lBfBY=
go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.4 h1:hi1bXHMVrlQh6WwxAy+qZCV/SYIlqo+Ushwdpa4tAKg=
go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
go.etcd.io/etcd v3.3.13+incompatible h1:jCejD5EMnlGxFvcGRyEV4VGlENZc7oPQX6o0t7n3xbw=
go.etcd.io/etcd v3.3.13+incompatible/go.mod h1:yaeTdrJi5lOmYerz05bd8+V7KubZs8YSFZfzsF9A6aI=
go.etcd.io/etcd v3.3.25+incompatible h1:V1RzkZJj9LqsJRy+TUBgpWSbZXITLB819lstuTFoZOY=
go.etcd.io/etcd v3.3.25+incompatible/go.mod h1:yaeTdrJi5lOmYerz05bd8+V7KubZs8YSFZfzsF9A6aI=
go.mongodb.org/mongo-driver v1.4.1 h1:38NSAyDPagwnFpUA/D5SFgbugUYR3NzYRNa4Qk9UxKs=
go.mongodb.org/mongo-driver v1.4.1/go.mod h1:llVBH2pkj9HywK0Dtdt6lDikOjFLbceHVu/Rc0iMKLs=
go.mongodb.org/mongo-driver v1.5.1 h1:9nOVLGDfOaZ9R0tBumx/BcuqkbFpyTCU2r/Po7A2azI=
Expand All @@ -956,6 +974,8 @@ go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk=
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/automaxprocs v1.3.0 h1:II28aZoGdaglS5vVNnspf28lnZpXScxtIozx1lAjdb0=
go.uber.org/automaxprocs v1.3.0/go.mod h1:9CWT6lKIep8U41DDaPiH6eFscnTyjfTANNQNx6LrIcA=
go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0=
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A=
Expand Down Expand Up @@ -1087,6 +1107,7 @@ golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -1173,6 +1194,7 @@ golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
Expand Down
9 changes: 9 additions & 0 deletions pkg/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"sync"
"time"

"github.com/douyu/jupiter/pkg/component"
job "github.com/douyu/jupiter/pkg/worker/xjob"

"github.com/BurntSushi/toml"
Expand All @@ -37,6 +38,7 @@ import (
"github.com/douyu/jupiter/pkg/signals"
"github.com/douyu/jupiter/pkg/util/xcolor"
"github.com/douyu/jupiter/pkg/util/xcycle"
"github.com/douyu/jupiter/pkg/util/xdebug"
"github.com/douyu/jupiter/pkg/util/xdefer"
"github.com/douyu/jupiter/pkg/util/xgo"
"github.com/douyu/jupiter/pkg/worker"
Expand Down Expand Up @@ -68,6 +70,7 @@ type Application struct {
disableMap map[Disable]bool
HideBanner bool
stopped chan struct{}
components []component.Component
}

// New create a new Application instance
Expand Down Expand Up @@ -124,6 +127,7 @@ func (app *Application) initialize() {
app.configParser = toml.Unmarshal
app.disableMap = make(map[Disable]bool)
app.stopped = make(chan struct{})
app.components = make([]component.Component, 0)
//private method
app.initHooks(StageBeforeStop, StageAfterStop)

Expand Down Expand Up @@ -225,6 +229,7 @@ func (app *Application) Job(runner job.Runner) error {
}

// SetRegistry set customize registry
// Deprecated, please use registry.DefaultRegisterer instead.
func (app *Application) SetRegistry(reg registry.Registry) {
registry.DefaultRegisterer = reg
}
Expand Down Expand Up @@ -522,6 +527,10 @@ func (app *Application) printBanner() error {
return nil
}

if xdebug.IsTestingMode() {
return nil
}

const banner = `
(_)_ _ _ __ (_) |_ ___ _ __
| | | | | '_ \| | __/ _ \ '__|
Expand Down
Loading

0 comments on commit 2356308

Please sign in to comment.