From c5e447308d4991f95364b875d4d553d3b89c0918 Mon Sep 17 00:00:00 2001 From: Inga Lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Wed, 12 Jul 2017 17:20:20 +0300 Subject: [PATCH] Contracts updated; IBackupEngine added --- EternalArrowBackup.sln | 2 +- .../MainBackupEngine/IBackupEngine.cs | 10 +++++++++ .../MainBackupEngine/IBackupReport.cs | 17 ++++++++++++++ .../SourceStorage/ISourceDirectory.cs | 3 ++- .../Contracts/SourceStorage/ISourceStorage.cs | 3 ++- .../TargetStorage/ITargetDirectory.cs | 22 ++++++++++++++++--- .../ITargetStorageForRecovery.cs | 3 ++- 7 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 Source/Contracts/MainBackupEngine/IBackupEngine.cs create mode 100644 Source/Contracts/MainBackupEngine/IBackupReport.cs diff --git a/EternalArrowBackup.sln b/EternalArrowBackup.sln index 270b060..492fbf7 100644 --- a/EternalArrowBackup.sln +++ b/EternalArrowBackup.sln @@ -5,7 +5,7 @@ VisualStudioVersion = 15.0.26430.14 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{A79A4872-4289-4429-B616-3E8CEC71ECB8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EternalArrowBackup.Contracts", "Source\Contracts\EternalArrowBackup.Contracts.csproj", "{9A363462-23E2-49FB-A65C-7B1CA1400046}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EternalArrowBackup.Contracts", "Source\Contracts\EternalArrowBackup.Contracts.csproj", "{9A363462-23E2-49FB-A65C-7B1CA1400046}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Source/Contracts/MainBackupEngine/IBackupEngine.cs b/Source/Contracts/MainBackupEngine/IBackupEngine.cs new file mode 100644 index 0000000..ce75db0 --- /dev/null +++ b/Source/Contracts/MainBackupEngine/IBackupEngine.cs @@ -0,0 +1,10 @@ +namespace EternalArrowBackup.Contracts.BackupEngine +{ + using System.Threading; + using System.Threading.Tasks; + + public interface IBackupEngine + { + Task BackupAll(CancellationToken ct); + } +} diff --git a/Source/Contracts/MainBackupEngine/IBackupReport.cs b/Source/Contracts/MainBackupEngine/IBackupReport.cs new file mode 100644 index 0000000..84ccef0 --- /dev/null +++ b/Source/Contracts/MainBackupEngine/IBackupReport.cs @@ -0,0 +1,17 @@ +using System; + +namespace EternalArrowBackup.Contracts.BackupEngine +{ + public class IBackupReport + { + public long FilesUploaded { get; } + + public long BytesUploaded { get; } + + public long FilesUpdated { get; } + + public long FilesProcessed { get; } + + public Exception[] Errors { get; } + } +} diff --git a/Source/Contracts/SourceStorage/ISourceDirectory.cs b/Source/Contracts/SourceStorage/ISourceDirectory.cs index c109d7f..ff04ba3 100644 --- a/Source/Contracts/SourceStorage/ISourceDirectory.cs +++ b/Source/Contracts/SourceStorage/ISourceDirectory.cs @@ -1,6 +1,7 @@ namespace EternalArrowBackup.Contracts.SourceStorage { using System; + using System.Threading; using System.Threading.Tasks; public interface ISourceDirectory @@ -9,6 +10,6 @@ Task GetFile(string filename); - IObservable GetAllFiles(); + IObservable GetAllFiles(CancellationToken ct); } } diff --git a/Source/Contracts/SourceStorage/ISourceStorage.cs b/Source/Contracts/SourceStorage/ISourceStorage.cs index 009d5d6..41f4b87 100644 --- a/Source/Contracts/SourceStorage/ISourceStorage.cs +++ b/Source/Contracts/SourceStorage/ISourceStorage.cs @@ -1,12 +1,13 @@ namespace EternalArrowBackup.Contracts.SourceStorage { using System; + using System.Threading; using System.Threading.Tasks; public interface ISourceStorage { Task GetDirectory(string normalizedRelativePath); - IObservable GetAllDirectories(); + IObservable GetAllDirectories(CancellationToken ct); } } diff --git a/Source/Contracts/TargetStorage/ITargetDirectory.cs b/Source/Contracts/TargetStorage/ITargetDirectory.cs index 0a0151f..eb66b82 100644 --- a/Source/Contracts/TargetStorage/ITargetDirectory.cs +++ b/Source/Contracts/TargetStorage/ITargetDirectory.cs @@ -1,14 +1,30 @@ namespace EternalArrowBackup.Contracts.TargetStorage { using System; + using System.Threading; using System.Threading.Tasks; public interface ITargetDirectory { - Task UploadFile(string filename, byte[] content, string hash); + /// + /// Uploads new content to the target directory, and adds new entity with DateTime.UtcNow to the list of files + /// + /// File name + /// Content + /// File hash + /// Task + Task UploadNewContent(string filename, byte[] content, string hash); - Task GetFile(string filename, string hash); + /// + /// Adds new entity with DateTime.UtcNow to the list of files. + /// + /// Example: file "abc.txt" with content "qwe" (v1) was replaced with "rty" (v2), and then was replaced with "qwe" (v3) again. + /// The client should for v1 and v2, and then call this method (passing v1 FileInfo to it) for v3. + /// + /// + /// + Task UpdateExistingContent(ITargetFile file); - IObservable GetAllFiles(); + IObservable GetAllFiles(CancellationToken ct); } } diff --git a/Source/Contracts/TargetStorage/ITargetStorageForRecovery.cs b/Source/Contracts/TargetStorage/ITargetStorageForRecovery.cs index 61afcee..36b51b1 100644 --- a/Source/Contracts/TargetStorage/ITargetStorageForRecovery.cs +++ b/Source/Contracts/TargetStorage/ITargetStorageForRecovery.cs @@ -1,9 +1,10 @@ namespace EternalArrowBackup.Contracts.TargetStorage { using System; + using System.Threading; public interface ITargetStorageForRecovery { - IObservable GetAllDirectories(); + IObservable GetAllDirectories(CancellationToken ct); } }