Exemplo n.º 1
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 void SetupDynamic(Func <IScheduledActionsBuilder, CancellationToken, Task> configuration, TimeSpan actualizationPeriod)
        {
            if (!SupportsDynamicConfiguration)
            {
                throw new InvalidOperationException("Dynamic configuration mode is not supported by this builder.");
            }

            if (dynamicOptions != null)
            {
                throw new InvalidOperationException("Can't overwrite existing dynamic configuration.");
            }

            dynamicOptions = new ScheduledActionsDynamicOptions(configuration, actualizationPeriod);
        }
Exemplo n.º 3
0
        public ScheduledActionsDynamicRunner(
            IReadOnlyList <ScheduledAction> staticActions,
            IVostokApplicationDiagnostics diagnostics,
            ITracer tracer,
            ILog log,
            ScheduledActionsDynamicOptions options)
        {
            this.staticActions = staticActions;
            this.diagnostics   = diagnostics;
            this.tracer        = tracer;
            this.log           = log;

            actualizationRunner = new ScheduledActionRunner(ConfigureActualizationAction(options), log, tracer, diagnostics);
            userRunners         = new ConcurrentDictionary <string, UserActionRunner>();
        }