Skip to content

Commit

Permalink
Configurable initialization #23
Browse files Browse the repository at this point in the history
  • Loading branch information
Dzoukr committed May 17, 2019
1 parent e1b689b commit e689108
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/CosmoStore.CosmosDb/CosmosDb.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ type Configuration = {
CollectionName : string
ServiceEndpoint : Uri
AuthKey : string
Throughput: int
Throughput : int
InitializeCollection : bool
}
with
static member CreateDefault serviceEndpoint authKey = {
Expand All @@ -26,4 +27,5 @@ with
ServiceEndpoint = serviceEndpoint
AuthKey = authKey
Throughput = Throughput.min
InitializeCollection = true
}
11 changes: 6 additions & 5 deletions src/CosmoStore.CosmosDb/EventStore.fs
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,12 @@ let getEventStore (configuration:Configuration) =
let appendEventProcUri = UriFactory.CreateStoredProcedureUri(configuration.DatabaseName, configuration.CollectionName, appendEventProcName)
let eventAppended = Event<EventRead>()

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 {
Expand Down
4 changes: 4 additions & 0 deletions src/CosmoStore.CosmosDb/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 3 additions & 0 deletions src/CosmoStore/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit e689108

Please sign in to comment.