server

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version    = "v1.1.0"
	ApiModule  = "crony/api-server"
	NodeModule = "crony/node-server"
)

Variables

View Source
var (
	ApiOptions struct {
		flags.Options
		Environment       string `short:"e" long:"env" description:"Use ApiServer environment" default:"testing"`
		Version           bool   `short:"v" long:"verbose"  description:"Show ApiServer version"`
		EnablePProfile    bool   `short:"p" long:"enable-pprof"  description:"enable pprof"`
		PProfilePort      int    `short:"d" long:"pprof-port"  description:"pprof port" default:"8188"`
		EnableHealthCheck bool   `short:"a" long:"enable-health-check"  description:"enable health check"`
		HealthCheckURI    string `short:"i" long:"health-check-uri"  description:"health check uri" default:"/health" `
		HealthCheckPort   int    `short:"f" long:"health-check-port"  description:"health check port" default:"8186"`
		ConfigFileName    string `short:"c" long:"config" description:"Use ApiServer config file" default:"main"`
		EnableDevMode     bool   `short:"m" long:"enable-dev-mode"  description:"enable dev mode"`
	}
)
View Source
var (
	NodeOptions struct {
		flags.Options
		Environment    string `short:"e" long:"env" description:"Use nodeServer environment" default:"testing"`
		Version        bool   `short:"v" long:"verbose"  description:"Show nodeServer version"`
		EnablePProfile bool   `short:"p" long:"enable-pprof"  description:"enable pprof"`
		PProfilePort   int    `short:"d" long:"pprof-port"  description:"pprof port" default:"8188"`
		ConfigFileName string `short:"c" long:"config" description:"Use nodeServer config file" default:"main"`
		EnableDevMode  bool   `short:"m" long:"enable-dev-mode"  description:"enable dev mode"`
	}
)

Functions

func InitNodeServer

func InitNodeServer(serverName string, inits ...func()) (*models.Config, error)

Types

type ApiServer

type ApiServer struct {
	Engine     *gin.Engine
	HttpServer *http.Server
	Addr       string

	Routers     []func(*gin.Engine)
	Middlewares []func(*gin.Engine)
	Shutdowns   []func(*ApiServer)
	Services    []func(*ApiServer)
	// contains filtered or unexported fields
}

func NewApiServer

func NewApiServer(serverName string, inits ...func()) (*ApiServer, error)

func (*ApiServer) ListenAndServe

func (srv *ApiServer) ListenAndServe() error

ListenAndServe Listen And Serve()

func (*ApiServer) RegisterMiddleware

func (srv *ApiServer) RegisterMiddleware(middlewares ...func(engine *gin.Engine))

Register Middleware Middleware

func (*ApiServer) RegisterRouters

func (srv *ApiServer) RegisterRouters(routers ...func(engine *gin.Engine)) *ApiServer

RegisterRouters

func (*ApiServer) RegisterService

func (srv *ApiServer) RegisterService(handlers ...func(*ApiServer))

Register Service Handler

func (*ApiServer) RegisterShutdown

func (srv *ApiServer) RegisterShutdown(handlers ...func(*ApiServer))

Register Shutdown Handler

func (*ApiServer) Shutdown

func (srv *ApiServer) Shutdown(ctx context.Context)

Jump to

Keyboard shortcuts

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