chore(httpserver): remove name field

This commit is contained in:
Quentin McGaw
2022-03-30 07:41:23 +00:00
parent 19b184adba
commit 8186ef2342
12 changed files with 10 additions and 53 deletions

View File

@@ -8,7 +8,6 @@ import (
)
func boolPtr(b bool) *bool { return &b }
func stringPtr(s string) *string { return &s }
func durationPtr(d time.Duration) *time.Duration { return &d }
var _ gomock.Matcher = (*regexMatcher)(nil)

View File

@@ -26,9 +26,6 @@ func New(settings Settings) (server *httpserver.Server, err error) {
handler.Handle("/debug/pprof/goroutine", pprof.Handler("goroutine"))
handler.Handle("/debug/pprof/heap", pprof.Handler("heap"))
handler.Handle("/debug/pprof/threadcreate", pprof.Handler("threadcreate"))
httpServerName := "pprof"
settings.HTTPServer.Name = &httpServerName
settings.HTTPServer.Handler = handler
settings.SetDefaults()

View File

@@ -22,8 +22,8 @@ func Test_Server(t *testing.T) {
const address = "127.0.0.1:0"
logger := NewMockLogger(ctrl)
logger.EXPECT().Info(newRegexMatcher("^pprof http server listening on 127.0.0.1:[1-9][0-9]{0,4}$"))
logger.EXPECT().Warn("pprof http server shutting down: context canceled")
logger.EXPECT().Info(newRegexMatcher("^http server listening on 127.0.0.1:[1-9][0-9]{0,4}$"))
logger.EXPECT().Warn("http server shutting down: context canceled")
const httpServerShutdownTimeout = 10 * time.Second // 10s in case test worker is slow
settings := Settings{

View File

@@ -26,7 +26,6 @@ type Settings struct {
func (s *Settings) SetDefaults() {
s.Enabled = helpers.DefaultBool(s.Enabled, false)
s.HTTPServer.Name = helpers.DefaultStringPtr(s.HTTPServer.Name, "pprof")
s.HTTPServer.Address = helpers.DefaultString(s.HTTPServer.Address, "localhost:6060")
s.HTTPServer.SetDefaults()
}

View File

@@ -21,7 +21,6 @@ func Test_Settings_SetDefaults(t *testing.T) {
expected: Settings{
Enabled: boolPtr(false),
HTTPServer: httpserver.Settings{
Name: stringPtr("pprof"),
Address: "localhost:6060",
ShutdownTimeout: durationPtr(3 * time.Second),
},
@@ -33,7 +32,6 @@ func Test_Settings_SetDefaults(t *testing.T) {
BlockProfileRate: 1,
MutexProfileRate: 1,
HTTPServer: httpserver.Settings{
Name: stringPtr("custom"),
Address: ":6061",
ShutdownTimeout: durationPtr(time.Second),
},
@@ -43,7 +41,6 @@ func Test_Settings_SetDefaults(t *testing.T) {
BlockProfileRate: 1,
MutexProfileRate: 1,
HTTPServer: httpserver.Settings{
Name: stringPtr("custom"),
Address: ":6061",
ShutdownTimeout: durationPtr(time.Second),
},
@@ -77,7 +74,6 @@ func Test_Settings_Copy(t *testing.T) {
BlockProfileRate: 1,
MutexProfileRate: 1,
HTTPServer: httpserver.Settings{
Name: stringPtr("custom"),
Address: ":6061",
ShutdownTimeout: durationPtr(time.Second),
},
@@ -87,7 +83,6 @@ func Test_Settings_Copy(t *testing.T) {
BlockProfileRate: 1,
MutexProfileRate: 1,
HTTPServer: httpserver.Settings{
Name: stringPtr("custom"),
Address: ":6061",
ShutdownTimeout: durationPtr(time.Second),
},
@@ -325,7 +320,6 @@ func Test_Settings_String(t *testing.T) {
BlockProfileRate: 2,
MutexProfileRate: 1,
HTTPServer: httpserver.Settings{
Name: stringPtr("name"),
Address: ":8000",
ShutdownTimeout: durationPtr(time.Second),
},
@@ -333,7 +327,7 @@ func Test_Settings_String(t *testing.T) {
s: `Pprof settings:
├── Block profile rate: 2
├── Mutex profile rate: 1
└── Name HTTP server settings:
└── HTTP server settings:
├── Listening address: :8000
└── Shutdown timeout: 1s`,
},