From 423597a01c17bfc6670f04f17f77eb0278a3b007 Mon Sep 17 00:00:00 2001 From: kesonan Date: Tue, 17 Oct 2023 23:38:21 +0800 Subject: [PATCH] feat: export devserver.Config (#3638) --- core/service/serviceconf.go | 27 ++++++++++++++++----------- core/service/serviceconf_test.go | 5 +++++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/core/service/serviceconf.go b/core/service/serviceconf.go index 04d9283e..a4999ab8 100644 --- a/core/service/serviceconf.go +++ b/core/service/serviceconf.go @@ -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() { diff --git a/core/service/serviceconf_test.go b/core/service/serviceconf_test.go index badf249f..5e37421d 100644 --- a/core/service/serviceconf_test.go +++ b/core/service/serviceconf_test.go @@ -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) { @@ -14,6 +15,10 @@ func TestServiceConf(t *testing.T) { Mode: "console", }, Mode: "dev", + DevServer: devserver.Config{ + Port: 6470, + HealthPath: "/healthz", + }, } c.MustSetUp() }