Add logging for deserialization
This commit is contained in:
@@ -26,7 +26,6 @@ class Program
|
||||
builder.Services.AddOptions();
|
||||
var listening = new IPEndPoint(IPAddress.Any, 4567);
|
||||
builder.Services.Configure<GatewayOptions>(options => options.Endpoint = listening);
|
||||
builder.Services.Configure<DistributionOptions>(o => o.DistributionType = EDistributionType.ExtractorFirst);
|
||||
builder.Services.AddSingleton<IDistributionModule, ExtractorFirstDistributionModule>();
|
||||
|
||||
builder.Services.AddSingleton<HubRequestExtractor>();
|
||||
|
||||
@@ -88,10 +88,19 @@ namespace mROA.Cbor
|
||||
}
|
||||
|
||||
public object? Deserialize(ReadOnlyMemory<byte> rawMemory, Type type, IEndPointContext? context)
|
||||
{
|
||||
try
|
||||
{
|
||||
var reader = new CborReader(rawMemory);
|
||||
return ReadData(reader, type, context);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine($"Bad deserialization. Bytes: {rawMemory.ToArray().Select(b => $"{b:X}")}");
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public T Cast<T>(object nonCasted, IEndPointContext? context)
|
||||
{
|
||||
|
||||
@@ -10,18 +10,17 @@ namespace mROA.Implementation.Backend
|
||||
private readonly IRealStoreInstanceRepository _contextRepository;
|
||||
private readonly IInstanceRepository _remoteContextRepository;
|
||||
private readonly IExecuteModule _executeModule;
|
||||
private readonly IDistributionModule _distribution;
|
||||
private readonly DistributionOptions _mode;
|
||||
private readonly Dictionary<int, IRequestExtractor> _producedExtractors = new();
|
||||
|
||||
public HubRequestExtractor(IRealStoreInstanceRepository contextRepository,
|
||||
IInstanceRepository remoteContextRepository, IExecuteModule executeModule,
|
||||
IDistributionModule distribution)
|
||||
IOptions<DistributionOptions> mode)
|
||||
{
|
||||
_contextRepository = contextRepository;
|
||||
_remoteContextRepository = remoteContextRepository;
|
||||
_executeModule = executeModule;
|
||||
_distribution = distribution;
|
||||
|
||||
_mode = mode.Value;
|
||||
}
|
||||
|
||||
public IRequestExtractor this[int id] => _producedExtractors[id];
|
||||
@@ -29,7 +28,7 @@ namespace mROA.Implementation.Backend
|
||||
public IRequestExtractor HubOnOnConnected(IRepresentationModule representationModule)
|
||||
{
|
||||
var extractor = CreateExtractor(representationModule);
|
||||
if (_distribution is ChannelDistributionModule)
|
||||
if (_mode.DistributionType == EDistributionType.Channeled)
|
||||
{
|
||||
extractor.StartExtraction().ContinueWith(_ => OnDisconnected(representationModule));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace mROA.Implementation
|
||||
{
|
||||
public class DistributionOptions
|
||||
{
|
||||
public EDistributionType DistributionType { get; set; }
|
||||
}
|
||||
|
||||
public enum EDistributionType
|
||||
{
|
||||
Channeled,
|
||||
ExtractorFirst
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user