public async Task TestGraphRunner() { var ctx = await TestSetup.TextCtx();; var res = await TaskGraph.FromMethods( (l, c) => Shorten(l), (l, c) => Generate(l, true), (l, c) => NotDependent(l)) .Run(parallel: 2, ctx.Log, CancellationToken.None); var resByName = res.ToKeyedCollection(r => r.Name); resByName[nameof(Generate)].FinalStatus.Should().Be(GraphTaskStatus.Error); resByName[nameof(Shorten)].FinalStatus.Should().Be(GraphTaskStatus.Cancelled); resByName[nameof(NotDependent)].FinalStatus.Should().Be(GraphTaskStatus.Success); ctx.Log.Information("Res {Res}, Shortened {Values}", res.Join("\n"), shortened); }
public async Task Run(IReadOnlyCollection <string> include, ILogger log, CancellationToken cancel = default) { var taskGraph = TaskGraph.FromMethods((l, c) => TopVideos(l), (l, c) => TopChannelVideos(l), (l, c) => ChannelStats(l)); taskGraph.IgnoreNotIncluded(include); var(res, dur) = await taskGraph.Run(parallel : 4, log, cancel).WithDuration(); var errors = res.Where(r => r.Error).ToArray(); if (errors.Any()) { Log.Error("Index - failed in {Duration}: {@TaskResults}", dur.HumanizeShort(), res.Join("\n")); } else { Log.Information("Index - completed in {Duration}: {TaskResults}", dur.HumanizeShort(), res.Join("\n")); } }
public async Task TestGraphRunner() { using var log = Setup.CreateTestLogger(); log.Information("hey there"); var res = await TaskGraph.FromMethods( c => Shorten(log), c => Generate(log, true), c => NotDependent(log)) .Run(parallel: 2, log, CancellationToken.None); var resByName = res.ToKeyedCollection(r => r.Name); resByName[nameof(Generate)].FinalStatus.Should().Be(GraphTaskStatus.Error); resByName[nameof(Shorten)].FinalStatus.Should().Be(GraphTaskStatus.Cancelled); resByName[nameof(NotDependent)].FinalStatus.Should().Be(GraphTaskStatus.Success); log.Information("Res {Res}, Shortened {Values}", res.Join("\n"), shortened); }