engine

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllocsHandler added in v0.0.3

func AllocsHandler() echo.HandlerFunc

AllocsHandler will pass the call from /debug/pprof/allocs to pprof.

func BlockHandler added in v0.0.3

func BlockHandler() echo.HandlerFunc

BlockHandler will pass the call from /debug/pprof/block to pprof.

func CmdlineHandler added in v0.0.3

func CmdlineHandler() echo.HandlerFunc

CmdlineHandler will pass the call from /debug/pprof/cmdline to pprof.

func GoroutineHandler added in v0.0.3

func GoroutineHandler() echo.HandlerFunc

GoroutineHandler will pass the call from /debug/pprof/goroutine to pprof.

func HeapHandler added in v0.0.3

func HeapHandler() echo.HandlerFunc

HeapHandler will pass the call from /debug/pprof/heap to pprof.

func IndexHandler added in v0.0.3

func IndexHandler() echo.HandlerFunc

IndexHandler will pass the call from /debug/pprof to pprof.

func MutexHandler added in v0.0.3

func MutexHandler() echo.HandlerFunc

MutexHandler will pass the call from /debug/pprof/mutex to pprof.

func ProfileHandler added in v0.0.3

func ProfileHandler() echo.HandlerFunc

ProfileHandler will pass the call from /debug/pprof/profile to pprof.

func SymbolHandler added in v0.0.3

func SymbolHandler() echo.HandlerFunc

SymbolHandler will pass the call from /debug/pprof/symbol to pprof.

func ThreadCreateHandler added in v0.0.3

func ThreadCreateHandler() echo.HandlerFunc

ThreadCreateHandler will pass the call from /debug/pprof/threadcreate to pprof.

func TraceHandler added in v0.0.3

func TraceHandler() echo.HandlerFunc

TraceHandler will pass the call from /debug/pprof/trace to pprof.

Types

type Checker

type Checker interface {
	Check() error
	Name() string
}

type Closer

type Closer interface {
	GetName() string

	Close(ctx context.Context, wg *sync.WaitGroup) error
}

func NewDefaultCloser

func NewDefaultCloser(name string, close func(ctx context.Context, group *sync.WaitGroup) error) Closer

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

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) Live

func (d *DebugServer) Live(c echo.Context) error

Live is probe checker

func (*DebugServer) Ready

func (d *DebugServer) Ready(c echo.Context) error

Ready is probe checker

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

type DefaultChecker

type DefaultChecker struct {
	CheckFunc func() 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() error) *DefaultChecker

func (*DefaultChecker) Check

func (c *DefaultChecker) Check() error

func (*DefaultChecker) Name

func (c *DefaultChecker) Name() string

type DefaultCloser

type DefaultCloser struct {
	Name      string                                              `json:"name"`
	CloseFunc func(ctx context.Context, wg *sync.WaitGroup) 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) Close

func (d *DefaultCloser) Close(ctx context.Context, wg *sync.WaitGroup) error

func (*DefaultCloser) GetName

func (d *DefaultCloser) GetName() 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

func NewServer(opt ...ServerOpt) *Server

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

func (s *Server) AddActor(execute func() error, interrupt func(err error))

AddActor add actor control you background task you have execute function and done function(interrupt function) interrupt function handle the error execute function is called when server is ready

func (*Server) AddCloser

func (s *Server) AddCloser(closer Closer)

AddCloser add closer object for shutdown your application gracefully you need to handle the context and call wg.Done() when done

func (*Server) AddClosers

func (s *Server) AddClosers(closers []Closer)

func (*Server) GetCTX

func (s *Server) GetCTX() context.Context

GetCTX return context of your engine

func (*Server) Run

func (s *Server) Run() error

Run start your server

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown server

Timeout is duration for graceful shutdown If all goroutines are finished, server will be shutdown or timeout will be reached, server will be shutdown force

type ServerOpt

type ServerOpt func(*Server)

func WithDebugPort

func WithDebugPort(port string) ServerOpt

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 WithGRPCServer(grpcServer *grpc.Server, port string, shutdownTimeout time.Duration) ServerOpt

func WithShutdownTimeout

func WithShutdownTimeout(timeout time.Duration) ServerOpt

WithShutdownTimeout set shutdown timeout

timeout is duration for graceful shutdown

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL