Documentation ¶
Index ¶
- type Checker
- type Closer
- type DebugServer
- func (d *DebugServer) AddChecker(checker Checker)
- func (d *DebugServer) AddCheckers(checkers []Checker)
- func (d *DebugServer) LiveProbeHandler(w http.ResponseWriter, _ *http.Request)
- func (d *DebugServer) ReadinessProbeHandler(w http.ResponseWriter, req *http.Request)
- func (d *DebugServer) RunDebug() error
- func (d *DebugServer) SetReady(ready bool)
- func (d *DebugServer) ShutdownDebug(ctx context.Context) error
- func (d *DebugServer) StartupProbeHandler(w http.ResponseWriter, _ *http.Request)
- type DefaultChecker
- type DefaultCloser
- type ErrorCloser
- type Server
- type ServerOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DebugServer ¶
type DebugServer struct { PORT string `json:"port" envconfig:"PORT" default:":8084"` // contains filtered or unexported fields }
func NewDebugServer ¶
func NewDebugServer(port string) *DebugServer
NewDebugServer create new debug server
port is debug port use value with `:` for example: :8084
func (*DebugServer) AddChecker ¶
func (d *DebugServer) AddChecker(checker Checker)
func (*DebugServer) AddCheckers ¶
func (d *DebugServer) AddCheckers(checkers []Checker)
AddCheckers for check your server is live
func (*DebugServer) LiveProbeHandler ¶ added in v0.2.0
func (d *DebugServer) LiveProbeHandler(w http.ResponseWriter, _ *http.Request)
LiveProbeHandler is probe checker for k8s liveness probe
func (*DebugServer) ReadinessProbeHandler ¶ added in v0.2.0
func (d *DebugServer) ReadinessProbeHandler(w http.ResponseWriter, req *http.Request)
ReadinessProbeHandler is probe checker for k8s readiness probe
It will check all checkersGroup and return 200 if all checkersGroup is ok or 500 if one of them is not ok
response will be json with all checkersGroup and their status
func (*DebugServer) RunDebug ¶
func (d *DebugServer) RunDebug() error
func (*DebugServer) SetReady ¶
func (d *DebugServer) SetReady(ready bool)
SetReady set server ready
warning use this method only when you sure that server is ready
func (*DebugServer) ShutdownDebug ¶
func (d *DebugServer) ShutdownDebug(ctx context.Context) error
func (*DebugServer) StartupProbeHandler ¶ added in v0.2.0
func (d *DebugServer) StartupProbeHandler(w http.ResponseWriter, _ *http.Request)
StartupProbeHandler is probe checker for k8s startup probe ready or not ready used only for start
type DefaultChecker ¶
type DefaultChecker struct { CheckFunc func(ctx context.Context) error `json:"check"` NameCheck string `json:"name"` }
DefaultChecker is a default implementation of Checker if you want simple checker without implementation Checker interface tou can call this function and receive Checker interface
func NewDefaultChecker ¶
func NewDefaultChecker(name string, checkFunc func(ctx context.Context) error) *DefaultChecker
func (*DefaultChecker) GetName ¶ added in v0.2.0
func (c *DefaultChecker) GetName() string
type DefaultCloser ¶
type DefaultCloser struct { Name string `json:"name"` CloseFunc func(ctx context.Context) error `json:"close"` }
DefaultCloser is a default implementation of Closer if you want simple checker without implementation Closer interface tou can call this function and receive Closer interface
func (*DefaultCloser) GetName ¶
func (d *DefaultCloser) GetName() string
type ErrorCloser ¶ added in v0.2.0
type ErrorCloser struct {
// contains filtered or unexported fields
}
func (*ErrorCloser) Error ¶ added in v0.2.0
func (e *ErrorCloser) Error() string
type Server ¶
type Server struct { *DebugServer // contains filtered or unexported fields }
Server is app engine with debug server
Use AddCloser to add closer objects for shutdown your application gracefully(for more information see AddCloser)
Use AddActor to add actor control you background task(for more information see AddActor)
Use AddChecker to add checker for live probe(for more information see AddChecker)
You can change config engine use ENV variables DEBUG_PORT and SHUTDOWN_TIMEOUT(for example 30s)
func NewServer ¶
NewServer create new server
You can change config engine use ENV variables DEBUG_PORT and SHUTDOWN_TIMEOUT(for example 30s) or use With function
func (*Server) AddActor ¶
AddActor add actor control you background task
you have executed function and done function(interrupt function) interrupt function handle the error execute function is called when server is ready
func (*Server) AddCloser ¶
AddCloser add closer object for shutdown your application gracefully you need to handle the context and call wg.Done() when done
func (*Server) AddClosers ¶
type ServerOpt ¶
type ServerOpt func(*Server)
func WithDebugPort ¶
WithDebugPort set debug port use value with `:` for example: :8084
func WithDisableBanner ¶
func WithDisableBanner() ServerOpt
WithDisableBanner disable witcher Banner
func WithGRPCServer ¶ added in v0.0.5
func WithShutdownTimeout ¶
WithShutdownTimeout set shutdown timeout
is duration for graceful shutdown