Documentation ¶
Index ¶
- type DataSourceRouter
- type GoroutineSessionMap
- type LocalSession
- func (it *LocalSession) Begin() error
- func (it *LocalSession) BeginTrans(p tx.Propagation) (err error)
- func (it *LocalSession) Close()
- func (it *LocalSession) Commit() (err error)
- func (it *LocalSession) Exec(sqlorArgs string) (res *Result, err error)
- func (it *LocalSession) Id() string
- func (it *LocalSession) LastPROPAGATION() *tx.Propagation
- func (it LocalSession) New(driver string, url string, db *sql.DB, logSystem logger.Log) LocalSession
- func (it *LocalSession) Query(sqlorArgs string) (res []map[string][]byte, err error)
- func (it *LocalSession) Rollback() (err error)
- func (it *LocalSession) WithContext(ctx context.Context)
- type Result
- type Session
- type SessionEngine
- type SessionFactory
- func (it *SessionFactory) Close(id string)
- func (it *SessionFactory) CloseAll(id string)
- func (it *SessionFactory) GetSession(id string) Session
- func (it SessionFactory) New(Engine SessionEngine) SessionFactory
- func (it *SessionFactory) NewSession(mapperName string, sessionType SessionType) Session
- func (it *SessionFactory) NewSessionContext(ctx context.Context, mapperName string, sessionType SessionType) Session
- func (it *SessionFactory) SetSession(id string, session Session)
- type SessionFactorySession
- func (it *SessionFactorySession) Begin() error
- func (it *SessionFactorySession) BeginTrans(p tx.Propagation) (err error)
- func (it *SessionFactorySession) Close()
- func (it *SessionFactorySession) Commit() error
- func (it *SessionFactorySession) Exec(sqlorArgs string) (*Result, error)
- func (it *SessionFactorySession) Id() string
- func (it *SessionFactorySession) LastPROPAGATION() *tx.Propagation
- func (it *SessionFactorySession) Query(sqlorArgs string) ([]map[string][]byte, error)
- func (it *SessionFactorySession) Rollback() error
- func (it *SessionFactorySession) WithContext(ctx context.Context)
- type SessionType
- type SqlBuilder
- type SqlResultDecoder
- type TempleteDecoder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataSourceRouter ¶
type DataSourceRouter interface { //路由规则 //参数:mapperName mapper文件包名+名称例如(example.ExampleActivityMapper) //返回(session,error)路由选择后的session,error异常 Router(mapperName string, engine SessionEngine) (Session, error) //设置sql.DB,该方法会被GoMybatis框架内调用 SetDB(driver string, url string, db *sql.DB) Name() string }
数据源路由接口
type GoroutineSessionMap ¶
type GoroutineSessionMap struct {
// contains filtered or unexported fields
}
func (*GoroutineSessionMap) Delete ¶
func (it *GoroutineSessionMap) Delete(k int64)
func (*GoroutineSessionMap) Get ¶
func (it *GoroutineSessionMap) Get(k int64) Session
func (GoroutineSessionMap) New ¶
func (it GoroutineSessionMap) New() GoroutineSessionMap
func (*GoroutineSessionMap) Put ¶
func (it *GoroutineSessionMap) Put(k int64, session Session)
type LocalSession ¶
type LocalSession struct { SessionId string // contains filtered or unexported fields }
本地直连session
func (*LocalSession) Begin ¶
func (it *LocalSession) Begin() error
func (*LocalSession) BeginTrans ¶
func (it *LocalSession) BeginTrans(p tx.Propagation) (err error)
func (*LocalSession) Close ¶
func (it *LocalSession) Close()
func (*LocalSession) Commit ¶
func (it *LocalSession) Commit() (err error)
func (*LocalSession) Id ¶
func (it *LocalSession) Id() string
func (*LocalSession) LastPROPAGATION ¶
func (it *LocalSession) LastPROPAGATION() *tx.Propagation
func (LocalSession) New ¶
func (it LocalSession) New(driver string, url string, db *sql.DB, logSystem logger.Log) LocalSession
func (*LocalSession) Query ¶
func (it *LocalSession) Query(sqlorArgs string) (res []map[string][]byte, err error)
func (*LocalSession) Rollback ¶
func (it *LocalSession) Rollback() (err error)
func (*LocalSession) WithContext ¶
func (it *LocalSession) WithContext(ctx context.Context)
type SessionEngine ¶
type SessionEngine interface { //打开数据库 Open(driverName, dataSourceName string) (*sql.DB, error) //写方法到mapper WriteMapperPtr(ptr interface{}, xml []byte) //引擎名称 Name() string //创建session NewSession(mapperName string) (Session, error) NewSessionWithContext(ctx context.Context, mapperName string) (Session, error) //获取数据源路由 DataSourceRouter() DataSourceRouter //设置数据源路由 SetDataSourceRouter(router DataSourceRouter) //是否启用日志 LogEnable() bool //是否启用日志 SetLogEnable(enable bool) //获取日志实现类 Log() logger.Log //设置日志实现类 SetLog(log logger.Log) //session工厂 SessionFactory() *SessionFactory //设置session工厂 SetSessionFactory(factory *SessionFactory) //表达式执行引擎 ExpressionEngine() ast.ExpressionEngine //设置表达式执行引擎 SetExpressionEngine(engine ast.ExpressionEngine) //sql构建器 SqlBuilder() SqlBuilder //设置sql构建器 SetSqlBuilder(builder SqlBuilder) //sql查询结果解析器 SqlResultDecoder() SqlResultDecoder //设置sql查询结果解析器 SetSqlResultDecoder(decoder SqlResultDecoder) //模板解析器 TempleteDecoder() TempleteDecoder //设置模板解析器 SetTempleteDecoder(decoder TempleteDecoder) RegisterObj(ptr interface{}, name string) GetObj(name string) interface{} //(注意(该方法需要在多协程环境下调用)启用会从栈获取协程id,有一定性能消耗,换取最大的事务定义便捷) GoroutineSessionMap() *GoroutineSessionMap //是否启用goroutineIDEnable(注意(该方法需要在多协程环境下调用)启用会从栈获取协程id,有一定性能消耗,换取最大的事务定义便捷) SetGoroutineIDEnable(enable bool) //是否启用goroutineIDEnable(注意(该方法需要在多协程环境下调用)启用会从栈获取协程id,有一定性能消耗,换取最大的事务定义便捷) GoroutineIDEnable() bool LogSystem() *logger.LogSystem }
产生session的引擎
type SessionFactory ¶
type SessionFactory struct { Engine SessionEngine SessionMap sync.Map //map[string]Session }
func (*SessionFactory) Close ¶
func (it *SessionFactory) Close(id string)
func (*SessionFactory) CloseAll ¶
func (it *SessionFactory) CloseAll(id string)
func (*SessionFactory) GetSession ¶
func (it *SessionFactory) GetSession(id string) Session
func (SessionFactory) New ¶
func (it SessionFactory) New(Engine SessionEngine) SessionFactory
func (*SessionFactory) NewSession ¶
func (it *SessionFactory) NewSession(mapperName string, sessionType SessionType) Session
func (*SessionFactory) NewSessionContext ¶
func (it *SessionFactory) NewSessionContext(ctx context.Context, mapperName string, sessionType SessionType) Session
加上上下文版
func (*SessionFactory) SetSession ¶
func (it *SessionFactory) SetSession(id string, session Session)
type SessionFactorySession ¶
type SessionFactorySession struct { Session Session Factory *SessionFactory }
func (*SessionFactorySession) Begin ¶
func (it *SessionFactorySession) Begin() error
func (*SessionFactorySession) BeginTrans ¶
func (it *SessionFactorySession) BeginTrans(p tx.Propagation) (err error)
func (*SessionFactorySession) Close ¶
func (it *SessionFactorySession) Close()
func (*SessionFactorySession) Commit ¶
func (it *SessionFactorySession) Commit() error
func (*SessionFactorySession) Exec ¶
func (it *SessionFactorySession) Exec(sqlorArgs string) (*Result, error)
func (*SessionFactorySession) Id ¶
func (it *SessionFactorySession) Id() string
func (*SessionFactorySession) LastPROPAGATION ¶
func (it *SessionFactorySession) LastPROPAGATION() *tx.Propagation
func (*SessionFactorySession) Query ¶
func (it *SessionFactorySession) Query(sqlorArgs string) ([]map[string][]byte, error)
func (*SessionFactorySession) Rollback ¶
func (it *SessionFactorySession) Rollback() error
func (*SessionFactorySession) WithContext ¶
func (it *SessionFactorySession) WithContext(ctx context.Context)
type SessionType ¶
type SessionType = int
const ( SessionType_Default SessionType = iota //默认session类型 SessionType_Local //本地session )
type SqlBuilder ¶
type SqlBuilder interface { BuildSql(paramMap map[string]interface{}, nodes []ast.Node) (string, error) ExpressionEngineProxy() *sqlbuilder.ExpressionEngineProxy SqlArgTypeConvert() ast.SqlArgTypeConvert SetEnableLog(enable bool) EnableLog() bool NodeParser() ast.NodeParser }
sql文本构建
type SqlResultDecoder ¶
type SqlResultDecoder interface { //resultMap = in xml resultMap element //dbData = select the SqlResult //decodeResultPtr = need decode result type Decode(resultMap map[string]*sqlbuilder.ResultProperty, SqlResult []map[string][]byte, decodeResultPtr interface{}) error }
sql查询结果解码
Source Files ¶
Click to show internal directories.
Click to hide internal directories.