* feat: support ClickHouse log database * feat(log): optimize log deletion process for ClickHouse
45 lines
1022 B
Go
45 lines
1022 B
Go
package common
|
|
|
|
type DatabaseType string
|
|
|
|
const (
|
|
DatabaseTypeMySQL DatabaseType = "mysql"
|
|
DatabaseTypeSQLite DatabaseType = "sqlite"
|
|
DatabaseTypePostgreSQL DatabaseType = "postgres"
|
|
DatabaseTypeClickHouse DatabaseType = "clickhouse"
|
|
)
|
|
|
|
var mainDatabaseType = DatabaseTypeSQLite
|
|
var logDatabaseType = DatabaseTypeSQLite
|
|
|
|
func MainDatabaseType() DatabaseType {
|
|
return mainDatabaseType
|
|
}
|
|
|
|
func LogDatabaseType() DatabaseType {
|
|
return logDatabaseType
|
|
}
|
|
|
|
func SetMainDatabaseType(databaseType DatabaseType) {
|
|
mainDatabaseType = databaseType
|
|
}
|
|
|
|
func SetLogDatabaseType(databaseType DatabaseType) {
|
|
logDatabaseType = databaseType
|
|
}
|
|
|
|
func SetDatabaseTypes(mainType DatabaseType, logType DatabaseType) {
|
|
mainDatabaseType = mainType
|
|
logDatabaseType = logType
|
|
}
|
|
|
|
func UsingMainDatabase(databaseType DatabaseType) bool {
|
|
return mainDatabaseType == databaseType
|
|
}
|
|
|
|
func UsingLogDatabase(databaseType DatabaseType) bool {
|
|
return logDatabaseType == databaseType
|
|
}
|
|
|
|
var SQLitePath = "one-api.db?_busy_timeout=30000"
|