Implemented SQL Interface

This commit is contained in:
netbenix 2021-11-22 21:28:18 +01:00
parent c80c353b6f
commit 8a5b82af83
4 changed files with 52 additions and 0 deletions

10
SQL/LogTypes.go Normal file
View file

@ -0,0 +1,10 @@
package SQL
type LogType int64
const(
LogInfo LogType = 1
LogWarning = 2
LogError = 3
LogFatal = 4
)

9
SQL/RemoteStorage.go Normal file
View file

@ -0,0 +1,9 @@
package SQL
type RemoteStorageType int64
const(
REMOTE_AZURE_FILE = 1
REMOTE_AZURE_BLOB = 2
REMOTE_NONE = 3
)

24
SQL/SQLInterface.go Normal file
View file

@ -0,0 +1,24 @@
package SQL
import (
"github.com/google/uuid"
"time"
)
type SQLService interface {
createDefaultTables()
newLogEntry(uuid uuid.UUID, logType LogType, backupName string, stage SQLStage, storageType RemoteStorageType, description string, timestamp time.Time)
newBackupEntry(uuid uuid.UUID, backupName string, lastBackup time.Time, localBackup bool, filePath string, storageType RemoteStorageType, remotePath string, durationToBackup time.Duration, hadErrors bool)
}
func CreateDefaultTables(sqlService SQLService){
sqlService.createDefaultTables()
}
func NewLogEntry(sqlService SQLService, uuid uuid.UUID, logType LogType, backupName string, stage SQLStage, storageType RemoteStorageType, description string, timestamp time.Time){
sqlService.newLogEntry(uuid, logType, backupName, stage, storageType, description, timestamp)
}
func NewBackupEntry(sqlService SQLService, uuid uuid.UUID, backupName string, lastBackup time.Time, localBackup bool, filePath string, storageType RemoteStorageType, remotePath string, durationToBackup time.Duration, hadErrors bool){
sqlService.newBackupEntry(uuid, backupName, lastBackup, localBackup, filePath, storageType, remotePath, durationToBackup, hadErrors)
}

9
SQL/SQLStages.go Normal file
View file

@ -0,0 +1,9 @@
package SQL
type SQLStage int64
const(
SQLStage_Compress = 1
SQLStage_Upload = 2
SQLStage_DeleteTmp = 3
)