Esempio n. 1
0
 internal EventStoreConfigurator RegisterMongoEventStore(IContainer container)
 {
     var appSettings = container.GetInstance<AppSettings>();
     var mongoEvents = new MongoInstance(appSettings.EventsConnectionString);
     var eventStore = new MongoEventStore(mongoEvents.GetDatabase(), EventStoreSettings.GetDefault());
     container.Configure(config => config.For<IEventStore>().Singleton().Use(eventStore));
     
     return this;
 }
Esempio n. 2
0
        internal UniformConfigurator RegisterMongoUniform(IContainer container)
        {
            var appSettings = container.GetInstance<AppSettings>();
            var mongoView = new MongoInstance(appSettings.ViewConnectionString);

            UniformContext uniformContext = new MongoContext(mongoView.GetDatabase(), ViewContextClassMap.GetClassMap());
            container.Configure(config => config.For<UniformContext>().Singleton().Use(uniformContext));

            return this;
        }
Esempio n. 3
0
        public LoggingConfigurator RegisterMongoDomainLogger(IContainer container)
        {
            var appSettings = container.GetInstance<AppSettings>();

            var mongoLogs = new MongoInstance(appSettings.LogsConnectionString);
            var domainLogs = mongoLogs.GetDatabase().GetCollection<MongoDomainLogRecord>("domain_logs");

            var logManager = new MongoDomainLogManager(domainLogs);
            container.Configure(config => config.For<IDomailLogManager>().Singleton().Use(logManager));
            
            return this;
        }
Esempio n. 4
0
        // todo should be moved to platform
        internal UniformConfigurator CreateIndexes(IContainer container)
        {
            var appSettings = container.GetInstance<AppSettings>();
            var mongoView = new MongoInstance(appSettings.ViewConnectionString).GetDatabase();

            var questions = mongoView.GetCollection<QuestionDocument>("questions");
            questions.CreateIndex(IndexKeys<QuestionDocument>.Descending(x => x.Rating));
            questions.CreateIndex(IndexKeys<QuestionDocument>.Descending(x => x.CreatedAt));
            questions.CreateIndex(IndexKeys<QuestionDocument>.Descending(x => x.CreatedAt, x => x.IsResolved));
            questions.CreateIndex(IndexKeys<QuestionDocument>.Descending(x => x.CreatedAt, x => x.AnswersCount, x => x.Rating));


            var answers = mongoView.GetCollection<AnswerDocument>("answers");
            answers.CreateIndex(IndexKeys<AnswerDocument>.Descending(x => x.Rating));

            var users = mongoView.GetCollection<UserDocument>("users");
            users.CreateIndex(IndexKeys<UserDocument>.Descending(x => x.Reputation));

            var notifications = mongoView.GetCollection<NotificationDocument>("notifications");
            notifications.CreateIndex(IndexKeys<NotificationDocument>.Descending(x => x.CreatedAt));
            notifications.CreateIndex(IndexKeys<NotificationDocument>.Descending(x => x.CreatedAt, x => x.TargetUserId));

            return this;
        }