Beispiel #1
0
 public static IScheduledActionsBuilder Schedule(
     [NotNull] this IScheduledActionsBuilder builder,
     [NotNull] string name,
     [NotNull] IScheduler scheduler,
     [NotNull] Func <Task> payload,
     [NotNull] ScheduledActionOptions options)
 => builder.Schedule(name, scheduler, _ => payload(), options);
Beispiel #2
0
        private ScheduledAction ConfigureActualizationAction(ScheduledActionsDynamicOptions options)
        {
            var scheduler = Scheduler.Periodical(options.ActualizationPeriod, false);

            var actionOptions = new ScheduledActionOptions();

            return(new ScheduledAction(
                       "ActualizeScheduledActionsSet",
                       scheduler,
                       actionOptions,
                       async context =>
            {
                var builder = new ScheduledActionsBuilder(log, tracer, diagnostics)
                {
                    SupportsDynamicConfiguration = false,
                    ShouldLogScheduledActions = false
                };

                foreach (var action in staticActions)
                {
                    builder.Schedule(action);
                }

                await options.Configuration(builder, context.CancellationToken);

                Actualize(builder.Actions, context.CancellationToken);
            }));
        }
 public static IScheduledActionsBuilder Schedule <TArg>(
     [NotNull] this IScheduledActionsBuilder builder,
     [NotNull] string name,
     [NotNull] IScheduler scheduler,
     [NotNull] Func <TArg, IScheduledActionContext, Task> payload,
     [NotNull] ScheduledActionOptions options)
 => builder.Schedule(name, scheduler, context => payload(ExtractArgumentFromOnDemandScheduler <TArg>(scheduler), context), options);
 public static IScheduledActionsBuilder Schedule <TArg>(
     [NotNull] this IScheduledActionsBuilder builder,
     [NotNull] string name,
     [NotNull] IScheduler scheduler,
     [NotNull] Action <TArg> payload,
     [NotNull] ScheduledActionOptions options)
 => builder.Schedule(name, scheduler, _ => payload(ExtractArgumentFromOnDemandScheduler <TArg>(scheduler)), options);
        public IScheduledActionsBuilder Schedule(string name, IScheduler scheduler, Func <IScheduledActionContext, Task> payload, ScheduledActionOptions options)
        {
            actions.Add(new ScheduledAction(name, scheduler, options, payload));

            log.Info("Scheduled '{ActionName}' action with scheduler '{Scheduler}'. ", name, scheduler.GetType().Name);

            return(this);
        }
 public IScheduledActionsBuilder Schedule(string name, IScheduler scheduler, Action <IScheduledActionContext> payload, ScheduledActionOptions options)
 => Schedule(name, scheduler, WrapAction(payload), options);
 public ScheduledAction([NotNull] string name, [NotNull] IScheduler scheduler, [NotNull] ScheduledActionOptions options, [NotNull] Func <IScheduledActionContext, Task> payload)
 {
     Scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler));
     Options   = options ?? throw new ArgumentNullException(nameof(options));
     Payload   = payload ?? throw new ArgumentNullException(nameof(payload));
     Name      = name ?? throw new ArgumentNullException(nameof(name));
 }
 public IScheduledActionsBuilder Schedule(string name, IScheduler scheduler, Func <IScheduledActionContext, Task> payload, ScheduledActionOptions options)
 => Schedule(new ScheduledAction(name, scheduler, options, payload));