From e6891080e082f0e5e630b7dccce441d50715059e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Provazn=C3=ADk?= Date: Fri, 17 May 2019 15:09:23 +0200 Subject: [PATCH] Configurable initialization #23 --- src/CosmoStore.CosmosDb/CosmosDb.fs | 4 +++- src/CosmoStore.CosmosDb/EventStore.fs | 11 ++++++----- src/CosmoStore.CosmosDb/RELEASE_NOTES.md | 4 ++++ src/CosmoStore/RELEASE_NOTES.md | 3 +++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/CosmoStore.CosmosDb/CosmosDb.fs b/src/CosmoStore.CosmosDb/CosmosDb.fs index e890051..22d1e31 100644 --- a/src/CosmoStore.CosmosDb/CosmosDb.fs +++ b/src/CosmoStore.CosmosDb/CosmosDb.fs @@ -17,7 +17,8 @@ type Configuration = { CollectionName : string ServiceEndpoint : Uri AuthKey : string - Throughput: int + Throughput : int + InitializeCollection : bool } with static member CreateDefault serviceEndpoint authKey = { @@ -26,4 +27,5 @@ with ServiceEndpoint = serviceEndpoint AuthKey = authKey Throughput = Throughput.min + InitializeCollection = true } diff --git a/src/CosmoStore.CosmosDb/EventStore.fs b/src/CosmoStore.CosmosDb/EventStore.fs index f636bdd..c66cc31 100644 --- a/src/CosmoStore.CosmosDb/EventStore.fs +++ b/src/CosmoStore.CosmosDb/EventStore.fs @@ -158,11 +158,12 @@ let getEventStore (configuration:Configuration) = let appendEventProcUri = UriFactory.CreateStoredProcedureUri(configuration.DatabaseName, configuration.CollectionName, appendEventProcName) let eventAppended = Event() - task { - do! createDatabase configuration.DatabaseName client - do! createCollection dbUri configuration client - do! createStoreProcedures eventsCollectionUri appendEventProcUri configuration.CollectionName client - } |> Async.AwaitTask |> Async.RunSynchronously + if configuration.InitializeCollection then + task { + do! createDatabase configuration.DatabaseName client + do! createCollection dbUri configuration client + do! createStoreProcedures eventsCollectionUri appendEventProcUri configuration.CollectionName client + } |> Async.AwaitTask |> Async.RunSynchronously { AppendEvent = fun stream pos event -> task { diff --git a/src/CosmoStore.CosmosDb/RELEASE_NOTES.md b/src/CosmoStore.CosmosDb/RELEASE_NOTES.md index d5381a0..0e4b215 100644 --- a/src/CosmoStore.CosmosDb/RELEASE_NOTES.md +++ b/src/CosmoStore.CosmosDb/RELEASE_NOTES.md @@ -1,3 +1,7 @@ +### 2.1.0 - May 17 2019 +* Configurable collection name #25 +* Configurable initialization #23 + ### 2.0.1 - February 12 2019 * Fixing typo StarsWith vs StartsWith diff --git a/src/CosmoStore/RELEASE_NOTES.md b/src/CosmoStore/RELEASE_NOTES.md index d5381a0..bf359e0 100644 --- a/src/CosmoStore/RELEASE_NOTES.md +++ b/src/CosmoStore/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +### 2.1.0 - May 14 2019 +* Added helper functions for validation and conversion + ### 2.0.1 - February 12 2019 * Fixing typo StarsWith vs StartsWith