45 lines
1.2 KiB
C#
45 lines
1.2 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 InputPipeline1 : FileSystemWatchablePipelineBase
|
|
{
|
|
private readonly ReadFiles readFiles;
|
|
|
|
public InputPipeline1(ILogger logger, IFileSystem fileSystem, ReadFiles readFiles)
|
|
: base(logger, fileSystem)
|
|
{
|
|
this.readFiles = readFiles.WithPattern("/input/input1/*.txt");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override UPath WatchPath => "/input/input1";
|
|
|
|
/// <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();
|
|
}
|
|
}
|