Documentation ¶
Index ¶
- Variables
- func InitializeDataStore(config *settings.Config) error
- func NewXOrmLoggerAdapter(showSql bool, logLevel settings.Level) xorm.Logger
- type DataStore
- type DataStoreContainer
- type Database
- type XOrmContextAdapter
- type XOrmLoggerAdapter
- func (logger XOrmLoggerAdapter) Debug(v ...any)
- func (logger XOrmLoggerAdapter) Debugf(format string, v ...any)
- func (logger XOrmLoggerAdapter) Error(v ...any)
- func (logger XOrmLoggerAdapter) Errorf(format string, v ...any)
- func (logger XOrmLoggerAdapter) Info(v ...any)
- func (logger XOrmLoggerAdapter) Infof(format string, v ...any)
- func (logger XOrmLoggerAdapter) IsShowSQL() bool
- func (logger XOrmLoggerAdapter) Level() xorm.LogLevel
- func (logger XOrmLoggerAdapter) SetLevel(l xorm.LogLevel)
- func (logger XOrmLoggerAdapter) ShowSQL(show ...bool)
- func (logger XOrmLoggerAdapter) Warn(v ...any)
- func (logger XOrmLoggerAdapter) Warnf(format string, v ...any)
Constants ¶
This section is empty.
Variables ¶
var (
Container = &DataStoreContainer{}
)
Initialize a data storage container singleton instance
Functions ¶
func InitializeDataStore ¶
InitializeDataStore initializes data storage according to the config
Types ¶
type DataStore ¶
type DataStore struct {
// contains filtered or unexported fields
}
DataStore represents a data storage containing a series of database shards
func NewDataStore ¶
NewDataStore returns a new data storage by a series of database
func (*DataStore) DoTransaction ¶
func (s *DataStore) DoTransaction(key int64, c *core.Context, fn func(sess *xorm.Session) error) (err error)
DoTransaction runs a new database transaction in a specific database by sharding key
func (*DataStore) Query ¶
Query returns a new database session in a specific database by sharding key
func (*DataStore) SyncStructs ¶
SyncStructs updates database structs by database models
type DataStoreContainer ¶
type DataStoreContainer struct { UserStore *DataStore TokenStore *DataStore UserDataStore *DataStore }
DataStoreContainer contains all data storages
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database represents a database instance
func (*Database) DoTransaction ¶
DoTransaction runs a new database transaction
type XOrmContextAdapter ¶
type XOrmContextAdapter struct {
// contains filtered or unexported fields
}
XOrmContextAdapter represents the context adapter for xorm
func NewXOrmContextAdapter ¶
func NewXOrmContextAdapter(c *core.Context) *XOrmContextAdapter
func (*XOrmContextAdapter) Deadline ¶
func (c *XOrmContextAdapter) Deadline() (deadline time.Time, ok bool)
Deadline does nothing
func (*XOrmContextAdapter) Done ¶
func (c *XOrmContextAdapter) Done() <-chan struct{}
Done always returns nil
func (*XOrmContextAdapter) Value ¶
func (c *XOrmContextAdapter) Value(key any) any
Value returns the value associated with this context for key, or nil if no value is associated with key.
type XOrmLoggerAdapter ¶
type XOrmLoggerAdapter struct {
// contains filtered or unexported fields
}
XOrmLoggerAdapter represents the logger adapter for xorm
func (XOrmLoggerAdapter) Debug ¶
func (logger XOrmLoggerAdapter) Debug(v ...any)
Debug logs debug log
func (XOrmLoggerAdapter) Debugf ¶
func (logger XOrmLoggerAdapter) Debugf(format string, v ...any)
Debugf logs debug log with custom format
func (XOrmLoggerAdapter) Error ¶
func (logger XOrmLoggerAdapter) Error(v ...any)
Error logs error log
func (XOrmLoggerAdapter) Errorf ¶
func (logger XOrmLoggerAdapter) Errorf(format string, v ...any)
Errorf logs error log with custom format
func (XOrmLoggerAdapter) Infof ¶
func (logger XOrmLoggerAdapter) Infof(format string, v ...any)
Infof logs info log with custom format
func (XOrmLoggerAdapter) IsShowSQL ¶
func (logger XOrmLoggerAdapter) IsShowSQL() bool
IsShowSQL returns whether write sql to log
func (XOrmLoggerAdapter) Level ¶
func (logger XOrmLoggerAdapter) Level() xorm.LogLevel
Level returns the logger level
func (XOrmLoggerAdapter) SetLevel ¶
func (logger XOrmLoggerAdapter) SetLevel(l xorm.LogLevel)
SetLevel sets the logger level
func (XOrmLoggerAdapter) ShowSQL ¶
func (logger XOrmLoggerAdapter) ShowSQL(show ...bool)
ShowSQL sets whether write sql to log
func (XOrmLoggerAdapter) Warnf ¶
func (logger XOrmLoggerAdapter) Warnf(format string, v ...any)
Warnf logs warn log with custom format