server

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: Apache-2.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLogLevel      = errors.New("log level is illegal")
	ErrLogPrefix     = errors.New("log prefix is nil")
	ErrLogDir        = errors.New("log dir is nil")
	ErrServerNameNil = errors.New("server name is nil")
	ErrConfigNil     = errors.New("config nil")
	ErrRedisNameNil  = errors.New("redis name is nil")
	ErrMysqlNameNil  = errors.New("mysql name is nil")
	ErrMysqlIpNil    = errors.New("mysql ip is nil")
)

Functions

This section is empty.

Types

type DefaultServer

type DefaultServer struct {
	Typ ServerTyp
	// contains filtered or unexported fields
}

func NewDefaultServer

func NewDefaultServer(ctx context.Context, typ ServerTyp, configPath string) (*DefaultServer, error)

func (*DefaultServer) AfterInit

func (d *DefaultServer) AfterInit(serverFunc ...ServerFunc)

func (*DefaultServer) BeforeInit

func (d *DefaultServer) BeforeInit(serverFunc ...ServerFunc)

func (*DefaultServer) GetConfig

func (d *DefaultServer) GetConfig() config.ConfigParser

func (*DefaultServer) Run

func (d *DefaultServer) Run(ctx context.Context, cancel context.CancelFunc) error

type Server

type Server interface {
	// Execute after Run function.
	// AfterInit is only suitable for initialization functions,
	// not suitable executing complex logic.
	AfterInit(serverFunc ...ServerFunc)

	// Execute before Run function.
	// The framework may still load some necessary functions
	// before Run executes(like logger, service register).
	// BeforeInit is only suitable for initialization functions,
	// not suitable for executing complex logic.
	BeforeInit(serverFunc ...ServerFunc)

	// run frame
	// The function will block until an error is
	// reported in the process.
	Run(ctx context.Context, cancel context.CancelFunc) error

	GetConfig() config.ConfigParser
}

func NewServer

func NewServer(ctx context.Context, typ ServerTyp, configPath string) (Server, error)

type ServerFunc

type ServerFunc func(ctx context.Context, config config.ConfigParser)

type ServerTyp

type ServerTyp string
const (
	NULL_TYPE    ServerTyp = ""
	DEFAULT_TYPE ServerTyp = "default"
)

Jump to

Keyboard shortcuts

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