Documentation
¶
Index ¶
- type Server
- func (s *Server) Addr() string
- func (s *Server) GracefulShutdownHandler() error
- func (s *Server) GracefulStop() error
- func (s *Server) HTTPServer() *http.Server
- func (s *Server) IsHTTPS() bool
- func (s *Server) PreStartCallback() func() error
- func (s *Server) Serve() error
- func (s *Server) TracerProviderShutdownHandler() error
- func (s *Server) Type() string
- type ServerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps up *HTTP.Server.
func NewServer ¶
func NewServer(c *ServerConfig, logger *logger.Logger, preStartCallback func() error, router http.Handler) (*Server, error)
NewServer initialises a http server.
func (*Server) GracefulShutdownHandler ¶
GracefulShutdownHandler is a function that runs before the HTTP server is gracefully shut down.
func (*Server) GracefulStop ¶
GracefulStop stops the HTTP server gracefully. It stops the server from accepting new connections and blocks until all the pending requests are finished.
func (*Server) HTTPServer ¶
HTTPServer returns the internal HTTP server instance.
func (*Server) PreStartCallback ¶
PreStartCallback is the callback function to trigger right before the server starts running.
func (*Server) Serve ¶
Serve accepts incoming connections on the listener lis, creating a new ServerTransport and service goroutine for each. The service goroutines read HTTP requests and then call the registered handlers to reply to them. Serve returns when lis.Accept fails with fatal errors. lis will be closed when this method returns. Serve will return a non-nil error unless Stop or GracefulStop is called.
func (*Server) TracerProviderShutdownHandler ¶
TracerProviderShutdownHandler is a function that shuts down the tracer's exporter/provider before the HTTP server is gracefully shut down.
type ServerConfig ¶
type ServerConfig struct { // Name of the server Name string // Address is the TCP address to listen on. Address string // GracefulShutdownHandler is a function that runs before the HTTP server is gracefully shut down. GracefulShutdownHandler func() error // KeepAlive indicates how the HTTP server should configure the connection's keep alive. KeepAlive struct { // EnforcementPolicy is used to set keepalive enforcement policy on the server-side. Server // will close connection with a client that violates this policy. EnforcementPolicy struct { // MinTime is the minimum amount of time a client should wait before sending a keepalive // ping. By default, it is 5 * time.Second. MinTime time.Duration // If true, server allows keepalive pings even when there are no active streams(RPCs). If // false, and client sends ping when there are no active streams, server will send GOAWAY // and close the connection. By default, it is false. PermitWithoutStream bool } // ServerParameters is used to set keepalive and max-age parameters on the server-side. ServerParameters struct { ReadTimeout time.Duration ReadHeaderTimeout time.Duration WriteTimeout time.Duration IdleTimeout time.Duration MaxHeaderBytes int } } // TracerProvider is the provider that uses the exporter to push traces to the collector. TracerProvider *tracer.Provider // TracerProviderShutdownHandler is a function that shuts down the tracer's exporter/provider before // the HTTP server is gracefully shut down. TracerProviderShutdownHandler func() error TLSConfig *tls.Config }
ServerConfig indicates how a HTTP server should be initialised.