gsf

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: MulanPSL-2.0 Imports: 13 Imported by: 0

README

gsf-fof

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

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

func (*Application) Start

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

type CmdArg

type CmdArg struct {
	Name, Default string
}

type CmdHandle

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

type CmdService

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

func (*CmdService) AddCmdFunc

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

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 *Config, _ *cli.Context) (logger.Interface, error)

func (*CmdService) Run

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

type Component

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

type Config

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

func (*Config) Env

func (v *Config) Env() int

func (*Config) EnvDesc

func (v *Config) EnvDesc() string

func (*Config) ExecDir

func (v *Config) ExecDir() string

func (*Config) LogMore

func (v *Config) LogMore() bool

func (*Config) SetEnv

func (v *Config) SetEnv(e int)

func (*Config) SetLogMore

func (v *Config) SetLogMore(lm bool)

func (*Config) Version

func (v *Config) Version() string

type Service

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 {
	Cfg                   WebConfig
	Handler               http.Handler
	BeforeRun, BeforeInit func(l logger.Interface) error
}

func (*WebService) CliFlags

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

func (*WebService) Close

func (c *WebService) Close()

func (*WebService) Init

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

func (*WebService) Run

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