gsf

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: Apache-2.0 Imports: 13 Imported by: 5

README

gsf-core

web config json

{
  "ip" : "0.0.0.0",
  "port" : 9902,
  "timeout": {
    "read" : 5,
    "write" : 5,
    "idle" : 10
  }
}

命令行参数

--app-env value      env(local-本地环境, test-测试环境, preview-预发布环境, release-线上环境) (default: "local")
--app-version value  version (default: "1.0.0")
--app-log-more       log more (default: false)
--app-cmd value      cmd

Documentation

Index

Constants

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

	CliAppEnv     = "app-env"
	CliAppVer     = "app-version"
	CliAppLogMore = "app-log-more"
)
View Source
const (
	CliWebIP           = "web-ip"
	CliWebPort         = "web-port"
	CliWebReadTimeout  = "web-r-timeout"
	CliWebWriteTimeout = "web-w-timeout"
	CliWebIdleTimeout  = "web-idle-timeout"
)
View Source
const (
	CliAppCmd = "app-cmd"
)

Variables

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

Functions

func SetEnvDesc added in v0.1.2

func SetEnvDesc(env int, key, desc string) bool

Types

type AppConfig

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

func (*AppConfig) Env added in v0.2.0

func (v *AppConfig) Env() int

func (*AppConfig) EnvDesc added in v0.2.0

func (v *AppConfig) EnvDesc() string

func (*AppConfig) ExecDir added in v0.2.0

func (v *AppConfig) ExecDir() string

func (*AppConfig) LogMore added in v0.2.0

func (v *AppConfig) LogMore() bool

func (*AppConfig) SetEnv added in v0.1.2

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

func (*AppConfig) Version added in v0.2.0

func (v *AppConfig) Version() string

type Application added in v0.2.0

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

func (*Application) Start added in v0.2.0

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

type CmdFunc

type CmdFunc func(logger.Interface) error

type Component

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

type Service added in v0.2.0

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

type TestCmdService added in v0.2.0

type TestCmdService struct {
	Router map[string]CmdFunc
	// contains filtered or unexported fields
}

func (*TestCmdService) AddCmdHandle added in v0.2.0

func (c *TestCmdService) AddCmdHandle(name string, handle CmdFunc) *TestCmdService

func (*TestCmdService) CliFlags added in v0.2.0

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

func (*TestCmdService) Close added in v0.2.0

func (c *TestCmdService) Close()

func (*TestCmdService) Init added in v0.2.0

func (c *TestCmdService) Init(cfg *AppConfig, _ *cli.Context) (logger.Interface, error)

func (*TestCmdService) Run added in v0.2.0

type TestWebService added in v0.2.0

type TestWebService struct {
	Handle http.Handler
	// contains filtered or unexported fields
}

func (*TestWebService) CliFlags added in v0.2.0

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

func (*TestWebService) Close added in v0.2.0

func (c *TestWebService) Close()

func (*TestWebService) Init added in v0.2.0

func (c *TestWebService) Init(cfg *AppConfig, _ *cli.Context) (logger.Interface, error)

func (*TestWebService) Run added in v0.2.0

type WebConfig

type WebConfig struct {
	IP      string `json:"ip"   yaml:"ip"`
	Port    int    `json:"port" yaml:"port"`
	Timeout struct {
		Read  int `json:"read"  yaml:"read"`
		Write int `json:"write" yaml:"write"`
		Idle  int `json:"idle"  yaml:"idle"`
	} `json:"timeout" yaml:"timeout"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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