Exemple #1
0
        public override async ValueTask ExecuteAsync(IConsole console)
        {
            var pipeMethods = PipeCtx.PipeMethods();
            var runId       = RunId.HasValue() ? PipeRunId.FromString(RunId) : new();

            if (RunId.NullOrEmpty())
            {
                throw new CommandException($"Provide one of the following pipes to run: {pipeMethods.Join(", ", m => m.Method.Name)}");
            }
            if (!pipeMethods.ContainsKey(runId.Name))
            {
                throw new CommandException($"Pipe {runId.Name} not found. Available: {pipeMethods.Join(", ", m => m.Method.Name)}");
            }

            var log = Log.ForContext("RunId", runId);

            log.Information("Pipe Run Command Started {RunId}", RunId);
            if (runId.HasGroup)
            {
                await PipeCtx.DoPipeWork(runId, console.GetCancellationToken());
            }
            else
            {
                var res = await PipeCtx.Run(runId.Name, new() { Location = Location ?? PipeRunLocation.Local }, log : log,
                                            cancel : console.GetCancellationToken());

                if (res.Error)
                {
                    throw new CommandException(res.ErrorMessage);
                }
            }
        }
Exemple #2
0
        public async Task <IReadOnlyCollection <PipeRunMetadata> > Launch(IPipeCtx ctx, IReadOnlyCollection <PipeRunId> ids, ILogger log, CancellationToken cancel)
        {
            var res = await ids.BlockFunc(async id => {
                await ctx.DoPipeWork(id, cancel);
                var md = new PipeRunMetadata {
                    Id = id
                };
                await md.Save(ctx.Store, log);
                return(md);
            });

            return(res);
        }