@@ -98,23 +98,6 @@ public class DiskTransport : ICloneable, ITransport
|
||||
Elapsed += stopwatch.Elapsed;
|
||||
}
|
||||
|
||||
public void SaveObject(string id, ITransport sourceTransport)
|
||||
{
|
||||
CancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var serializedObject = sourceTransport.GetObject(id);
|
||||
|
||||
if (serializedObject is null)
|
||||
{
|
||||
throw new TransportException(
|
||||
this,
|
||||
$"Cannot copy {id} from {sourceTransport.TransportName} to {TransportName} as source returned null"
|
||||
);
|
||||
}
|
||||
|
||||
SaveObject(id, serializedObject);
|
||||
}
|
||||
|
||||
public Task WriteComplete()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
|
||||
@@ -56,16 +56,6 @@ public interface ITransport
|
||||
/// <exception cref="OperationCanceledException"><see cref="CancellationToken"/> requested cancel</exception>
|
||||
public void SaveObject(string id, string serializedObject);
|
||||
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="SaveObject(string, string)"/>
|
||||
/// Retrieving its serialised version from the provided transport.
|
||||
/// </summary>
|
||||
/// <param name="id"><inheritdoc cref="SaveObject(string, string)"/></param>
|
||||
/// <param name="sourceTransport">The transport from where to retrieve it.</param>
|
||||
/// <exception cref="TransportException">Failed to save object</exception>
|
||||
/// <exception cref="OperationCanceledException"><see cref="CancellationToken"/> requested cancel</exception>
|
||||
public void SaveObject(string id, ITransport sourceTransport);
|
||||
|
||||
/// <summary>
|
||||
/// Awaitable method to figure out whether writing is completed.
|
||||
/// </summary>
|
||||
|
||||
@@ -63,23 +63,6 @@ public sealed class MemoryTransport : ITransport, ICloneable
|
||||
Elapsed += stopwatch.Elapsed;
|
||||
}
|
||||
|
||||
public void SaveObject(string id, ITransport sourceTransport)
|
||||
{
|
||||
CancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var serializedObject = sourceTransport.GetObject(id);
|
||||
|
||||
if (serializedObject is null)
|
||||
{
|
||||
throw new TransportException(
|
||||
this,
|
||||
$"Cannot copy {id} from {sourceTransport.TransportName} to {TransportName} as source returned null"
|
||||
);
|
||||
}
|
||||
|
||||
SaveObject(id, serializedObject);
|
||||
}
|
||||
|
||||
public string? GetObject(string id)
|
||||
{
|
||||
var stopwatch = Stopwatch.StartNew();
|
||||
|
||||
@@ -370,24 +370,6 @@ public sealed class SQLiteTransport : IDisposable, ICloneable, ITransport, IBlob
|
||||
_writeTimer.Start();
|
||||
}
|
||||
|
||||
public void SaveObject(string id, ITransport sourceTransport)
|
||||
{
|
||||
CancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var serializedObject = sourceTransport.GetObject(id);
|
||||
|
||||
if (serializedObject is null)
|
||||
{
|
||||
throw new TransportException(
|
||||
this,
|
||||
$"Cannot copy {id} from {sourceTransport.TransportName} to {TransportName} as source returned null"
|
||||
);
|
||||
}
|
||||
|
||||
//Should this just call SaveObject... do we not want the write timers?
|
||||
_queue.Enqueue((id, serializedObject, Encoding.UTF8.GetByteCount(serializedObject)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Directly saves the object in the db.
|
||||
/// </summary>
|
||||
|
||||
@@ -224,21 +224,6 @@ public sealed class ServerTransport : IServerTransport
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveObject(string id, ITransport sourceTransport)
|
||||
{
|
||||
var objectData = sourceTransport.GetObject(id);
|
||||
|
||||
if (objectData is null)
|
||||
{
|
||||
throw new TransportException(
|
||||
this,
|
||||
$"Cannot copy {id} from {sourceTransport.TransportName} to {TransportName} as source returned null"
|
||||
);
|
||||
}
|
||||
|
||||
SaveObject(id, objectData);
|
||||
}
|
||||
|
||||
public void BeginWrite()
|
||||
{
|
||||
if (_shouldSendThreadRun || _sendingThread != null)
|
||||
|
||||
@@ -30,8 +30,6 @@ public class TestTransport : ITransport
|
||||
|
||||
public void SaveObject(string id, string serializedObject) => Objects[id] = serializedObject;
|
||||
|
||||
public void SaveObject(string id, ITransport sourceTransport) => throw new NotImplementedException();
|
||||
|
||||
public Task WriteComplete() => throw new NotImplementedException();
|
||||
|
||||
public string? GetObject(string id) => Objects.TryGetValue(id, out string? o) ? o : null;
|
||||
|
||||
@@ -93,13 +93,6 @@ public abstract class TransportTests
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SaveObject_FromTransport_FailsPredictably()
|
||||
{
|
||||
var exception = Assert.Throws<TransportException>(() => Sut.NotNull().SaveObject("non-existent-id", Sut));
|
||||
Assert.That(exception?.Transport, Is.EqualTo(Sut));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ProgressAction_Called_OnSaveObject()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user