Exemplo n.º 1
0
        private Assembly[] ParseExecutorAssembliesFromConfig(StakhanoviseSetupDefaultsConfig defaultsConfig)
        {
            Assembly[] assemblies = null;

            if (defaultsConfig.ExecutorAssemblies != null && defaultsConfig.ExecutorAssemblies.Count > 0)
            {
                assemblies = new Assembly[defaultsConfig.ExecutorAssemblies.Count];
                for (int i = 0; i < defaultsConfig.ExecutorAssemblies.Count; i++)
                {
                    assemblies[i] = Assembly.LoadFrom(defaultsConfig.ExecutorAssemblies[i]);
                }
            }

            return(assemblies);
        }
Exemplo n.º 2
0
        private QueuedTaskMapping GetQueudTaskMappingFromDefaultsConfig(StakhanoviseSetupDefaultsConfig defaultsConfig)
        {
            QueuedTaskMapping mapping = new QueuedTaskMapping();

            if (defaultsConfig.Mapping != null)
            {
                mapping = new QueuedTaskMapping();
                mapping.DequeueFunctionName            = defaultsConfig.Mapping.DequeueFunctionName;
                mapping.ExecutionTimeStatsTableName    = defaultsConfig.Mapping.ExecutionTimeStatsTableName;
                mapping.MetricsTableName               = defaultsConfig.Mapping.MetricsTableName;
                mapping.NewTaskNotificationChannelName = defaultsConfig.Mapping.NewTaskNotificationChannelName;
                mapping.QueueTableName        = defaultsConfig.Mapping.QueueTableName;
                mapping.ResultsQueueTableName = defaultsConfig.Mapping.ResultsQueueTableName;
            }

            return(mapping);
        }
Exemplo n.º 3
0
        public StakhanoviseSetupDefaults GetDefaults()
        {
            IConfiguration config = GetConfig();

            IConfigurationSection section = config
                                            .GetSection(mConfigSectionName);

            StakhanoviseSetupDefaults defaults = mFallbackDefaultsProvider
                                                 .GetDefaults();

            if (section != null)
            {
                StakhanoviseSetupDefaultsConfig defaultsConfig = section.Get <StakhanoviseSetupDefaultsConfig>();
                if (defaultsConfig != null)
                {
                    defaults = MergeDefaultsFromConfig(defaults,
                                                       defaultsConfig,
                                                       config);
                }
            }

            return(defaults);
        }
Exemplo n.º 4
0
 private Func <IQueuedTask, Exception, bool> CompileIsTaskErrorRecoverableFnFromConfig(StakhanoviseSetupDefaultsConfig defaultsConfig,
                                                                                       ScriptOptions parseOptions)
 {
     if (!string.IsNullOrEmpty(defaultsConfig.IsTaskErrorRecoverable))
     {
         return(CSharpScript.EvaluateAsync <Func <IQueuedTask, Exception, bool> >(defaultsConfig.IsTaskErrorRecoverable,
                                                                                  options: parseOptions)
                .Result);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 5
0
 private Func <IQueuedTaskToken, long> CompileCalculateDelayTicksTaskAfterFailureFnFromConfig(StakhanoviseSetupDefaultsConfig defaultsConfig,
                                                                                              ScriptOptions parseOptions)
 {
     if (!string.IsNullOrEmpty(defaultsConfig.CalculateDelayTicksTaskAfterFailure))
     {
         return(CSharpScript.EvaluateAsync <Func <IQueuedTaskToken, long> >(defaultsConfig.CalculateDelayTicksTaskAfterFailure,
                                                                            options: parseOptions)
                .Result);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 6
0
        private StakhanoviseSetupDefaults MergeDefaultsFromConfig(StakhanoviseSetupDefaults targetDefaults,
                                                                  StakhanoviseSetupDefaultsConfig defaultsConfig,
                                                                  IConfiguration config)
        {
            ScriptOptions parseOptions = ConstructParseOptions();

            Assembly[] executorAssemblies = ParseExecutorAssembliesFromConfig(defaultsConfig);
            if (executorAssemblies != null)
            {
                targetDefaults.ExecutorAssemblies = executorAssemblies;
            }

            Func <IQueuedTaskToken, long> calculateDelayTicksTaskAfterFailureFn =
                CompileCalculateDelayTicksTaskAfterFailureFnFromConfig(defaultsConfig, parseOptions);

            if (calculateDelayTicksTaskAfterFailureFn != null)
            {
                targetDefaults.CalculateDelayMillisecondsTaskAfterFailure = calculateDelayTicksTaskAfterFailureFn;
            }

            Func <IQueuedTask, Exception, bool> isTaskErrorRecoverableFn =
                CompileIsTaskErrorRecoverableFnFromConfig(defaultsConfig, parseOptions);

            if (isTaskErrorRecoverableFn != null)
            {
                targetDefaults.IsTaskErrorRecoverable = isTaskErrorRecoverableFn;
            }

            if (!string.IsNullOrWhiteSpace(defaultsConfig.ConnectionStringName))
            {
                targetDefaults.ConnectionString = config.GetConnectionString(defaultsConfig.ConnectionStringName);
            }

            QueuedTaskMapping mappingFromConfig =
                GetQueudTaskMappingFromDefaultsConfig(defaultsConfig);

            targetDefaults.Mapping = MergeMappingFromConfig(targetDefaults.Mapping,
                                                            mappingFromConfig);

            if (defaultsConfig.WorkerCount > 0)
            {
                targetDefaults.WorkerCount = defaultsConfig.WorkerCount;
            }

            if (defaultsConfig.FaultErrorThresholdCount > 0)
            {
                targetDefaults.FaultErrorThresholdCount = defaultsConfig.FaultErrorThresholdCount;
            }

            if (defaultsConfig.AppMetricsCollectionIntervalMilliseconds > 0)
            {
                targetDefaults.AppMetricsCollectionIntervalMilliseconds = defaultsConfig.AppMetricsCollectionIntervalMilliseconds;
            }

            if (defaultsConfig.AppMetricsMonitoringEnabled.HasValue)
            {
                targetDefaults.AppMetricsMonitoringEnabled = defaultsConfig.AppMetricsMonitoringEnabled.Value;
            }

            if (defaultsConfig.SetupBuiltInDbAsssets.HasValue)
            {
                targetDefaults.SetupBuiltInDbAsssets = defaultsConfig.SetupBuiltInDbAsssets.Value;
            }

            return(targetDefaults);
        }