Documentation ¶
Overview ¶
Package admin provides management capabilities for trpc services, including but not limited to health checks, logging, performance monitoring, RPCZ, etc.
Index ¶
- Constants
- func ErrorOutput(w http.ResponseWriter, error string, code int)
- func HandleFunc(pattern string, handler http.HandlerFunc)
- type Option
- func WithAddr(addr string) Option
- func WithConfigPath(configPath string) Option
- func WithReadTimeout(readTimeout time.Duration) Option
- func WithSkipServe(isSkip bool) Option
- func WithTLS(isTLS bool) Option
- func WithVersion(version string) Option
- func WithWriteTimeout(writeTimeout time.Duration) Option
- type Server
- func (s *Server) Close(ch chan struct{}) error
- func (s *Server) HandleFunc(pattern string, handler http.HandlerFunc)
- func (s *Server) Register(serviceDesc interface{}, serviceImpl interface{}) error
- func (s *Server) RegisterHealthCheck(serviceName string) (unregister func(), update func(healthcheck.Status), err error)
- func (s *Server) Serve() error
- func (s *Server) WatchStatus(serviceName string, onStatusChanged func(healthcheck.Status))
Constants ¶
const ServiceName = "admin"
ServiceName is the service name of admin service.
Variables ¶
This section is empty.
Functions ¶
func ErrorOutput ¶
func ErrorOutput(w http.ResponseWriter, error string, code int)
ErrorOutput normalizes the error output.
func HandleFunc ¶
func HandleFunc(pattern string, handler http.HandlerFunc)
HandleFunc registers the handler function for the given pattern. Each time NewServer is called, all handlers registered through HandleFunc will be in effect. Therefore, please prioritize using Server.HandleFunc.
Types ¶
type Option ¶
type Option func(*configuration)
Option Service configuration options.
func WithAddr ¶
WithAddr returns an Option which sets the address bound to admin, default: ":9028". Supported formats: 1. :80 2. 0.0.0.0:80 3. localhost:80 4. 127.0.0.0:8001
func WithConfigPath ¶
WithConfigPath returns an Option which sets the framework configuration file path.
func WithReadTimeout ¶
WithReadTimeout returns an Option which sets read timeout.
func WithSkipServe ¶
WithSkipServe sets whether to skip starting the admin service.
func WithVersion ¶
WithVersion returns an Option which sets the version number.
func WithWriteTimeout ¶
WithWriteTimeout returns an Option which sets write timeout.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server structure provides utilities related to administration. It implements the server.Service interface.
func (*Server) HandleFunc ¶
func (s *Server) HandleFunc(pattern string, handler http.HandlerFunc)
HandleFunc registers the handler function for the given pattern.
func (*Server) RegisterHealthCheck ¶
func (s *Server) RegisterHealthCheck( serviceName string, ) (unregister func(), update func(healthcheck.Status), err error)
RegisterHealthCheck registers a new service and returns two functions, one for unregistering the service and one for updating the status of the service.
func (*Server) WatchStatus ¶
func (s *Server) WatchStatus(serviceName string, onStatusChanged func(healthcheck.Status))
WatchStatus HealthCheck proxy, registers health status watcher for service.