Skip to content

Commit

Permalink
Fix CosmosStoreContext ctor ambiguity
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Oct 30, 2020
1 parent 8f780a5 commit 22cfdd4
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 104 deletions.
155 changes: 78 additions & 77 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion samples/Infrastructure/Storage.fs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ module Cosmos =
CosmosStoreConnection(client, databaseId, containerId, client2 = client2, databaseId2 = db2, containerId2 = cont2)
log.Information("CosmosStore Max Events in Tip: {maxTipEvents}e {maxTipJsonLength}b Items in Query: {queryMaxItems}",
a.TipMaxEvents, a.TipMaxJsonLength, a.QueryMaxItems)
let ctx = CosmosStoreContext(conn, queryMaxItems = a.QueryMaxItems, tipMaxEvents = a.TipMaxEvents, tipMaxJsonLength = a.TipMaxJsonLength)
let ctx = CosmosStoreContext.Create(conn, defaultMaxItems = a.QueryMaxItems, tipMaxEvents = a.TipMaxEvents, tipMaxJsonLength = a.TipMaxJsonLength)
let cacheStrategy = match cache with Some c -> CachingStrategy.SlidingWindow (c, TimeSpan.FromMinutes 20.) | None -> CachingStrategy.NoCaching
StorageConfig.Cosmos (ctx, cacheStrategy, unfolds)

Expand Down
2 changes: 1 addition & 1 deletion samples/Tutorial/AsAt.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#r "FSharp.Control.AsyncSeq.dll"
#r "System.Net.Http"
#r "Serilog.Sinks.Seq.dll"
#r "Eventstore.ClientAPI.dll"
#r "EventStore.ClientAPI.dll"
#r "Equinox.EventStore.dll"
#r "Microsoft.Azure.Cosmos.Direct.dll"
#r "Microsoft.Azure.Cosmos.Client.dll"
Expand Down
2 changes: 1 addition & 1 deletion samples/Tutorial/FulfilmentCenter.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ service.Read(fc) |> Async.RunSynchronously

Log.dumpMetrics ()

/// Manages ingestion of summary events tagged with the version emitted from FulmentCenter.Service.QueryWithVersion
/// Manages ingestion of summary events tagged with the version emitted from FulfilmentCenter.Service.QueryWithVersion
module FulfilmentCenterSummary =

let streamName id = FsCodec.StreamName.create "FulfilmentCenterSummary" id
Expand Down
12 changes: 0 additions & 12 deletions src/Equinox.Core/Infrastructure.fs
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,3 @@ type Async with
else
sc ())
|> ignore)

[<RequireQualifiedAccess>]
module Regex =
open System.Text.RegularExpressions

let DefaultTimeout = TimeSpan.FromMilliseconds 250.
let private mkRegex p = Regex(p, RegexOptions.None, DefaultTimeout)

/// Active pattern for branching on successful regex matches
let (|Match|_|) (pattern : string) (input : string) =
let m = (mkRegex pattern).Match input
if m.Success then Some m else None
18 changes: 9 additions & 9 deletions src/Equinox.CosmosStore/CosmosStore.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1223,17 +1223,17 @@ type CosmosStoreConnection

/// Defines a set of related access policies for a given CosmosDB, together with a Containers map defining mappings from (category,id) to (databaseId,containerId,streamName)
type CosmosStoreContext(connection : CosmosStoreConnection, ?queryOptions, ?tipOptions) =
new(connection : CosmosStoreConnection, ?defaultMaxItems, ?getDefaultMaxItems, ?maxRequests, ?tipOptions) =
static member Create
( connection : CosmosStoreConnection,
?defaultMaxItems, ?getDefaultMaxItems, ?maxRequests,
/// Maximum number of events permitted in Tip. When this is exceeded, events are moved out to a standalone Batch. Default: 0
/// NOTE <c>Equinox.Cosmos</c> versions <= 3.0.0 cannot read events in Tip, hence using a non-zero value will not be interoperable.
?tipMaxEvents,
/// Maximum serialized size (length of JSON.stringify representation) permitted in Tip before they get moved out to a standalone Batch. Default: 30_000.
?tipMaxJsonLength) =
let queryOptions = QueryOptions(?defaultMaxItems = defaultMaxItems, ?getDefaultMaxItems = getDefaultMaxItems, ?maxRequests = maxRequests)
CosmosStoreContext(connection, queryOptions, ?tipOptions = tipOptions)
new(connection : CosmosStoreConnection, ?queryMaxItems,
/// Maximum number of events permitted in Tip. When this is exceeded, events are moved out to a standalone Batch. Default: 0
/// NOTE <c>Equinox.Cosmos</c> versions <= 3.0.0 cannot read events in Tip, hence using a non-zero value will not be interoperable.
?tipMaxEvents,
/// Maximum serialized size (length of JSON.stringify representation) permitted in Tip before they get moved out to a standalone Batch. Default: 30_000.
?tipMaxJsonLength) =
let tipOptions = TipOptions(?maxEvents = tipMaxEvents, ?maxJsonLength = tipMaxJsonLength)
CosmosStoreContext(connection, tipOptions = tipOptions, ?defaultMaxItems = queryMaxItems)
CosmosStoreContext(connection, queryOptions, tipOptions)
member val QueryOptions = queryOptions |> Option.defaultWith QueryOptions
member val TipOptions = tipOptions |> Option.defaultWith TipOptions
member internal __.ResolveContainerClientAndStreamIdAndInit(categoryName, streamId) =
Expand Down
6 changes: 3 additions & 3 deletions tests/Equinox.CosmosStore.Integration/CosmosFixtures.fs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ let connectWithFallback log =

let createPrimaryContextEx log queryMaxItems tipMaxEvents =
let conn = connectPrimary log
CosmosStoreContext(conn, queryMaxItems = queryMaxItems, tipMaxEvents = tipMaxEvents)
CosmosStoreContext.Create(conn, defaultMaxItems = queryMaxItems, tipMaxEvents = tipMaxEvents)

let defaultTipMaxEvents = 10

Expand All @@ -54,11 +54,11 @@ let createPrimaryContext log queryMaxItems =

let createSecondaryContext log queryMaxItems =
let conn = connectSecondary log
CosmosStoreContext(conn, queryMaxItems = queryMaxItems, tipMaxEvents = defaultTipMaxEvents)
CosmosStoreContext.Create(conn, defaultMaxItems = queryMaxItems, tipMaxEvents = defaultTipMaxEvents)

let createFallbackContext log queryMaxItems =
let conn = connectWithFallback log
CosmosStoreContext(conn, queryMaxItems = queryMaxItems, tipMaxEvents = defaultTipMaxEvents)
CosmosStoreContext.Create(conn, defaultMaxItems = queryMaxItems, tipMaxEvents = defaultTipMaxEvents)

let defaultQueryMaxItems = 10

Expand Down

0 comments on commit 22cfdd4

Please sign in to comment.