gsf

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: MulanPSL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Env
	EnvLocal = 0 // 本地
	EnvDebug = 1 // 测试
	EnvPrev  = 2 // 预发布
	EnvProd  = 3 // 线上

	CliAppEnv     = "app-env"
	CliAppVer     = "app-version"
	CliAppLogMore = "app-log-more"
)
View Source
const (
	CliAppCmd    = "path"
	CliAppCmdArg = "args"
)
View Source
const (
	CliWebIP   = "web-ip"
	CliWebPort = "web-port"
)

Variables

View Source
var (
	AppCmdNoFind = errors.New(" Command No Find")
)
View Source
var (
	EnvVersion = "1.0.0"
)

Functions

This section is empty.

Types

type AppConfig

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

func (*AppConfig) Env

func (v *AppConfig) Env() int

func (*AppConfig) EnvDesc

func (v *AppConfig) EnvDesc() string

func (*AppConfig) ExecDir

func (v *AppConfig) ExecDir() string

func (*AppConfig) LogMore

func (v *AppConfig) LogMore() bool

func (*AppConfig) SetEnv

func (v *AppConfig) SetEnv(e int) bool

func (*AppConfig) Version

func (v *AppConfig) Version() string

type Application

type Application struct {
	Component map[string]Component
	Log       logger.Interface
	Cfg       AppConfig
	Ser       Service
}

func (*Application) Start

func (app *Application) Start(cmd *cli.App, args []string, service Service)

type BasicService

type BasicService struct {
	RunBefore, InitBefore func() error
}

func (*BasicService) Init

func (c *BasicService) Init(runMode string, cfg *AppConfig, ctx *cli.Context) (logger.Interface, error)

func (*BasicService) ParserFile

func (c *BasicService) ParserFile(cfg interface{}) error

type CmdArg

type CmdArg struct {
	Name, Default string
}

type CmdHandle

type CmdHandle interface {
	Flags() []CmdArg
	Run(map[string]string) error
}

type CmdService

type CmdService struct {
	BasicService
	Cfg struct {
		RunMode string `yaml:"runmode"` // 服务运行模式
	}

	Router map[string]CmdHandle
	// contains filtered or unexported fields
}

func (*CmdService) AddCmdHandle

func (c *CmdService) AddCmdHandle(name string, handle CmdHandle) *CmdService

func (*CmdService) CliFlags

func (c *CmdService) CliFlags() []cli.Flag

func (*CmdService) Close

func (c *CmdService) Close()

func (*CmdService) Init

func (c *CmdService) Init(cfg *AppConfig, ctx *cli.Context) (logger.Interface, error)

func (*CmdService) Run

func (c *CmdService) Run(l logger.Interface, _ *AppConfig) error

type Component

type Component interface {
	CliFlags() []cli.Flag
	Init(logger.Interface, *AppConfig, *cli.Context) error
	Run() error
	Close() error
}

type Service

type Service interface {
	CliFlags() []cli.Flag
	Init(*AppConfig, *cli.Context) (logger.Interface, error)
	Run(logger.Interface, *AppConfig) error
	Close()
}

type WebService added in v0.2.6

type WebService struct {
	BasicService
	Cfg struct {
		IP      string `yaml:"ip"`      // 监听端口
		Port    int    `yaml:"listen"`  // 监听端口
		RunMode string `yaml:"runmode"` // 服务运行模式
	}
	Handler http.Handler
}

func (*WebService) CliFlags added in v0.2.6

func (c *WebService) CliFlags() []cli.Flag

func (*WebService) Close added in v0.2.6

func (c *WebService) Close()

func (*WebService) Init added in v0.2.6

func (c *WebService) Init(cfg *AppConfig, ctx *cli.Context) (logger.Interface, error)

func (*WebService) Run added in v0.2.6

func (c *WebService) Run(log logger.Interface, cfg *AppConfig) error

Jump to

Keyboard shortcuts

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