[#44] Expose metrics

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-08-11 17:07:53 +03:00 committed by Kirillov Denis
parent 8221ec317c
commit c397efb1c2
13 changed files with 426 additions and 33 deletions

View file

@ -58,6 +58,8 @@ type ServerConfig struct {
TLSCertificate string
TLSCertificateKey string
TLSCACertificate string
SuccessfulStartCallback func()
}
// NewServer creates a new api neofs rest gw server but does not configure it
@ -85,6 +87,7 @@ func NewServer(api *operations.NeofsRestGwAPI, cfg *ServerConfig) *Server {
s.TLSWriteTimeout = cfg.TLSWriteTimeout
s.shutdown = make(chan struct{})
s.api = api
s.startCallback = cfg.SuccessfulStartCallback
s.interrupt = make(chan os.Signal, 1)
return s
}
@ -120,6 +123,8 @@ type Server struct {
TLSWriteTimeout time.Duration
httpsServerL net.Listener
startCallback func()
cfgTLSFn func(tlsConfig *tls.Config)
cfgServerFn func(s *http.Server, scheme, addr string)
@ -322,6 +327,10 @@ func (s *Server) Serve() (err error) {
wg.Add(1)
go s.handleShutdown(wg, &servers)
if s.startCallback != nil {
s.startCallback()
}
wg.Wait()
return nil
}