Pull request 1935: upd-pprof
Squashed commit of the following: commit 71d8936bddcf2d2b293015d3091df72aa1333270 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Jul 20 18:48:08 2023 +0300 next/websvc: fix pprof disabling commit 30cc75d1eb89f7422555c18ad474324ab55eb13b Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Jul 20 18:30:29 2023 +0300 all: upd golibs; add pprof to next
This commit is contained in:
@@ -17,8 +17,6 @@ type config struct {
|
||||
Log *logConfig `yaml:"log"`
|
||||
// TODO(a.garipov): Use.
|
||||
SchemaVersion int `yaml:"schema_version"`
|
||||
// TODO(a.garipov): Use.
|
||||
DebugPprof bool `yaml:"debug_pprof"`
|
||||
}
|
||||
|
||||
const errNoConf errors.Error = "configuration not found"
|
||||
@@ -84,6 +82,8 @@ func (c *dnsConfig) validate() (err error) {
|
||||
|
||||
// httpConfig is the on-disk web API configuration.
|
||||
type httpConfig struct {
|
||||
Pprof *httpPprofConfig `yaml:"pprof"`
|
||||
|
||||
// TODO(a.garipov): Document the configuration change.
|
||||
Addresses []netip.AddrPort `yaml:"addresses"`
|
||||
SecureAddresses []netip.AddrPort `yaml:"secure_addresses"`
|
||||
@@ -101,10 +101,25 @@ func (c *httpConfig) validate() (err error) {
|
||||
case c.Timeout.Duration <= 0:
|
||||
return newMustBePositiveError("timeout", c.Timeout)
|
||||
default:
|
||||
return nil
|
||||
return c.Pprof.validate()
|
||||
}
|
||||
}
|
||||
|
||||
// httpPprofConfig is the on-disk pprof configuration.
|
||||
type httpPprofConfig struct {
|
||||
Port uint16 `yaml:"port"`
|
||||
Enabled bool `yaml:"enabled"`
|
||||
}
|
||||
|
||||
// validate returns an error if the pprof configuration structure is invalid.
|
||||
func (c *httpPprofConfig) validate() (err error) {
|
||||
if c == nil {
|
||||
return errNoConf
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// logConfig is the on-disk web API configuration.
|
||||
type logConfig struct {
|
||||
// TODO(a.garipov): Use.
|
||||
|
||||
@@ -151,6 +151,10 @@ func (m *Manager) assemble(
|
||||
}
|
||||
|
||||
webSvcConf := &websvc.Config{
|
||||
Pprof: &websvc.PprofConfig{
|
||||
Port: conf.HTTP.Pprof.Port,
|
||||
Enabled: conf.HTTP.Pprof.Enabled,
|
||||
},
|
||||
ConfigManager: m,
|
||||
Frontend: frontend,
|
||||
// TODO(a.garipov): Fill from config file.
|
||||
@@ -259,9 +263,6 @@ func (m *Manager) UpdateWeb(ctx context.Context, c *websvc.Config) (err error) {
|
||||
m.updMu.Lock()
|
||||
defer m.updMu.Unlock()
|
||||
|
||||
// TODO(a.garipov): Update and write the configuration file. Return an
|
||||
// error if something went wrong.
|
||||
|
||||
err = m.updateWeb(ctx, c)
|
||||
if err != nil {
|
||||
return fmt.Errorf("reassembling websvc: %w", err)
|
||||
@@ -291,6 +292,8 @@ func (m *Manager) updateWeb(ctx context.Context, c *websvc.Config) (err error) {
|
||||
|
||||
// updateCurrentWeb updates the web configuration in the current config.
|
||||
func (m *Manager) updateCurrentWeb(c *websvc.Config) {
|
||||
// TODO(a.garipov): Update pprof from API?
|
||||
|
||||
m.current.HTTP.Addresses = slices.Clone(c.Addresses)
|
||||
m.current.HTTP.SecureAddresses = slices.Clone(c.SecureAddresses)
|
||||
m.current.HTTP.Timeout = timeutil.Duration{Duration: c.Timeout}
|
||||
|
||||
Reference in New Issue
Block a user