Skip to content

Commit

Permalink
Review diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Mar 4, 2022
1 parent d5748af commit c86f703
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ The components within this repository are delivered as multi-targeted Nuget pack
- `Equinox.Core` [![NuGet](https://img.shields.io/nuget/v/Equinox.Core.svg)](https://www.nuget.org/packages/Equinox.Core/): Interfaces and helpers used in the concrete Store implementations, together with the default [`System.Runtime.Caching.Cache`-based] `Cache` implementation. Hosts generic utility types frequently useful alongside Equinox: [`AsyncCacheCell`](https://github.com/jet/equinox/blob/master/src/Equinox.Core/AsyncCacheCell.fs#L36), [`AsyncBatchingGate`](https://github.com/jet/equinox/blob/master/src/Equinox.Core/AsyncBatchingGate.fs#L41). ([depends](https://www.fuget.org/packages/Equinox.Core) on `Equinox`, `System.Runtime.Caching`)
- `Equinox.MemoryStore` [![MemoryStore NuGet](https://img.shields.io/nuget/v/Equinox.MemoryStore.svg)](https://www.nuget.org/packages/Equinox.MemoryStore/): In-memory store for integration testing/performance base-lining/providing out-of-the-box zero dependency storage for examples. ([depends](https://www.fuget.org/packages/Equinox.MemoryStore) on `Equinox.Core`, `FsCodec`)
- `Equinox.EventStore` [![EventStore NuGet](https://img.shields.io/nuget/v/Equinox.EventStore.svg)](https://www.nuget.org/packages/Equinox.EventStore/): [EventStoreDB](https://eventstore.org/) Adapter designed to meet Jet's production monitoring requirements. ([depends](https://www.fuget.org/packages/Equinox.EventStore) on `Equinox.Core`, `EventStore.Client >= 20.6`, `FSharp.Control.AsyncSeq >= 2.0.23`)
- `Equinox.CosmosStore` [![CosmosStore NuGet](https://img.shields.io/nuget/v/Equinox.CosmosStore.svg)](https://www.nuget.org/packages/Equinox.CosmosStore/): Azure CosmosDB Adapter with integrated 'unfolds' feature, facilitating optimal read performance in terms of latency and RU costs, instrumented to meet Jet's production monitoring requirements. ([depends](https://www.fuget.org/packages/Equinox.CosmosStore) on `Equinox.Core`, `Microsoft.Azure.Cosmos >= 3.17`, `FsCodec >= 2.3.0`, `System.Text.Json >= 6.0.1`, `FSharp.Control.AsyncSeq >= 2.0.23`)
- `Equinox.CosmosStore` [![CosmosStore NuGet](https://img.shields.io/nuget/v/Equinox.CosmosStore.svg)](https://www.nuget.org/packages/Equinox.CosmosStore/): Azure CosmosDB Adapter with integrated 'unfolds' feature, facilitating optimal read performance in terms of latency and RU costs, instrumented to meet Jet's production monitoring requirements. ([depends](https://www.fuget.org/packages/Equinox.CosmosStore) on `Equinox.Core`, `Microsoft.Azure.Cosmos >= 3.25`, `FsCodec >= 2.3.1`, `System.Text.Json >= 6.0.1`, `FSharp.Control.AsyncSeq >= 2.0.23`)
- `Equinox.CosmosStore.Prometheus` [![CosmosStore.Prometheus NuGet](https://img.shields.io/nuget/v/Equinox.CosmosStore.Prometheus.svg)](https://www.nuget.org/packages/Equinox.CosmosStore.Prometheus/): Integration package providing a `Serilog.Core.ILogEventSink` that extracts detailed metrics information attached to the `LogEvent`s and feeds them to the `prometheus-net`'s `Prometheus.Metrics` static instance. ([depends](https://www.fuget.org/packages/Equinox.CosmosStore.Prometheus) on `Equinox.CosmosStore`, `prometheus-net >= 3.6.0`)
- `Equinox.SqlStreamStore` [![SqlStreamStore NuGet](https://img.shields.io/nuget/v/Equinox.SqlStreamStore.svg)](https://www.nuget.org/packages/Equinox.SqlStreamStore/): [SqlStreamStore](https://github.com/SQLStreamStore/SQLStreamStore) Adapter derived from `Equinox.EventStore` - provides core facilities (but does not connect to a specific database; see sibling `SqlStreamStore`.* packages). ([depends](https://www.fuget.org/packages/Equinox.SqlStreamStore) on `Equinox.Core`, `FsCodec`, `SqlStreamStore >= 1.2.0-beta.8`, `FSharp.Control.AsyncSeq`)
- `Equinox.SqlStreamStore.MsSql` [![MsSql NuGet](https://img.shields.io/nuget/v/Equinox.SqlStreamStore.MsSql.svg)](https://www.nuget.org/packages/Equinox.SqlStreamStore.MsSql/): [SqlStreamStore.MsSql](https://sqlstreamstore.readthedocs.io/en/latest/sqlserver) Sql Server `Connector` implementation for `Equinox.SqlStreamStore` package). ([depends](https://www.fuget.org/packages/Equinox.SqlStreamStore.MsSql) on `Equinox.SqlStreamStore`, `SqlStreamStore.MsSql >= 1.2.0-beta.8`)
Expand Down
26 changes: 13 additions & 13 deletions src/Equinox.CosmosStore/CosmosStore.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ type EventBody = JsonElement

/// A single Domain Event from the array held in a Batch
[<NoEquality; NoComparison>]
type Event = // TODO for STJ v5: All fields required unless explicitly optional
type Event = // TODO for a future STJ version: All fields required unless explicitly optional
{ /// Creation datetime (as opposed to system-defined _lastUpdated which is touched by triggers, replication etc.)
t: DateTimeOffset // ISO 8601

/// The Case (Event Type); used to drive deserialization
c: string // required

/// Event body, as UTF-8 encoded json ready to be injected into the Json being rendered for CosmosDB
d: EventBody // TODO for STJ v5: Required, but can be null so Nullary cases can work
d: EventBody // TODO for a future STJ version: Required, but can be null so Nullary cases can work

/// Optional metadata, as UTF-8 encoded json, ready to emit directly
m: EventBody // TODO for STJ v5: Optional, not serialized if missing
m: EventBody // TODO for a future STJ version: Optional, not serialized if missing

/// Optional correlationId
correlationId : string // TODO for STJ v5: Optional, not serialized if missing
correlationId : string // TODO for a future STJ version: Optional, not serialized if missing

/// Optional causationId
causationId : string // TODO for STJ v5: Optional, not serialized if missing
causationId : string // TODO for a future STJ version: Optional, not serialized if missing
}

interface IEventData<EventBody> with
Expand All @@ -43,10 +43,10 @@ type Event = // TODO for STJ v5: All fields required unless explicitly optional

/// A 'normal' (frozen, not Tip) Batch of Events (without any Unfolds)
[<NoEquality; NoComparison>]
type Batch = // TODO for STJ v5: All fields required unless explicitly optional
type Batch = // TODO for a future STJ version: All fields required unless explicitly optional
{ /// CosmosDB-mandated Partition Key, must be maintained within the document
/// Not actually required if running in single partition mode, but for simplicity, we always write it
p: string // "{streamName}" TODO for STJ v5: Optional, not requested in queries
p: string // "{streamName}" TODO for a future STJ version: Optional, not requested in queries

/// CosmosDB-mandated unique row key; needs to be unique within any partition it is maintained; must be string
/// At the present time, one can't perform an ORDER BY on this field, hence we also have i shadowing it
Expand All @@ -56,7 +56,7 @@ type Batch = // TODO for STJ v5: All fields required unless explicitly optional
/// When we read, we need to capture the value so we can retain it for caching purposes
/// NB this is not relevant to fill in when we pass it to the writing stored procedure
/// as it will do: 1. read 2. merge 3. write merged version contingent on the _etag not having changed
_etag: string // TODO for STJ v5: Optional, not serialized if missing
_etag: string // TODO for a future STJ version: Optional, not serialized if missing

/// base 'i' value for the Events held herein
i: int64 // {index}
Expand All @@ -66,7 +66,7 @@ type Batch = // TODO for STJ v5: All fields required unless explicitly optional

/// The Domain Events (as opposed to Unfolded Events, see Tip) at this offset in the stream
e: Event[] }
/// Unless running in single partition mode (which would restrict us to 10GB per collection)
/// Unless running in single partition mode (which would restrict us to 10GB per container)
/// we need to nominate a partition key that will be in every document
static member internal PartitionKeyField = "p"
/// As one cannot sort by the implicit `id` field, we have an indexed `i` field for sort and range query use
Expand All @@ -90,25 +90,25 @@ type Unfold =

/// Optional metadata, same encoding as `d` (can be null; not written if missing)
[<Serialization.JsonConverter(typeof<JsonCompressedBase64Converter>)>]
m: EventBody // TODO for STJ v5: Optional, not serialized if missing
m: EventBody // TODO for a future STJ version: Optional, not serialized if missing
}

/// The special-case 'Pending' Batch Format used to read the currently active (and mutable) document
/// Stored representation has the following diffs vs a 'normal' (frozen/completed) Batch: a) `id` = `-1` b) contains unfolds (`u`)
/// NB the type does double duty as a) model for when we read it b) encoding a batch being sent to the stored proc
[<NoEquality; NoComparison>]
type Tip = // TODO for STJ v5: All fields required unless explicitly optional
type Tip = // TODO for a future STJ version: All fields required unless explicitly optional
{
/// Partition key, as per Batch
p: string // "{streamName}" TODO for STJ v5: Optional, not requested in queries
p: string // "{streamName}" TODO for a future STJ version: Optional, not requested in queries

/// Document Id within partition, as per Batch
id: string // "{-1}" - Well known IdConstant used while this remains the pending batch

/// When we read, we need to capture the value so we can retain it for caching purposes
/// NB this is not relevant to fill in when we pass it to the writing stored procedure
/// as it will do: 1. read 2. merge 3. write merged version contingent on the _etag not having changed
_etag: string // TODO for STJ v5: Optional, not serialized if missing
_etag: string // TODO for a future STJ version: Optional, not serialized if missing

/// base 'i' value for the Events held herein
i: int64
Expand Down
2 changes: 1 addition & 1 deletion src/Equinox.CosmosStore/Equinox.CosmosStore.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<PackageReference Include="FSharp.Core" Version="4.3.4" />

<PackageReference Include="FsCodec" Version="2.3.0" />
<PackageReference Include="FsCodec" Version="2.3.1" />
<PackageReference Include="System.Text.Json" Version="6.0.1" />
<PackageReference Include="FSharp.Control.AsyncSeq" Version="2.0.23" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.25.0" />
Expand Down
2 changes: 1 addition & 1 deletion tests/Equinox.CosmosStore.Integration/CosmosIntegration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ type Tests(testOutputHelper) =
test <@ addRemoveCount = match state with { items = [{ quantity = quantity }] } -> quantity | _ -> failwith "nope" @>

test <@ List.replicate (expectedResponses transactions) EqxAct.ResponseBackward @ [EqxAct.QueryBackward] = capture.ExternalCalls @>
if eventsInTip then verifyRequestChargesMax 9 // 8.05
if eventsInTip then verifyRequestChargesMax 8 // 7.46
else verifyRequestChargesMax 15 // 14.01
}

Expand Down

0 comments on commit c86f703

Please sign in to comment.