整理代码
This commit is contained in:
parent
fcc0de5b2a
commit
a169eecec5
@ -45,17 +45,28 @@ public class TransformService : ITransformService
|
||||
if (!producerQueue.TryDequeue(out var record)) continue;
|
||||
|
||||
//过滤不要的record
|
||||
if (await _options.Value.RecordFilter?.Invoke(record, _cache) == false) continue;
|
||||
|
||||
if (_options.Value.RecordFilter != null)
|
||||
{
|
||||
var result = await _options.Value.RecordFilter.Invoke(record, _cache);
|
||||
if (result == false) continue;
|
||||
}
|
||||
record.Database = _options.Value.DatabaseFilter?.Invoke(record);
|
||||
//修改record
|
||||
_options.Value.RecordModify?.Invoke(record);
|
||||
//缓存record
|
||||
await _options.Value.RecordCache?.Invoke(record, _cache);
|
||||
//替换record
|
||||
var replaceRecord = await _options.Value.RecordReplace?.Invoke(record, _cache);
|
||||
if (replaceRecord != null)
|
||||
if (_options.Value.RecordCache != null)
|
||||
{
|
||||
record = replaceRecord;
|
||||
await _options.Value.RecordCache.Invoke(record, _cache);
|
||||
}
|
||||
//替换record
|
||||
if (_options.Value.RecordReplace != null)
|
||||
{
|
||||
var result = await _options.Value.RecordReplace.Invoke(record, _cache);
|
||||
if (result != null)
|
||||
{
|
||||
record = result;
|
||||
}
|
||||
}
|
||||
consumerQueue.Enqueue(record);
|
||||
_context.AddTransform();
|
||||
|
@ -445,7 +445,7 @@ async Task RunProgram()
|
||||
|
||||
host.Services.AddHostedService<MainHostedService>();
|
||||
host.Services.AddHostedService<TaskMonitorService>();
|
||||
if(commandOptions.IsMock)host.Services.AddSingleton<IInputService,SimulationInputService>();
|
||||
if(commandOptions.IsMock)host.Services.AddSingleton<IInputService,InputService>();
|
||||
else host.Services.AddSingleton<IInputService, InputService>();
|
||||
host.Services.AddSingleton<ITransformService, TransformService>();
|
||||
host.Services.AddSingleton<IOutputService, OutputService>();
|
||||
|
Loading…
Reference in New Issue
Block a user