From 8a5b82af838e645a1a739e7a3ad518395132e208 Mon Sep 17 00:00:00 2001 From: netbenix Date: Mon, 22 Nov 2021 21:28:18 +0100 Subject: [PATCH] Implemented SQL Interface --- SQL/LogTypes.go | 10 ++++++++++ SQL/RemoteStorage.go | 9 +++++++++ SQL/SQLInterface.go | 24 ++++++++++++++++++++++++ SQL/SQLStages.go | 9 +++++++++ 4 files changed, 52 insertions(+) create mode 100644 SQL/LogTypes.go create mode 100644 SQL/RemoteStorage.go create mode 100644 SQL/SQLInterface.go create mode 100644 SQL/SQLStages.go diff --git a/SQL/LogTypes.go b/SQL/LogTypes.go new file mode 100644 index 0000000..16f2ea0 --- /dev/null +++ b/SQL/LogTypes.go @@ -0,0 +1,10 @@ +package SQL + +type LogType int64 + +const( + LogInfo LogType = 1 + LogWarning = 2 + LogError = 3 + LogFatal = 4 +) diff --git a/SQL/RemoteStorage.go b/SQL/RemoteStorage.go new file mode 100644 index 0000000..dd835c0 --- /dev/null +++ b/SQL/RemoteStorage.go @@ -0,0 +1,9 @@ +package SQL + +type RemoteStorageType int64 + +const( + REMOTE_AZURE_FILE = 1 + REMOTE_AZURE_BLOB = 2 + REMOTE_NONE = 3 +) \ No newline at end of file diff --git a/SQL/SQLInterface.go b/SQL/SQLInterface.go new file mode 100644 index 0000000..79f69ee --- /dev/null +++ b/SQL/SQLInterface.go @@ -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) +} \ No newline at end of file diff --git a/SQL/SQLStages.go b/SQL/SQLStages.go new file mode 100644 index 0000000..36c7441 --- /dev/null +++ b/SQL/SQLStages.go @@ -0,0 +1,9 @@ +package SQL + +type SQLStage int64 + +const( + SQLStage_Compress = 1 + SQLStage_Upload = 2 + SQLStage_DeleteTmp = 3 +)