gsf

package module
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 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 (
	EnvLocal   = 0 // 本地
	EnvTest    = 1 // 测试
	EnvPrev    = 2 // 预发布
	EnvRelease = 3 // 线上

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

Variables

View Source
var (
	EnvVersion = "1.0.0"

	EnvLocalArg   = "local"   // 本地
	EnvTestArg    = "test"    // 测试
	EnvPrevArg    = "preview" // 预发布
	EnvReleaseArg = "release" // 线上
)
View Source
var (
	CmdNoFind = errors.New(" Command No Find")
)

Functions

This section is empty.

Types

type Application added in v0.2.0

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

func (*Application) Start added in v0.2.0

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

type CmdArg added in v0.2.2

type CmdArg struct {
	Name, Default string
}

type CmdHandle added in v0.2.2

type CmdHandle interface {
	Flags() []CmdArg
	Run(logger.Interface, map[string]string) error
}

type CmdService added in v0.2.2

type CmdService struct {
	Router                map[string]CmdHandle
	BeforeRun, BeforeInit func(l logger.Interface) error
	// contains filtered or unexported fields
}

func (*CmdService) AddCmdFunc added in v0.2.2

func (c *CmdService) AddCmdFunc(name string, handle func(logger.Interface) error) *CmdService

func (*CmdService) AddCmdHandle added in v0.2.2

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

func (*CmdService) CliFlags added in v0.2.2

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

func (*CmdService) Close added in v0.2.2

func (c *CmdService) Close()

func (*CmdService) Init added in v0.2.2

func (c *CmdService) Init(cfg *Config, _ *cli.Context) (logger.Interface, error)

func (*CmdService) Run added in v0.2.2

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

type Component

type Component interface {
	CliFlags() []cli.Flag
	Init(env int, logMore bool, ctx *cli.Context, infoLog, warnLog, errLog func(string, ...interface{})) error
	Run(env int, logMore bool, infoLog, warnLog, errLog func(string, ...interface{})) error
	Close(env int, logMore bool, infoLog, warnLog, errLog func(string, ...interface{})) error
}

type Config added in v0.2.2

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

func (*Config) Env added in v0.2.2

func (v *Config) Env() int

func (*Config) EnvDesc added in v0.2.2

func (v *Config) EnvDesc() string

func (*Config) ExecDir added in v0.2.2

func (v *Config) ExecDir() string

func (*Config) LogMore added in v0.2.2

func (v *Config) LogMore() bool

func (*Config) Version added in v0.2.2

func (v *Config) Version() string

type Service added in v0.2.0

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

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"`
}

type WebService

type WebService struct {
	Handle                http.Handler
	BeforeRun, BeforeInit func(l logger.Interface) error
	// contains filtered or unexported fields
}

func (*WebService) CliFlags added in v0.2.2

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

func (*WebService) Close added in v0.2.2

func (c *WebService) Close()

func (*WebService) Init

func (c *WebService) Init(cfg *Config, _ *cli.Context) (logger.Interface, error)

func (*WebService) Run added in v0.2.2

func (c *WebService) Run(l logger.Interface, cfg *Config) error

Directories

Path Synopsis
web

Jump to

Keyboard shortcuts

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