Documentation
¶
Index ¶
- Constants
- Variables
- func FullVersion() string
- func Short() string
- type Application
- func (a *Application) HTTPPrefix() string
- func (a *Application) HandleError(err error)
- func (a *Application) Init() error
- func (a *Application) Name() string
- func (i *Application) Priority() int
- func (a *Application) Start(ctx context.Context) error
- func (a *Application) String() string
- func (a *Application) SwagerDocs(swo *spec.Swagger)
- func (a *Application) UseGoRestful()
- type BuildConfig
- type BuildHook
- type ErrHandler
- type GinRouterBuilder
- type GoRestfulRouterBuilder
- type Grpc
- func (g *Grpc) AddInterceptors(interceptors ...grpc.UnaryServerInterceptor)
- func (g *Grpc) Addr() string
- func (g *Grpc) Interceptors() (interceptors []grpc.UnaryServerInterceptor)
- func (g *Grpc) Parse() error
- func (g *Grpc) ServerOpts() []grpc.ServerOption
- func (g *Grpc) Start(ctx context.Context, cb ErrHandler)
- func (g *Grpc) Stop(ctx context.Context) error
- type Http
- type RouterBuilder
- type ServiceInfoCtxKey
- type WEB_FRAMEWORK
Constants ¶
View Source
const (
AppName = "application_config"
)
Variables ¶
View Source
var ( GIT_TAG string GIT_COMMIT string GIT_BRANCH string BUILD_TIME string GO_VERSION string )
编译时注入
Functions ¶
Types ¶
type Application ¶
type Application struct {
AppName string `json:"name" yaml:"name" toml:"name" env:"APP_NAME"`
AppDescription string `json:"description" yaml:"description" toml:"description" env:"APP_DESCRIPTION"`
EncryptKey string `json:"encrypt_key" yaml:"encrypt_key" toml:"encrypt_key" env:"APP_ENCRYPT_KEY"`
CipherPrefix string `json:"cipher_prefix" yaml:"cipher_prefix" toml:"cipher_prefix" env:"APP_CIPHER_PREFIX"`
HTTP *Http `json:"http" yaml:"http" toml:"http"`
GRPC *Grpc `json:"grpc" yaml:"grpc" toml:"grpc"`
ioc.ObjectImpl
// contains filtered or unexported fields
}
func App ¶
func App() *Application
func (*Application) HTTPPrefix ¶
func (a *Application) HTTPPrefix() string
func (*Application) HandleError ¶
func (a *Application) HandleError(err error)
func (*Application) Init ¶
func (a *Application) Init() error
func (*Application) Name ¶
func (a *Application) Name() string
func (*Application) Priority ¶
func (i *Application) Priority() int
func (*Application) String ¶
func (a *Application) String() string
func (*Application) SwagerDocs ¶
func (a *Application) SwagerDocs(swo *spec.Swagger)
func (*Application) UseGoRestful ¶
func (a *Application) UseGoRestful()
type BuildConfig ¶
type ErrHandler ¶
type ErrHandler func(error)
type GinRouterBuilder ¶
type GinRouterBuilder struct {
// contains filtered or unexported fields
}
func NewGinRouterBuilder ¶
func NewGinRouterBuilder() *GinRouterBuilder
func (*GinRouterBuilder) Config ¶
func (b *GinRouterBuilder) Config(c *BuildConfig)
type GoRestfulRouterBuilder ¶
type GoRestfulRouterBuilder struct {
// contains filtered or unexported fields
}
func NewGoRestfulRouterBuilder ¶
func NewGoRestfulRouterBuilder() *GoRestfulRouterBuilder
func (*GoRestfulRouterBuilder) Build ¶
func (b *GoRestfulRouterBuilder) Build() (http.Handler, error)
func (*GoRestfulRouterBuilder) Config ¶
func (b *GoRestfulRouterBuilder) Config(c *BuildConfig)
type Grpc ¶
type Grpc struct {
// 开启GRPC服务
Enable *bool `json:"enable" yaml:"enable" toml:"enable" env:"GRPC_ENABLE"`
Host string `json:"host" yaml:"host" toml:"host" env:"GRPC_HOST"`
Port int `json:"port" yaml:"port" toml:"port" env:"GRPC_PORT"`
EnableSSL bool `json:"enable_ssl" yaml:"enable_ssl" toml:"enable_ssl" env:"GRPC_ENABLE_SSL"`
CertFile string `json:"cert_file" yaml:"cert_file" toml:"cert_file" env:"GRPC_CERT_FILE"`
KeyFile string `json:"key_file" yaml:"key_file" toml:"key_file" env:"GRPC_KEY_FILE"`
// 开启recovery恢复
EnableRecovery bool `json:"enable_recovery" yaml:"enable_recovery" toml:"enable_recovery" env:"GRPC_ENABLE_RECOVERY"`
// 开启Trace
EnableTrace bool `json:"enable_trace" yaml:"enable_trace" toml:"enable_trace" env:"GRPC_ENABLE_TRACE"`
// 启动后执行
PostStart func(context.Context) error `json:"-" yaml:"-" toml:"-" env:"-"`
// 关闭前执行
PreStop func(context.Context) error `json:"-" yaml:"-" toml:"-" env:"-"`
// contains filtered or unexported fields
}
func NewDefaultGrpc ¶
func NewDefaultGrpc() *Grpc
func (*Grpc) AddInterceptors ¶
func (g *Grpc) AddInterceptors(interceptors ...grpc.UnaryServerInterceptor)
func (*Grpc) Interceptors ¶
func (g *Grpc) Interceptors() (interceptors []grpc.UnaryServerInterceptor)
func (*Grpc) ServerOpts ¶
func (g *Grpc) ServerOpts() []grpc.ServerOption
type Http ¶
type Http struct {
// 默认根据
Enable *bool `json:"enable" yaml:"enable" toml:"enable" env:"HTTP_ENABLE"`
// HTTP服务Host
Host string `json:"size" yaml:"size" toml:"size" env:"HTTP_HOST"`
// HTTP服务端口
Port int `json:"port" yaml:"port" toml:"port" env:"HTTP_PORT"`
// 使用的http框架, 启用后会自动从ioc中加载 该框架的hanlder
WEB_FRAMEWORK WEB_FRAMEWORK `json:"web_framework" yaml:"web_framework" toml:"web_framework" env:"HTTP_WEB_FRAMEWORK"`
// HTTP服务器参数
ReadHeaderTimeoutSecond int `json:"read_header_timeout" yaml:"read_header_timeout" toml:"read_header_timeout" env:"HTTP_READ_HEADER_TIMEOUT"`
// 读取HTTP整个请求时的参数
ReadTimeoutSecond int `json:"read_timeout" yaml:"read_timeout" toml:"read_timeout" env:"HTTP_READ_TIMEOUT"`
// 响应超时事件
WriteTimeoutSecond int `json:"write_timeout" yaml:"write_timeout" toml:"write_timeout" env:"HTTP_WRITE_TIMEOUT"`
// 启用了KeepAlive时 复用TCP链接的超时时间
IdleTimeoutSecond int `json:"idle_timeout" yaml:"idle_timeout" toml:"idle_timeout" env:"HTTP_IDLE_TIMEOUT"`
// header最大大小
MaxHeaderSize string `json:"max_header_size" yaml:"max_header_size" toml:"max_header_size" env:"HTTP_MAX_HEADER_SIZE"`
// SSL启用参数
EnableSSL bool `json:"enable_ssl" yaml:"enable_ssl" toml:"enable_ssl" env:"HTTP_ENABLE_SSL"`
CertFile string `json:"cert_file" yaml:"cert_file" toml:"cert_file" env:"HTTP_CERT_FILE"`
KeyFile string `json:"key_file" yaml:"key_file" toml:"key_file" env:"HTTP_KEY_FILE"`
// 开启Trace
EnableTrace bool `toml:"enable_trace" json:"enable_trace" yaml:"enable_trace" env:"HTTP_ENABLE_TRACE"`
// 开启HTTP健康检查
EnableHealthCheck bool `toml:"enable_health_check" json:"enable_health_check" yaml:"enable_health_check" env:"HTTP_ENABLE_HEALTH_CHECK"`
// 开启跨越允许
EnableCors bool `toml:"enable_cors" json:"enable_cors" yaml:"enable_cors" env:"HTTP_ENABLE_CORS"`
// 是否开启API Doc
EnableApiDoc bool `json:"enable_api_doc" yaml:"enable_api_doc" toml:"enable_api_doc" env:"HTTP_ENABLE_API_DOC"`
// Swagger API Doc URL路径
ApiDocPath string `json:"api_doc_path" yaml:"api_doc_path" toml:"api_doc_path" env:"HTTP_API_DOC_PATH"`
RouterBuildConfig *BuildConfig
// contains filtered or unexported fields
}
func NewDefaultHttp ¶
func NewDefaultHttp() *Http
func (*Http) BuildRouter ¶
func (*Http) GetRouterBuilder ¶
func (h *Http) GetRouterBuilder() RouterBuilder
type RouterBuilder ¶
type RouterBuilder interface {
Config(*BuildConfig)
Build() (http.Handler, error)
}
type ServiceInfoCtxKey ¶
type ServiceInfoCtxKey struct{}
type WEB_FRAMEWORK ¶
type WEB_FRAMEWORK string
const ( WEB_FRAMEWORK_GO_RESTFUL WEB_FRAMEWORK = "go-restful" WEB_FRAMEWORK_GIN WEB_FRAMEWORK = "gin" )
Click to show internal directories.
Click to hide internal directories.