private static async Task Main()
        {
            //todo temp - for manual tests
            // var message = new KafkaMessage
            // {
            //     UtcStartDateTime = DateTime.Now.AddMinutes(-1).ToUniversalTime(),
            //     FilePath = @"<some path>"
            // };

            Log.Logger =
                new LoggerConfiguration()
                .MinimumLevel.Information()
                .Enrich.With(new UtcTimestampEnricher())
                .WriteTo.ColoredConsole(
                    outputTemplate:
                    "{UtcTimestamp:yyyy-MM-dd HH:mm:ss.fff} [{Level}] {CallerMemberName} {Message:lj}{NewLine}{Exception}",
                    formatProvider: CultureInfo.InvariantCulture)
                .CreateLogger();

            var cfg = JsonConvert.DeserializeObject <MainConfig>(await File.ReadAllTextAsync("config.json"));

            cfg.ValidateConfig();

            await KafkaConsumer.ConsumeMessage(cfg, new CancellationToken(), Log.Logger);

            //// <comment upper line and uncomment this to use without Kafka in testing>
            //await SortWorker.ProcessSorting(cfg, message, Log.Logger);
            //Console.ReadKey();
        }
Esempio n. 2
0
        public void TestKafkaConsumer()
        {
            Rootobject   msg    = new Rootobject();
            IKafkaConfig kconf  = new KafkaConfig(conf);
            KProcessor   worker = new KProcessor();
            KafkaConsumer <Rootobject> kafkaConsumer = new KafkaConsumer <Rootobject>(kconf, msg, worker);

            kafkaConsumer.ConsumeMessage();
        }