48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using MfGames.Gallium;
|
|
using MfGames.Nitride.IO;
|
|
using MfGames.Nitride.IO.Contents;
|
|
using Serilog;
|
|
using Zio;
|
|
|
|
namespace NitridePipelines.Pipelines;
|
|
|
|
public class InputPipeline2 : FileSystemWatchablePipelineBase
|
|
{
|
|
private readonly ILogger logger;
|
|
|
|
private readonly ReadFiles readFiles;
|
|
|
|
public InputPipeline2(ILogger logger, IFileSystem fileSystem, ReadFiles readFiles)
|
|
: base(logger, fileSystem)
|
|
{
|
|
this.logger = logger.ForContext<InputPipeline2>();
|
|
this.readFiles = readFiles.WithPattern("/input/input2/*.txt");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override UPath WatchPath => "/input/input2";
|
|
|
|
/// <inheritdoc />
|
|
public override IAsyncEnumerable<Entity> RunAsync(
|
|
IEnumerable<Entity> _,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
IEnumerable<Entity> entities = this.readFiles.Run()
|
|
.Select(entity =>
|
|
{
|
|
Task.Delay(1000, cancellationToken).Wait(cancellationToken);
|
|
|
|
this.logger.Information("Read {Value}", entity.Get<UPath>());
|
|
|
|
return entity;
|
|
});
|
|
|
|
return entities.ToAsyncEnumerable();
|
|
}
|
|
}
|