apiserver

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2022 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RunModeDebug      = "debug"
	RunModeTest       = "test"
	RunModeDev        = "dev"
	RunModeProd       = "prod"
	RunModeProduction = "production"
	RunModeRelease    = "release"
)

Variables

This section is empty.

Functions

func AddShutdownListener

func AddShutdownListener(fn func()) (waitForCalled func())

AddShutdownListener adds fn as a shutdown listener. The returned func can be used to wait for fn getting called.

func AddWrapUpListener

func AddWrapUpListener(fn func()) (waitForCalled func())

AddWrapUpListener adds fn as a wrap up listener. The returned func can be used to wait for fn getting called.

func NewConfigEnvCommand

func NewConfigEnvCommand(c interface{}) *cobra.Command

func StartHTTP

func StartHTTP(host string, port int, handler http.Handler, opts ...StartOption) error

StartHTTP starts a http server.

func StartHTTPS

func StartHTTPS(conf APIConfig, handler http.Handler, opts ...StartOption) error

StartHTTPS starts a https server.

Types

type APIConfig

type APIConfig struct {
	App    AppConfig         `yaml:"app"`
	Log    logger.Config     `yaml:"log"`
	MySQL  gormdb.DBConfig   `yaml:"mysql"`
	Redis  rediscache.Config `yaml:"redis"`
	Kafka  kafka.Config      `yaml:"kafka"`
	Tracer tracer.Config     `yaml:"tracer"`
}

func (*APIConfig) String

func (c *APIConfig) String() string

type AppConfig

type AppConfig struct {
	ServiceName string `yaml:"service_name" env-default:"gin-project" env-description:"the name of the service"`
	HostIP      string `yaml:"local_ip" env:"HostIP" env-default:"0.0.0.0" env-description:"listening on which IP"`
	APIPort     int    `yaml:"api_port" env:"APIPort" env-default:"8000" env-description:"listening on which port"`
	AdminPort   int    `yaml:"admin_port" env:"AdminPort" env-default:"8001" env-description:"listening on which port of admin service"`
	RunMode     string `yaml:"run_mode" env:"RunMode" env-description:"run mode of the service"`
	CertFile    string `yaml:"cert_file" env:"CertFile" env-description:"cert file if server need to use tls"`
	KeyFile     string `yaml:"key_file" env:"KeyFile" env-description:"key file if server need to use tls"`
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func CreateNewServer

func CreateNewServer(ctx context.Context, c APIConfig, opts ...ServerOption) *Server

CreateNewServer create a new server with gin

func (*Server) AddGinGroup

func (s *Server) AddGinGroup(group string) *gin.RouterGroup

func (*Server) GetTracer

func (s *Server) GetTracer() opentracing.Tracer

func (*Server) Start

func (s *Server) Start()

func (*Server) StartAdminOnly

func (s *Server) StartAdminOnly()

func (*Server) Stop

func (s *Server) Stop()

type ServerOption

type ServerOption func(*serverOptions)

func Migration

func Migration(tables []interface{}) ServerOption

func RawColumn added in v0.1.0

func RawColumn(raw bool) ServerOption

type StartOption

type StartOption func(srv *http.Server)

StartOption defines the method to customize http.Server.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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