Exemplo n.º 1
0
        public async Task MainAsync()
        {
            var configClient = InternalConfigurationApiClientFactory.Create(GetConfiguration().GetValue <string>("System:InternalConfiguration:Host"), TimeSpan.FromSeconds(5), 5);
            var systemConfig = await configClient.GetConfigurationAsync();

            // TODO : ideally queue name should be read from InternalConfigurationApi
            IMessageChannel messageChannel = new RabbitMqChannel(systemConfig.MessageQueue.Host, systemConfig.MessageQueue.User, systemConfig.MessageQueue.Password, new JsonSerializer(), RabbitMqConsts.WorkerQueueName);
            IMessageBus     messageBus     = new RabbitMqBus(systemConfig.MessageQueue.Host, systemConfig.MessageQueue.User, systemConfig.MessageQueue.Password, new JsonSerializer());
            var             worker         = new WorkerService(messageChannel, messageBus, new ChannelPersistence(new MongoDbOptions(systemConfig.ChannelsDb.DbHost, systemConfig.ChannelsDb.DbName, systemConfig.ChannelsDb.CollectionName, systemConfig.ChannelsDb.User, systemConfig.ChannelsDb.Password)));

            worker.Start();

            await Task.Delay(-1);
        }
Exemplo n.º 2
0
        public async Task MainAsync()
        {
            var configClient = InternalConfigurationApiClientFactory.Create(GetConfiguration().GetValue <string>("System:InternalConfiguration:Host"), TimeSpan.FromSeconds(5), 5);
            var systemConfig = await configClient.GetConfigurationAsync();

            // TODO : ideally queue name should be read from InternalConfigurationApi
            IMessageChannel messageChannel = new RabbitMqChannel(systemConfig.MessageQueue.Host, systemConfig.MessageQueue.User, systemConfig.MessageQueue.Password, new JsonSerializer(), RabbitMqConsts.DiscordBotQueueName);
            IMessageBus     messageBus     = new RabbitMqBus(systemConfig.MessageQueue.Host, systemConfig.MessageQueue.User, systemConfig.MessageQueue.Password, new JsonSerializer());
            var             svc            = new DiscordService(systemConfig.DiscordBot.ApiKey, messageChannel, messageBus);

            messageChannel.Start();

            await svc.ConnectAsync();

            await Task.Delay(-1);
        }