Exemplo n.º 1
0
        /// <summary>
        /// Constructs the persister which will connect to the Mongo database pointed to by the connection string.
        /// This also means that the connection string must include the database name.
        /// </summary>
        public MongoDbSagaPersister(string connectionString)
        {
            log.Info("Connecting to Mongo");
            database = MongoHelper.GetDatabase(connectionString);

            // flick the bool once in a while
            indexRecreationTimer.Elapsed += delegate { indexEnsuredRecently = false; };
            indexRecreationTimer.Interval = TimeSpan.FromMinutes(1).TotalMilliseconds;
            indexRecreationTimer.Start();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructs the timeout storage, connecting to the Mongo database pointed to by the given connection string,
        /// storing the timeouts in the given collection
        /// </summary>
        public MongoDbTimeoutStorage(string connectionString, string collectionName)
        {
            var database = MongoHelper.GetDatabase(connectionString);

            collection = database.GetCollection <BsonDocument>(collectionName);

            var indexBuilder = Builders <BsonDocument> .IndexKeys;
            var indexModel   = new CreateIndexModel <BsonDocument>(indexBuilder.Ascending(TimeProperty), new CreateIndexOptions()
            {
                Background = true, Unique = false
            });

            collection.Indexes.CreateOne(indexModel);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Constructs the storage to persist subscriptions in the given collection, in the database specified by the connection string.
 /// </summary>
 public MongoDbSubscriptionStorage(string connectionString, string collectionName)
 {
     this.collectionName = collectionName;
     database            = database = MongoHelper.GetDatabase(connectionString);
 }