Documentation ¶
Index ¶
- Constants
- Variables
- func AutoMigrateObTables(parallel bool) (err error)
- func CheckObserverProcess() error
- func ClearInstance()
- func CreateDataBase(dBname string) (err error)
- func GetAvailableInstance() (db *gorm.DB, err error)
- func GetInstance() (db *gorm.DB, err error)
- func GetLastInitError() error
- func GetOcsInstance() (db *gorm.DB, err error)
- func GetRestrictedInstance() (db *gorm.DB, err error)
- func GetState() int
- func HasAttemptedConnection() bool
- func HasOceanbaseInstance() bool
- func Init()
- func IsConnecting() bool
- func IsDuplicateColumn(err error) bool
- func IsInitPasswordError() bool
- func IsTableAlreadyExists(err error) bool
- func IsTableNotExists(err error) bool
- func LoadGormWithTenant(tenant string, password string) (*gorm.DB, error)
- func LoadOceanbaseInstance(config ...*config.ObDataSourceConfig) error
- func LoadOceanbaseInstanceForTest(dsConfig *config.ObDataSourceConfig) error
- func NewConnectSubscriber() *connectSubscriber
Constants ¶
const ( TEST_DATABASE_SQL = "SELECT 1" TEST_OCEANBASE_SQL = "SHOW DATABASES" TEST_OCEANBASE_TABLES_SQL = "SHOW TABLES" )
const ( STATE_PROCESS_NOT_RUNNING = iota STATE_PROCESS_RUNNING STATE_CONNECTION_RESTRICTED STATE_CONNECTION_AVAILABLE )
Variables ¶
var (
ERR_OBSERVER_NOT_EXIST = errors.New("observer process not exist")
)
var OBStateMap = map[int]string{
0: "OB process not running",
1: "OB process running with no connection",
2: "OB process running with restricted connection",
3: "OB process running with available connection",
}
var OBStateShortMap = map[int]string{
0: "NOT RUNNING",
1: "RUNNING",
2: "RESTRICTED",
3: "AVAILABLE",
}
Functions ¶
func AutoMigrateObTables ¶
func CheckObserverProcess ¶
func CheckObserverProcess() error
if observer process not exist, return error
func ClearInstance ¶
func ClearInstance()
func CreateDataBase ¶
CreateDataBase will query whether the ocs db exists, create it if it does not exist
func GetAvailableInstance ¶
func GetInstance ¶
GetInstance will return the current connection regardless of the database it is connected with. If the connection cannot execute the SQL command 'SHOW DATABASES', it will return an error.
func GetLastInitError ¶
func GetLastInitError() error
func GetOcsInstance ¶
GetOcsInstance will return a connection to the OCS database. If the connection cannot execute the SQL command 'SHOW DATABASES', it will return an error.
func GetRestrictedInstance ¶
GetRestrictedInstance will return the connection which not specify any database and this connection can only execute the SQL command 'SELECT 1'.
func HasAttemptedConnection ¶
func HasAttemptedConnection() bool
func HasOceanbaseInstance ¶
func HasOceanbaseInstance() bool
func IsConnecting ¶
func IsConnecting() bool
func IsDuplicateColumn ¶
func IsInitPasswordError ¶
func IsInitPasswordError() bool
func IsTableAlreadyExists ¶
func IsTableNotExists ¶
func LoadGormWithTenant ¶
LoadTmpInstanceWithTenant creates a db instance according to the configuration.
func LoadOceanbaseInstance ¶
func LoadOceanbaseInstance(config ...*config.ObDataSourceConfig) error
LoadOceanbaseInstance creates a db instance according to the configuration. The `config` is a variable-length parameter, and the corresponding operation is selected according to whether the parameter is set or not. If there are no special requirements, do not set config.
func LoadOceanbaseInstanceForTest ¶
func LoadOceanbaseInstanceForTest(dsConfig *config.ObDataSourceConfig) error
LoadOceanbaseInstanceForTest will try connecting ob with the given configuration to verify that the configuration is correct.
func NewConnectSubscriber ¶
func NewConnectSubscriber() *connectSubscriber
Types ¶
This section is empty.