Beispiel #1
0
        internal static EngineSetup ConfigureLogging(this EngineSetup setup, FfdbConfig config)
        {
            if (!string.IsNullOrWhiteSpace(config.Logging?.Directory))
            {
                var rollingInterval = config.Logging.RollingInterval.HasValue
                                        ? config.Logging.RollingInterval.Value
                                        : RollingInterval.Day;

                setup.Logging
                .SetLogDirectory(config.Logging.Directory)
                .SetRollingInterval(rollingInterval);

                if (config.Logging.UseDebugLogLevel)
                {
                    setup.Logging.UseDebugLogLevel();
                }

                if (config.Logging.MaxBytes.HasValue)
                {
                    setup.Logging.SetMaxBytes(config.Logging.MaxBytes.Value);
                }
                if (config.Logging.RollOnFileSizeLimit)
                {
                    setup.Logging.RollOnFileSizeLimit();
                }
            }

            return(setup);
        }
Beispiel #2
0
        public static async Task Main(string[] args)
        {
            try
            {
                if (TryGetRunInfo(args, out RunInfoBase runInfo))
                {
                    string     configFilePath = GetConfigFilePath(runInfo);
                    FfdbConfig config         = FileConfigResolver.FromFile(configFilePath);

                    DataRepoState dataRepoState = await GetDataRepoStateAsync();

                    FfdbEngine engine = EngineResolver.Resolve(config, runInfo, dataRepoState);

                    OutputCommandInfo(runInfo);

                    await new EngineRunner(engine).RunAsync(runInfo);
                }
            }
            catch (Exception ex)
            {
                CM.WriteError(ex.Message);
            }
            finally
            {
                WriteLine(Environment.NewLine + "Completed running command. Press any key to exit..");
                ReadKey();
            }
        }
Beispiel #3
0
        internal static EngineSetup ConfigureDbProvider(this EngineSetup setup, FfdbConfig config)
        {
            if (config.PostgreSql != null)
            {
                setup.UsePostgreSql(config.PostgreSql);
            }
            else if (config.Mongo != null)
            {
                setup.UseMongo(config.Mongo);
            }

            return(setup);
        }
Beispiel #4
0
        internal static EngineSetup ConfigureWebClient(this EngineSetup setup, FfdbConfig config)
        {
            if (config.WebRequest.RandomizedThrottle != null)
            {
                setup.WebRequest.SetRandomizedThrottle(
                    config.WebRequest.RandomizedThrottle.Min,
                    config.WebRequest.RandomizedThrottle.Max);
            }
            else
            {
                setup.WebRequest.SetThrottle(config.WebRequest.ThrottleMilliseconds);
            }

            return(setup);
        }
Beispiel #5
0
        internal static FfdbEngine Resolve(FfdbConfig config, RunInfoBase runInfo, DataRepoState dataRepoState)
        {
            var setup = new EngineSetup()
                        .SetRootDataDirectoryPath(config.RootDataPath)
                        .ConfigureWebClient(config)
                        .ConfigureLogging(config)
                        .ConfigureDbProvider(config)
                        .ConfigureFromRunInfo(runInfo);

            bool fetchFromDataRepo = dataRepoState?.Enabled ?? false;

            if (fetchFromDataRepo)
            {
                setup.EnableFetchingFromDataRepo();
            }

            return(setup.Create());
        }