Documentation ¶
Index ¶
- Constants
- func AppDefaultBoot(container ICtxContainer)
- func AppDefaultInit(container ICtxContainer)
- func AppDefaultSetup(container ICtxContainer)
- func Container(name string, ctx ...ICtxContainer) interface{}
- func Dirname() string
- func DriverName(scope string, name string) string
- func LogicError(message string) error
- func NetWorkError(message string) error
- func OnError(err error)
- func RuntimeError(message string) error
- func ServiceError(message string) error
- func TransformMap2Struct(data map[string]interface{}, v interface{}, tags ...string) (err error)
- func TransformStruct2Map(v interface{}, tags ...string) (data map[string]interface{}, err error)
- func WarpError(msg string, err ...error) error
- type AppApi
- func (a *AppApi) Boot()
- func (a *AppApi) Component(string) (interface{}, error)
- func (a *AppApi) Context() ICtxContainer
- func (a *AppApi) Destroy()
- func (a *AppApi) Hook(string, func(string, interface{}))
- func (a *AppApi) Init()
- func (a *AppApi) On(string, IAppEventHandler)
- func (a *AppApi) Run()
- func (a *AppApi) Stop()
- type AppWeb
- func (a *AppWeb) Boot()
- func (a AppWeb) Component(name string) (interface{}, error)
- func (a *AppWeb) Context() ICtxContainer
- func (a *AppWeb) Destroy()
- func (a *AppWeb) Hook(hook string, handler func(string, interface{}))
- func (a *AppWeb) Init()
- func (a *AppWeb) On(event string, handler IAppEventHandler)
- func (a *AppWeb) Run()
- func (a *AppWeb) Setup()
- func (a *AppWeb) Stop()
- type ComponentInvoker
- type Configure
- func (c *Configure) Block() bool
- func (c *Configure) Boot() bool
- func (c *Configure) Booted() bool
- func (c *Configure) Destroy()
- func (c *Configure) Durations(key string) []time.Duration
- func (c *Configure) Face() string
- func (c *Configure) Float64s(key string) []float64
- func (c *Configure) Get(key string) (string, error)
- func (c *Configure) GetBool(key string) (bool, error)
- func (c *Configure) GetBoolDefault(key string, defaultValue bool) bool
- func (c *Configure) GetDefault(key, defaultValue string) string
- func (c *Configure) GetDuration(key string) (time.Duration, error)
- func (c *Configure) GetDurationDefault(key string, defaultValue time.Duration) time.Duration
- func (c *Configure) GetFloat64(key string) (float64, error)
- func (c *Configure) GetFloat64Default(key string, defaultValue float64) float64
- func (c *Configure) GetInt(key string) (int, error)
- func (c *Configure) GetIntDefault(key string, defaultValue int) int
- func (c *Configure) Ints(key string) []int
- func (c *Configure) Keys() []string
- func (c *Configure) Prefix(prefix string, withOutPrefix ...bool) ConfigureFace
- func (c *Configure) Register(container ICtxContainer) bool
- func (c *Configure) Set(key, val string)
- func (c *Configure) SetAll(values map[string]string)
- func (c *Configure) Strings(key string) []string
- func (c *Configure) Unmarshal(t interface{}) error
- type ConfigureFace
- type CreateAble
- type CtxContainer
- func (c *CtxContainer) Faced(face string) (ok bool)
- func (c *CtxContainer) Get(key string) interface{}
- func (c *CtxContainer) Register(face string, invoker ComponentInvoker)
- func (c *CtxContainer) RegisterByFace(instance IFaced)
- func (c *CtxContainer) RegisterBySingle(face string, instance interface{})
- func (c *CtxContainer) Remove(id string) bool
- type DataMap
- type ErrorAble
- func (e *ErrorAble) Block() bool
- func (e *ErrorAble) Boot() bool
- func (e *ErrorAble) Booted() bool
- func (e *ErrorAble) Code() int
- func (e *ErrorAble) Destroy()
- func (e *ErrorAble) Error() string
- func (e *ErrorAble) ErrorType() string
- func (e *ErrorAble) Face() string
- func (e *ErrorAble) Message() string
- func (e *ErrorAble) New(msg string, code int, parent ...error) error
- func (e *ErrorAble) Register(ctx ICtxContainer) bool
- func (e *ErrorAble) Set(key string, value interface{}) ErrorInstance
- func (e *ErrorAble) TraceString() string
- type ErrorFace
- type ErrorInstance
- type IAppEventHandler
- type IApplication
- type IConfiguration
- type ICtxContainer
- type ICtxRegister
- type IDatabase
- type IDestroy
- type IFaced
- type IModel
- type IQueryBuilder
- type IRedisClient
- type IRemoveAble
- type IReturnAble
- type ISqlExecutor
- type IStarter
- type LogInstanceFace
- func (l *LogInstanceFace) Block() bool
- func (l *LogInstanceFace) Boot() bool
- func (l *LogInstanceFace) Booted() bool
- func (l *LogInstanceFace) Debug(args ...interface{})
- func (l *LogInstanceFace) Debugf(format string, args ...interface{})
- func (l *LogInstanceFace) Destroy()
- func (l *LogInstanceFace) Error(args ...interface{})
- func (l *LogInstanceFace) Errorf(format string, args ...interface{})
- func (l *LogInstanceFace) Face() string
- func (l *LogInstanceFace) Fatal(args ...interface{})
- func (l *LogInstanceFace) Fatalf(format string, args ...interface{})
- func (l *LogInstanceFace) Info(args ...interface{})
- func (l *LogInstanceFace) Infof(format string, args ...interface{})
- func (l *LogInstanceFace) Panic(args ...interface{})
- func (l *LogInstanceFace) Panicf(format string, args ...interface{})
- func (l *LogInstanceFace) Print(args ...interface{})
- func (l *LogInstanceFace) Printf(format string, args ...interface{})
- func (l *LogInstanceFace) Register(ctx ICtxContainer) bool
- func (l *LogInstanceFace) Warn(args ...interface{})
- func (l *LogInstanceFace) Warnf(format string, args ...interface{})
- func (l *LogInstanceFace) Warning(args ...interface{})
- func (l *LogInstanceFace) Warningf(format string, args ...interface{})
- type Logger
- type LoggerFace
- type ReturnAble
- type RpcApp
- func (r *RpcApp) Boot()
- func (r *RpcApp) Component(string) (interface{}, error)
- func (r *RpcApp) Context() ICtxContainer
- func (r *RpcApp) Destroy()
- func (r *RpcApp) Hook(string, func(string, interface{}))
- func (r *RpcApp) Init()
- func (r *RpcApp) On(string, IAppEventHandler)
- func (r *RpcApp) Run()
- func (r *RpcApp) Stop()
- type StarterContext
- type WebSocketApp
- func (w *WebSocketApp) Boot()
- func (w *WebSocketApp) Component(string) (interface{}, error)
- func (w *WebSocketApp) Context() ICtxContainer
- func (w *WebSocketApp) Destroy()
- func (w *WebSocketApp) Hook(string, func(string, interface{}))
- func (w *WebSocketApp) Init()
- func (w *WebSocketApp) On(string, IAppEventHandler)
- func (w *WebSocketApp) Run()
- func (w *WebSocketApp) Stop()
Constants ¶
View Source
const ApiAppName = "ApiApp"
View Source
const ApiAppVersion = "1.0.0-Beta"
View Source
const ConfigureFaceId = "IConfiguration"
View Source
const ConfigureId = "configure"
常量
View Source
const ErrorFaceId = "error"
View Source
const ErrorId = "err"
View Source
const LoggerFaceId = "logger"
View Source
const LoggerId = "log"
View Source
const RpcAppName = "RpcApp"
View Source
const RpcAppVersion = "1.0.0-Beta"
View Source
const SuccessCode = 200
View Source
const WebAppName = "WebApp"
View Source
const WebAppVersion = "1.0.0-Beta"
View Source
const WebSocketAppName = "WebSocketApp"
View Source
const WebSocketAppVersion = "1.0.0-Beta"
Variables ¶
This section is empty.
Functions ¶
func TransformMap2Struct ¶
简单转换 不支持嵌套
func TransformStruct2Map ¶
简单转换 不支持嵌套
Types ¶
type AppApi ¶
type AppApi struct { Ctx ICtxContainer AppName string Version string }
func (*AppApi) Context ¶
func (a *AppApi) Context() ICtxContainer
func (*AppApi) On ¶
func (a *AppApi) On(string, IAppEventHandler)
type AppWeb ¶
type AppWeb struct { Ctx ICtxContainer AppName string Version string }
func (*AppWeb) Context ¶
func (a *AppWeb) Context() ICtxContainer
func (*AppWeb) On ¶
func (a *AppWeb) On(event string, handler IAppEventHandler)
type ComponentInvoker ¶
type ComponentInvoker func(ICtxContainer) interface{}
type Configure ¶
type Configure struct {
// contains filtered or unexported fields
}
配置管理门脸类
func (*Configure) GetBoolDefault ¶
func (*Configure) GetDefault ¶
func (*Configure) GetDurationDefault ¶
func (*Configure) GetFloat64Default ¶
func (*Configure) GetIntDefault ¶
func (*Configure) Prefix ¶
func (c *Configure) Prefix(prefix string, withOutPrefix ...bool) ConfigureFace
func (*Configure) Register ¶
func (c *Configure) Register(container ICtxContainer) bool
type ConfigureFace ¶
type ConfigureFace interface { IFaced // 门脸信息,门脸注册相关 IConfiguration // 实例操作集合 }
配置管理(门脸)对象
func GetConfigureInstance ¶
func GetConfigureInstance(instances ...IConfiguration) ConfigureFace
获取单例
type CtxContainer ¶
type CtxContainer struct {
// contains filtered or unexported fields
}
func (*CtxContainer) Faced ¶
func (c *CtxContainer) Faced(face string) (ok bool)
func (*CtxContainer) Get ¶
func (c *CtxContainer) Get(key string) interface{}
func (*CtxContainer) Register ¶
func (c *CtxContainer) Register(face string, invoker ComponentInvoker)
func (*CtxContainer) RegisterByFace ¶
func (c *CtxContainer) RegisterByFace(instance IFaced)
func (*CtxContainer) RegisterBySingle ¶
func (c *CtxContainer) RegisterBySingle(face string, instance interface{})
func (*CtxContainer) Remove ¶
func (c *CtxContainer) Remove(id string) bool
type ErrorAble ¶
type ErrorAble struct {
// contains filtered or unexported fields
}
func (*ErrorAble) Register ¶
func (e *ErrorAble) Register(ctx ICtxContainer) bool
func (*ErrorAble) Set ¶
func (e *ErrorAble) Set(key string, value interface{}) ErrorInstance
func (*ErrorAble) TraceString ¶
type ErrorFace ¶
type ErrorFace interface { IFaced ErrorInstance }
func GetErrorFaceInstance ¶
func GetErrorFaceInstance() ErrorFace
func NewErrorFace ¶
func NewErrorFace(instance ...ErrorInstance) ErrorFace
type ErrorInstance ¶
type IAppEventHandler ¶
type IAppEventHandler func(target interface{}, ctx ICtxContainer, next IAppEventHandler)
type IApplication ¶
type IApplication interface { Boot() // 在自身所需 配置 或者驱动 和检查相关环境 Init() // 初始化 依赖组织 并注册 到相关容器中 Run() // 运行于启动 应用, 提供外部相关服务 Stop() // 暂停服务 Destroy() // 回收服务资源 Context() ICtxContainer // 获取上线文容器 Component(string) (interface{}, error) // 获取组件 Hook(string, func(string, interface{})) // 添加相关hook处理函数 On(string, IAppEventHandler) // 添加事件处理机制调用链 , 事件处理链路可以自由阻断 }
func NewApiApp ¶
func NewApiApp(name ...string) IApplication
func NewRpcApp ¶
func NewRpcApp(name ...string) IApplication
func NewWebApp ¶
func NewWebApp(name ...string) IApplication
func NewWsApp ¶
func NewWsApp(name ...string) IApplication
type IConfiguration ¶
type IConfiguration interface { // values Strings(key string) []string Ints(key string) []int Float64s(key string) []float64 Durations(key string) []time.Duration // Get(string) (string, error) GetDefault(string, string) string // GetInt(string) (int, error) GetIntDefault(string, int) int // GetDuration(string) (time.Duration, error) GetDurationDefault(string, time.Duration) time.Duration // GetBool(string) (bool, error) GetBoolDefault(string, bool) bool // GetFloat64(string) (float64, error) GetFloat64Default(string, float64) float64 Set(string, string) SetAll(map[string]string) Keys() []string //t必须为指针型 Unmarshal(interface{}) error // 获取特定前缀配置,返回新配置对象 Prefix(string, ...bool) ConfigureFace }
配置操作对象
type ICtxContainer ¶
type ICtxContainer interface { Get(string) interface{} // 获取注册对象 Register(string, ComponentInvoker) // 构造函数注册 RegisterBySingle(string, interface{}) // 单例注册 RegisterByFace(IFaced) // 门脸模式自动注册 Faced(string) bool // 是否已注册 IRemoveAble }
func GetContainerInstance ¶
func GetContainerInstance() ICtxContainer
func NewCtxContainer ¶
func NewCtxContainer() ICtxContainer
type ICtxRegister ¶
type ICtxRegister interface {
Register(ICtxContainer) // 注册
}
type IDatabase ¶
type IDatabase interface { SetConnection(string) // 获取链接对象 Create(interface{}) bool // 通过数据结构体 创建,返回是否成功 Table(string) IQueryBuilder // 获取 指定表的查询对象 Select(string) IQueryBuilder // 通过 select 语句构造 query 对象 Exec(string) (int, error) // 执行原始sql 返回影响记录数和异常 Connection() interface{} // 获取当前链接对象 Query(string, ...interface{}) (IQueryBuilder, error) // 构建 query 查询对象 }
数据库
type IFaced ¶
type IFaced interface { Face() string // 门脸名 Register(ICtxContainer) bool // 自动注册逻辑 Booted() bool // 是否已执行引导 Boot() bool // 引导加载逻辑 Block() bool // 引导加载是否阻塞 Destroy() // 清理回收 }
门脸对象
type IModel ¶
type IModel interface { Table() string // 表名 Model() interface{} // 模型结构体 Tags(...string) map[string]string // 结构体 对应 tags集合 Conn(...string) IDatabase // 获取数据库操作对象 }
模型
type IQueryBuilder ¶
type IQueryBuilder interface { ToSql() string // 输出sql Count() int // 条数 Exists() bool // 是否存在 Save() (int, error) // 保存 CurrentTable() string // 当前表名 All() (interface{}, error) // 获取所有 First() (interface{}, error) // 获取第一条 Update(map[string]interface{}) ISqlExecutor // 更新 Order(string, string) IQueryBuilder // 排序 Group(string, string) IQueryBuilder // 分组 Join(string, ...string) IQueryBuilder // join Insert(interface{}, ...interface{}) ISqlExecutor // 插入 Delete(string, ...interface{}) ISqlExecutor // 删除语句 Pluck(string, interface{}) IQueryBuilder // 获取其中一个键值 When(string, ...func(IQueryBuilder) ISqlExecutor) IQueryBuilder // 组合语句 Raw(string) IQueryBuilder // sql原始语句 Get() (interface{}, error) // 执行并获取sql结果 GetOne() (interface{}, error) // 获取任意一条 }
查询构造器
type IRedisClient ¶
type IRedisClient interface { Del(key string) Exists(key string) bool Set(key string, value string) Get(key string) (string, error) HSet(key string, hash map[string]string) HGet(key string, field string) (string, error) HGetAll(key string) (map[string]string, error) Setex(key string, value string, expire time.Duration) Command(command string, args ...interface{}) (interface{}, error) }
type IRemoveAble ¶
type IReturnAble ¶
type IReturnAble interface { State() int64 Message() string Value() interface{} ToJson() string ToMap() DataMap Error() error Transform(interface{}, string) error }
结果对象
func NewFailAbel ¶
func NewFailAbel(errMsg string, errNo int64, res ...interface{}) IReturnAble
func NewReturnAble ¶
func NewReturnAble(code int64, msg string, data interface{}, errNo int64, errMsg string) IReturnAble
func NewSuccessAble ¶
func NewSuccessAble(data interface{}, msg string, codeArg ...int64) IReturnAble
type ISqlExecutor ¶
type ISqlExecutor interface { Sql() string // 输出 sql Exec() (interface{}, error) // 执行 Sql 语句 获取结果 }
sql 执行器
type IStarter ¶
type IStarter interface { Init() // 初始化函数 Start() // 启动函数 Stop() // 停止 Register(ICtxContainer) // 自动注册函数 Block() bool // 是否阻塞启动 Destroy() // 清理 }
type LogInstanceFace ¶
type LogInstanceFace struct {
// contains filtered or unexported fields
}
日志实例 对象
func (*LogInstanceFace) Block ¶
func (l *LogInstanceFace) Block() bool
func (*LogInstanceFace) Boot ¶
func (l *LogInstanceFace) Boot() bool
func (*LogInstanceFace) Booted ¶
func (l *LogInstanceFace) Booted() bool
func (*LogInstanceFace) Debug ¶
func (l *LogInstanceFace) Debug(args ...interface{})
func (*LogInstanceFace) Debugf ¶
func (l *LogInstanceFace) Debugf(format string, args ...interface{})
func (*LogInstanceFace) Destroy ¶
func (l *LogInstanceFace) Destroy()
func (*LogInstanceFace) Error ¶
func (l *LogInstanceFace) Error(args ...interface{})
func (*LogInstanceFace) Errorf ¶
func (l *LogInstanceFace) Errorf(format string, args ...interface{})
func (*LogInstanceFace) Face ¶
func (l *LogInstanceFace) Face() string
func (*LogInstanceFace) Fatal ¶
func (l *LogInstanceFace) Fatal(args ...interface{})
func (*LogInstanceFace) Fatalf ¶
func (l *LogInstanceFace) Fatalf(format string, args ...interface{})
func (*LogInstanceFace) Info ¶
func (l *LogInstanceFace) Info(args ...interface{})
func (*LogInstanceFace) Infof ¶
func (l *LogInstanceFace) Infof(format string, args ...interface{})
func (*LogInstanceFace) Panic ¶
func (l *LogInstanceFace) Panic(args ...interface{})
func (*LogInstanceFace) Panicf ¶
func (l *LogInstanceFace) Panicf(format string, args ...interface{})
func (*LogInstanceFace) Print ¶
func (l *LogInstanceFace) Print(args ...interface{})
func (*LogInstanceFace) Printf ¶
func (l *LogInstanceFace) Printf(format string, args ...interface{})
func (*LogInstanceFace) Register ¶
func (l *LogInstanceFace) Register(ctx ICtxContainer) bool
func (*LogInstanceFace) Warn ¶
func (l *LogInstanceFace) Warn(args ...interface{})
func (*LogInstanceFace) Warnf ¶
func (l *LogInstanceFace) Warnf(format string, args ...interface{})
func (*LogInstanceFace) Warning ¶
func (l *LogInstanceFace) Warning(args ...interface{})
func (*LogInstanceFace) Warningf ¶
func (l *LogInstanceFace) Warningf(format string, args ...interface{})
type Logger ¶
type Logger interface { Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Printf(format string, args ...interface{}) Warnf(format string, args ...interface{}) Warningf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) Panicf(format string, args ...interface{}) Debug(args ...interface{}) Info(args ...interface{}) Print(args ...interface{}) Warn(args ...interface{}) Warning(args ...interface{}) Error(args ...interface{}) Fatal(args ...interface{}) Panic(args ...interface{}) }
日志操作对象
type LoggerFace ¶
日志 门脸接口
type ReturnAble ¶
type ReturnAble struct { Code int64 `json:"code" Tr:"code"` Msg string `json:"msg" Tr:"msg"` Data interface{} `json:"data" Tr:"data"` ErrNo int64 `json:"errNo" Tr:"errno"` ErrMsg string `json:"errMsg" Tr:"errMsg"` }
func (*ReturnAble) Error ¶
func (r *ReturnAble) Error() error
func (*ReturnAble) Message ¶
func (r *ReturnAble) Message() string
func (*ReturnAble) State ¶
func (r *ReturnAble) State() int64
func (*ReturnAble) ToJson ¶
func (r *ReturnAble) ToJson() string
func (*ReturnAble) ToMap ¶
func (r *ReturnAble) ToMap() DataMap
func (*ReturnAble) Transform ¶
func (r *ReturnAble) Transform(v interface{}, scope string) error
对应结果体装载
func (*ReturnAble) Value ¶
func (r *ReturnAble) Value() interface{}
type RpcApp ¶
type RpcApp struct { Ctx ICtxContainer AppName string Version string }
func (*RpcApp) Context ¶
func (r *RpcApp) Context() ICtxContainer
func (*RpcApp) On ¶
func (r *RpcApp) On(string, IAppEventHandler)
type StarterContext ¶
type StarterContext struct { CtxContainer Name string // 启动器名 }
starter 上下文 构造环境获取器
type WebSocketApp ¶
type WebSocketApp struct { Ctx ICtxContainer AppName string Version string }
func (*WebSocketApp) Boot ¶
func (w *WebSocketApp) Boot()
func (*WebSocketApp) Component ¶
func (w *WebSocketApp) Component(string) (interface{}, error)
func (*WebSocketApp) Context ¶
func (w *WebSocketApp) Context() ICtxContainer
func (*WebSocketApp) Destroy ¶
func (w *WebSocketApp) Destroy()
func (*WebSocketApp) Hook ¶
func (w *WebSocketApp) Hook(string, func(string, interface{}))
func (*WebSocketApp) Init ¶
func (w *WebSocketApp) Init()
func (*WebSocketApp) On ¶
func (w *WebSocketApp) On(string, IAppEventHandler)
func (*WebSocketApp) Run ¶
func (w *WebSocketApp) Run()
func (*WebSocketApp) Stop ¶
func (w *WebSocketApp) Stop()
Click to show internal directories.
Click to hide internal directories.