feat: support ClickHouse log database (#5663)
* feat: support ClickHouse log database * feat(log): optimize log deletion process for ClickHouse
This commit is contained in:
+37
-8
@@ -1,15 +1,44 @@
|
||||
package common
|
||||
|
||||
type DatabaseType string
|
||||
|
||||
const (
|
||||
DatabaseTypeMySQL = "mysql"
|
||||
DatabaseTypeSQLite = "sqlite"
|
||||
DatabaseTypePostgreSQL = "postgres"
|
||||
DatabaseTypeMySQL DatabaseType = "mysql"
|
||||
DatabaseTypeSQLite DatabaseType = "sqlite"
|
||||
DatabaseTypePostgreSQL DatabaseType = "postgres"
|
||||
DatabaseTypeClickHouse DatabaseType = "clickhouse"
|
||||
)
|
||||
|
||||
var UsingSQLite = false
|
||||
var UsingPostgreSQL = false
|
||||
var LogSqlType = DatabaseTypeSQLite // Default to SQLite for logging SQL queries
|
||||
var UsingMySQL = false
|
||||
var UsingClickHouse = false
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user