Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 701013ad46 | |||
| 37358570ec | |||
| 02b9a73164 |
@@ -44,6 +44,11 @@ public partial class Operations
|
||||
receiveActivity?.SetStatus(SdkActivityStatusCode.Ok);
|
||||
return result;
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
//this is handled by the caller
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
receiveActivity?.SetStatus(SdkActivityStatusCode.Error);
|
||||
|
||||
@@ -9,6 +9,7 @@ public class MemoryServerObjectManager(ConcurrentDictionary<string, string> obje
|
||||
{
|
||||
public virtual async IAsyncEnumerable<(string, string)> DownloadObjects(
|
||||
IReadOnlyCollection<string> objectIds,
|
||||
string? attributeMask,
|
||||
IProgress<ProgressArgs>? progress,
|
||||
[EnumeratorCancellation] CancellationToken cancellationToken
|
||||
)
|
||||
|
||||
@@ -14,7 +14,8 @@ public record DeserializeProcessOptions(
|
||||
bool ThrowOnMissingReferences = true,
|
||||
bool SkipInvalidConverts = false,
|
||||
int? MaxParallelism = null,
|
||||
bool SkipServer = false
|
||||
bool SkipServer = false,
|
||||
string? AttributeMask = null
|
||||
);
|
||||
|
||||
public partial interface IDeserializeProcess : IAsyncDisposable;
|
||||
@@ -44,6 +45,7 @@ public sealed class DeserializeProcess(
|
||||
new ObjectLoader(
|
||||
sqLiteJsonCacheManager,
|
||||
serverObjectManager,
|
||||
options?.AttributeMask,
|
||||
progress,
|
||||
loggerFactory.CreateLogger<ObjectLoader>(),
|
||||
cancellationToken
|
||||
|
||||
@@ -16,6 +16,7 @@ public partial interface IObjectLoader : IDisposable;
|
||||
public sealed class ObjectLoader(
|
||||
ISqLiteJsonCacheManager sqLiteJsonCacheManager,
|
||||
IServerObjectManager serverObjectManager,
|
||||
string? attributeMask,
|
||||
IProgress<ProgressArgs>? progress,
|
||||
ILogger<ObjectLoader> logger,
|
||||
CancellationToken cancellationToken
|
||||
@@ -111,6 +112,7 @@ public sealed class ObjectLoader(
|
||||
await foreach (
|
||||
var (id, json) in serverObjectManager.DownloadObjects(
|
||||
ids.Select(x => x.NotNull()).ToList(),
|
||||
attributeMask,
|
||||
progress,
|
||||
cancellationToken
|
||||
)
|
||||
|
||||
@@ -51,6 +51,7 @@ public class ServerObjectManager : IServerObjectManager
|
||||
|
||||
public async IAsyncEnumerable<(string, string)> DownloadObjects(
|
||||
IReadOnlyCollection<string> objectIds,
|
||||
string? attributeMask,
|
||||
IProgress<ProgressArgs>? progress,
|
||||
[EnumeratorCancellation] CancellationToken cancellationToken
|
||||
)
|
||||
@@ -59,10 +60,14 @@ public class ServerObjectManager : IServerObjectManager
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
using var childrenHttpMessage = new HttpRequestMessage();
|
||||
childrenHttpMessage.RequestUri = new Uri($"/api/getobjects/{_streamId}", UriKind.Relative);
|
||||
childrenHttpMessage.RequestUri = new Uri($"/api/v2/projects/{_streamId}/object-stream/", UriKind.Relative);
|
||||
childrenHttpMessage.Method = HttpMethod.Post;
|
||||
|
||||
Dictionary<string, string> postParameters = new() { { "objects", JsonConvert.SerializeObject(objectIds) } };
|
||||
Dictionary<string, string> postParameters = new() { { "objectIds", JsonConvert.SerializeObject(objectIds) } };
|
||||
if (!string.IsNullOrWhiteSpace(attributeMask))
|
||||
{
|
||||
postParameters.Add("attributeMask", attributeMask.NotNull());
|
||||
}
|
||||
string serializedPayload = JsonConvert.SerializeObject(postParameters);
|
||||
childrenHttpMessage.Content = new StringContent(serializedPayload, Encoding.UTF8, "application/json");
|
||||
childrenHttpMessage.Headers.Add("Accept", "text/plain");
|
||||
|
||||
@@ -338,6 +338,7 @@ public class DummyServerObjectManager : IServerObjectManager
|
||||
{
|
||||
public IAsyncEnumerable<(string, string)> DownloadObjects(
|
||||
IReadOnlyCollection<string> objectIds,
|
||||
string? attributeMask,
|
||||
IProgress<ProgressArgs>? progress,
|
||||
CancellationToken cancellationToken
|
||||
) => throw new NotImplementedException();
|
||||
|
||||
@@ -112,6 +112,7 @@ public class ExceptionTests
|
||||
new DummySqLiteReceiveManager(new Dictionary<string, string>()),
|
||||
new ExceptionServerObjectManager(),
|
||||
null,
|
||||
null,
|
||||
new NullLogger<ObjectLoader>(),
|
||||
default
|
||||
);
|
||||
|
||||
@@ -8,6 +8,7 @@ public class ExceptionServerObjectManager : IServerObjectManager
|
||||
{
|
||||
public IAsyncEnumerable<(string, string)> DownloadObjects(
|
||||
IReadOnlyCollection<string> objectIds,
|
||||
string? attributeMask,
|
||||
IProgress<ProgressArgs>? progress,
|
||||
CancellationToken cancellationToken
|
||||
) => throw new NotImplementedException();
|
||||
|
||||
@@ -204,6 +204,7 @@ public class SerializationTests
|
||||
new DummySqLiteReceiveManager(closures),
|
||||
new DummyReceiveServerObjectManager(closures),
|
||||
null,
|
||||
null,
|
||||
new NullLogger<ObjectLoader>(),
|
||||
default
|
||||
)
|
||||
|
||||
@@ -33,12 +33,12 @@ public class ServerObjectManagerTests : MoqTest
|
||||
var mockHttp = new MockHttpMessageHandler();
|
||||
Dictionary<string, string> postParameters = new()
|
||||
{
|
||||
{ "objects", JsonConvert.SerializeObject(new List<string> { id, id2 }) },
|
||||
{ "objectIds", JsonConvert.SerializeObject(new List<string> { id, id2 }) },
|
||||
};
|
||||
|
||||
string serializedPayload = JsonConvert.SerializeObject(postParameters);
|
||||
mockHttp
|
||||
.When(HttpMethod.Post, $"http://localhost/api/getobjects/{streamId}")
|
||||
.When(HttpMethod.Post, $"http://localhost/api/v2/projects/{streamId}/object-stream/")
|
||||
.WithContent(serializedPayload)
|
||||
.Respond(
|
||||
"application/json",
|
||||
@@ -59,7 +59,7 @@ public class ServerObjectManagerTests : MoqTest
|
||||
token,
|
||||
new(timeout: TimeSpan.FromSeconds(timeout))
|
||||
);
|
||||
var results = serverObjectManager.DownloadObjects(new List<string> { id, id2 }, null, ct);
|
||||
var results = serverObjectManager.DownloadObjects(new List<string> { id, id2 }, null, null, ct);
|
||||
var objects = new JObject();
|
||||
await foreach (var (x, json) in results)
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@ public class DummyReceiveServerObjectManager(IReadOnlyDictionary<string, string>
|
||||
{
|
||||
public async IAsyncEnumerable<(string, string)> DownloadObjects(
|
||||
IReadOnlyCollection<string> objectIds,
|
||||
string? attributeMask,
|
||||
IProgress<ProgressArgs>? progress,
|
||||
[EnumeratorCancellation] CancellationToken cancellationToken
|
||||
)
|
||||
|
||||
@@ -9,6 +9,7 @@ public class DummySendServerObjectManager(ConcurrentDictionary<string, string> s
|
||||
{
|
||||
public IAsyncEnumerable<(string, string)> DownloadObjects(
|
||||
IReadOnlyCollection<string> objectIds,
|
||||
string? attributeMask,
|
||||
IProgress<ProgressArgs>? progress,
|
||||
CancellationToken cancellationToken
|
||||
) => throw new NotImplementedException();
|
||||
|
||||
Reference in New Issue
Block a user