Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application struct {
Context
Config Config // todo 改为引用?
// GinRouter gin.IRouter
GinRouter *gin.Engine
// contains filtered or unexported fields
}
Application FIXME 可以考虑也实现 Module接口 变为组合设计模式?
func New ¶
func New(conf Config) *Application
func (*Application) Init ¶
func (app *Application) Init()
func (*Application) RegisterModule ¶
func (app *Application) RegisterModule(mid string, m Module) error
func (*Application) Run ¶
func (app *Application) Run()
type Config ¶
type Config struct {
Raw *viper.Viper
// the path to the error message file. Defaults to "config/errors.yaml"
ErrorFile string `mapstructure:"error_file"`
// the server port. Defaults to 8080
ServerPort int `mapstructure:"server_port"`
// the data source name (DSN) for connecting to the database. required.
DSN string `mapstructure:"dsn"`
// the signing method for JWT. Defaults to "HS256"
JWTSigningMethod string `mapstructure:"jwt_signing_method"`
// JWT signing key. required.
JWTSigningKey string `mapstructure:"jwt_signing_key"`
// JWT verification key. required.
JWTVerificationKey string `mapstructure:"jwt_verification_key"`
}
func LoadConfig ¶
LoadConfig loads configuration from the given list of paths and populates it into the Config variable. The configuration file(s) should be named as app.yaml. Environment variables with the prefix "RESTFUL_" in their names are also read automatically.
type Context ¶
Context represents a global-vars namespace , store shared vars here . alias is AppContext ,dry(dont repeat yourself) for removing the prefix App
type Module ¶
type Module interface {
// globalViper instance or SubViper? 当前才用拉配置 后期可以用依赖注入 就不需要从viper实例中拉配置信息了
Configure(v *viper.Viper) error
// TODO 签名改为Init() error
Init() error
Start() error
// Stop is called to stop operation of the coordinator. In this func, the coordinator should call the Stop func for
// any of its modules, and stop any goroutines that it has started. While it can return an error if there is a
// problem, the errors are mostly ignored.
Stop() error
}
参考:Burrow modular define methods a module should have
type ProtoModule ¶
type ProtoModule struct {
}
ProtoModule is a stub Module which implements the Module interface with all empty methods !
func (*ProtoModule) Init ¶
func (m *ProtoModule) Init() error
func (*ProtoModule) Start ¶
func (m *ProtoModule) Start() error
func (*ProtoModule) Stop ¶
func (m *ProtoModule) Stop() error
Click to show internal directories.
Click to hide internal directories.