public ITimeoutManager Create() { _documentStore = new EmbeddableDocumentStore() { RunInMemory = true, }; _documentStore.Configuration.Storage.Voron.AllowOn32Bits = true; _documentStore.Initialize(); _documentStore.ExecuteIndex(new TimeoutIndex()); return new RavenDbTimeoutManager(_documentStore, new ConsoleLoggerFactory(false)); }
public static void ConfigureRaven(MvcApplication application) { var store = new EmbeddableDocumentStore { DataDirectory = "~/App_Data/Database", UseEmbeddedHttpServer = true }; store.Conventions.CustomizeJsonSerializer = x => x.Converters.Add(new GeoJsonConverter()); store.Initialize(); MvcApplication.DocumentStore = store; store.ExecuteIndex(new RestaurantIndex()); store.ExecuteTransformer(new RestaurantsTransformer()); var statistics = store.DatabaseCommands.GetStatistics(); if (statistics.CountOfDocuments < 5) using (var bulkInsert = store.BulkInsert()) LoadRestaurants(application.Server.MapPath("~/App_Data/Restaurants.csv"), bulkInsert); }
public void Init() { Directory.CreateDirectory(Settings.DbPath); var documentStore = new EmbeddableDocumentStore { DataDirectory = Settings.DbPath, UseEmbeddedHttpServer = Settings.MaintenanceMode || Settings.ExposeRavenDB, EnlistInDistributedTransactions = false, }; var localRavenLicense = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "RavenLicense.xml"); if (File.Exists(localRavenLicense)) { Logger.InfoFormat("Loading RavenDB license found from {0}", localRavenLicense); documentStore.Configuration.Settings["Raven/License"] = NonLockingFileReader.ReadAllTextWithoutLocking(localRavenLicense); } else { Logger.InfoFormat("Loading Embedded RavenDB license"); documentStore.Configuration.Settings["Raven/License"] = ReadLicense(); } documentStore.Configuration.Catalog.Catalogs.Add(new AssemblyCatalog(GetType().Assembly)); if (!Settings.MaintenanceMode) { documentStore.Configuration.Settings.Add("Raven/ActiveBundles", "CustomDocumentExpiration"); } documentStore.Configuration.Port = Settings.Port; documentStore.Configuration.HostName = (Settings.Hostname == "*" || Settings.Hostname == "+") ? "localhost" : Settings.Hostname; documentStore.Configuration.CompiledIndexCacheDirectory = Settings.DbPath; documentStore.Configuration.VirtualDirectory = Settings.VirtualDirectory + "/storage"; documentStore.Conventions.SaveEnumsAsIntegers = true; documentStore.Initialize(); Logger.Info("Index creation started"); //Create this index synchronously as we are using it straight away //Should be quick as number of endpoints will always be a small number documentStore.ExecuteIndex(new KnownEndpointIndex()); if (Settings.CreateIndexSync) { IndexCreation.CreateIndexes(typeof(RavenBootstrapper).Assembly, documentStore); } else { IndexCreation.CreateIndexesAsync(typeof(RavenBootstrapper).Assembly, documentStore) .ContinueWith(c => { if (c.IsFaulted) { Logger.Error("Index creation failed", c.Exception); } }); } PurgeKnownEndpointsWithTemporaryIdsThatAreDuplicate(documentStore); Configure.Instance.Configurer.RegisterSingleton<IDocumentStore>(documentStore); Configure.Component(builder => { #pragma warning disable 618 var context = builder.Build<PipelineExecutor>().CurrentContext; #pragma warning restore 618 IDocumentSession session; if (context.TryGet(out session)) { return session; } throw new InvalidOperationException("No session available"); }, DependencyLifecycle.InstancePerCall); Configure.Instance.RavenDBStorageWithSelfManagedSession(documentStore, false, () => Configure.Instance.Builder.Build<IDocumentSession>()) .UseRavenDBSagaStorage() .UseRavenDBSubscriptionStorage() .UseRavenDBTimeoutStorage(); }