Skip to content

Commit

Permalink
feat: export devserver.Config (#3638)
Browse files Browse the repository at this point in the history
  • Loading branch information
kesonan authored Oct 17, 2023
1 parent d84dfe1 commit 423597a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
27 changes: 16 additions & 11 deletions core/service/serviceconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,22 @@ const (
ProMode = "pro"
)

// A ServiceConf is a service config.
type ServiceConf struct {
Name string
Log logx.LogConf
Mode string `json:",default=pro,options=dev|test|rt|pre|pro"`
MetricsUrl string `json:",optional"`
// Deprecated: please use DevServer
Prometheus prometheus.Config `json:",optional"`
Telemetry trace.Config `json:",optional"`
DevServer devserver.Config `json:",optional"`
}
type (
// DevServerConfig is type alias for devserver.Config
DevServerConfig = devserver.Config

// A ServiceConf is a service config.
ServiceConf struct {
Name string
Log logx.LogConf
Mode string `json:",default=pro,options=dev|test|rt|pre|pro"`
MetricsUrl string `json:",optional"`
// Deprecated: please use DevServer
Prometheus prometheus.Config `json:",optional"`
Telemetry trace.Config `json:",optional"`
DevServer DevServerConfig `json:",optional"`
}
)

// MustSetUp sets up the service, exits on error.
func (sc ServiceConf) MustSetUp() {
Expand Down
5 changes: 5 additions & 0 deletions core/service/serviceconf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/internal/devserver"
)

func TestServiceConf(t *testing.T) {
Expand All @@ -14,6 +15,10 @@ func TestServiceConf(t *testing.T) {
Mode: "console",
},
Mode: "dev",
DevServer: devserver.Config{
Port: 6470,
HealthPath: "/healthz",
},
}
c.MustSetUp()
}
Expand Down

0 comments on commit 423597a

Please sign in to comment.