Documentation ¶
Index ¶
- Variables
- func ListenAndServe(s *grpc.Server, addr string)
- func NewRedisClient(cfg config.RedisConfig) *redis.Client
- func NewXormEngine(mysql config.MysqlInstance, logWriter io.Writer, idle, open int, ...) (*xorm.Engine, error)
- type App
- func (app *App) DefaultLogger() util.Logger
- func (app *App) Get(key string) interface{}
- func (app *App) GetConfig() *cfg.AppConfig
- func (app *App) GetHook(ht HookType) *[]HookFunc
- func (app *App) Initialize()
- func (app *App) Inject(object interface{}) error
- func (app *App) LoadConfig(mode string) *cfg.AppConfig
- func (app *App) Logger(name string) (util.Logger, error)
- func (app *App) RegisterHook(ht HookType, hooks ...HookFunc)
- func (app *App) Set(key string, object interface{}, ifacePtr interface{})
- func (app *App) SetConfig(config *cfg.AppConfig)
- func (app *App) SetLogger(name string, logger util.Logger)
- type Application
- type GrpcApp
- type GrpcApplication
- type HookFunc
- type HookType
- type MysqlManager
- type WebApp
- type WebApplication
Constants ¶
This section is empty.
Variables ¶
var ( // AppMode is App's running envirenment. Valid values are dev and prod AppMode string // ConfigFile is the absolute path of config file ConfigFile string // LogPath is where log file will be LogPath string )
var ( // MySQLMaxIdle of connection MySQLMaxIdle = 10 // MySQLMaxOpen of connection MySQLMaxOpen = 20 )
Functions ¶
func ListenAndServe ¶ added in v0.1.1
ListenAndServe the gRPC server at addr
func NewRedisClient ¶ added in v0.1.1
func NewRedisClient(cfg config.RedisConfig) *redis.Client
NewRedisClient get a redis client
Types ¶
type App ¶
type App struct { Store *container.Map Injector container.Injector //loggers map[string]util.Logger Config *cfg.AppConfig // contains filtered or unexported fields }
App represents the application
func (*App) DefaultLogger ¶
DefaultLogger gets default logger
func (*App) Inject ¶
Inject dependencies to the object. Please MAKE SURE that the dependencies should be stored at app.Injector before this method is called. Please use app.Set() to make this happen.
func (*App) LoadConfig ¶
LoadConfig by mode from file
func (*App) RegisterHook ¶
RegisterHook in application's starting process
type Application ¶
type Application interface { // Container Set(key string, object interface{}, ifacePtr interface{}) Get(key string) interface{} Inject(object interface{}) error // hook GetHook(HookType) *[]HookFunc // load from file LoadConfig(mode string) *cfg.AppConfig SetConfig(*cfg.AppConfig) GetConfig() *cfg.AppConfig // logger DefaultLogger() util.Logger Logger(name string) (util.Logger, error) SetLogger(string, util.Logger) // init Initialize() RegisterHook(HookType, ...HookFunc) }
Application interface represents a service application
type GrpcApp ¶
type GrpcApp struct { App // contains filtered or unexported fields }
GrpcApp is the concrete type of GrpcApplication
func (*GrpcApp) ListenAndServe ¶
func (app *GrpcApp) ListenAndServe()
ListenAndServe implements the GrpcApplication interface
type GrpcApplication ¶
type GrpcApplication interface { Application SetServer(*grpc.Server) GetServer() *grpc.Server ListenAndServe() }
GrpcApplication represents a gRPC Application
type MysqlManager ¶ added in v0.1.1
type MysqlManager struct { App Application `inject:"app"` Config config.MysqlConfig // contains filtered or unexported fields }
MysqlManager for mysql connection
func NewMysqlManager ¶ added in v0.1.1
func NewMysqlManager(app Application, config config.MysqlConfig) (*MysqlManager, error)
NewMysqlManager returns a new MysqlManager
func (*MysqlManager) DB ¶ added in v0.1.1
func (mm *MysqlManager) DB(name string) *xorm.Engine
DB gets databases by name
func (*MysqlManager) R ¶ added in v0.1.1
func (mm *MysqlManager) R() *xorm.Engine
R get read-only mysql Engine
func (*MysqlManager) SetDB ¶ added in v0.1.2
func (mm *MysqlManager) SetDB(name string, engine *xorm.Engine) bool
SetDB sets database by name
func (*MysqlManager) W ¶ added in v0.1.1
func (mm *MysqlManager) W() *xorm.Engine
W gets master mysql Engine
type WebApp ¶
type WebApp struct { App Router *echo.Echo }
WebApp is the concrete type of WebApplication
func (*WebApp) ListenAndServe ¶
func (app *WebApp) ListenAndServe()
ListenAndServe the web application
type WebApplication ¶
type WebApplication interface { Application GetRouter() *echo.Echo SetRouter(*echo.Echo) ListenAndServe() }
WebApplication interface represents a web application