Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename/reorg .Cosmos to .CosmosStore #243

Merged
merged 6 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,19 @@ The `Unreleased` section name is replaced by the expected version of next releas
- `Cosmos`: Reorganize Sync log message text, merge with Sync Conflict message [#241](https://github.com/jet/equinox/pull/241)
- `Cosmos`: Converge Stored Procedure Impl with `tip-isa-batch` impl from V3 (minor Request Charges cost reduction) [#242](https://github.com/jet/equinox/pull/242)

- target `Microsoft.Azure.Cosmos` v `3.9.0` (instead of `Microsoft.Azure.DocumentDB`[`.Core`] v 2.x) [#144](https://github.com/jet/equinox/pull/144)
- Fork `Equinox.Cosmos` to `Equinox.CosmosStore`
- target `Microsoft.Azure.Cosmos` v `3.9.0` (instead of `Microsoft.Azure.DocumentDB`[`.Core`] v 2.x) [#144](https://github.com/jet/equinox/pull/144)
- Removed [warmup call](https://github.com/Azure/azure-cosmos-dotnet-v3/issues/1436)
- Rename `Equinox.Cosmos` DLL and namespace to `Equinox.CosmosStore` [#243](https://github.com/jet/equinox/pull/243)
- Rename `Equinox.Cosmos.Store` -> `Equinox.CosmosStore.Core`
- `Core` sub-namespace
- Rename `Equinox.Cosmos.Core.Context` -> `Equinox.CosmosStore.Core.EventsContext`
- Change `Equinox.Cosmos.Core.Connection` -> `Equinox.CosmosStore.Core.RetryPolicy`
- Rename `Equinox.Cosmos.Core.Gateway` -> `Equinox.CosmosStore.Core.StoreClient`
- Rename `Equinox.Cosmos.Containers` -> `Equinox.CosmosStore.CosmosStoreConnection`
- Rename `Equinox.Cosmos.Context` -> `Equinox.CosmosStore.CosmosStoreContext`
- Rename `Equinox.Cosmos.Resolver` -> `Equinox.CosmosStore.CosmosStoreCategory`
- Rename `Equinox.Cosmos.Connector` -> `Equinox.CosmosStore.CosmosStoreClientFactory`
- target `EventStore.Client` v `20.6` (instead of v `5.0.x`) [#224](https://github.com/jet/equinox/pull/224)
- Retarget `netcoreapp2.1` apps to `netcoreapp3.1` with `SystemTextJson`
- Retarget Todobackend to `aspnetcore` v `3.1`
Expand All @@ -24,7 +36,6 @@ The `Unreleased` section name is replaced by the expected version of next releas
- Update to `3.1.101` SDK
- Remove `module Commands` convention from in examples
- Revise semantics of Cart Sample Command handling
- `Cosmos:` Removed [warmup call](https://github.com/Azure/azure-cosmos-dotnet-v3/issues/1436)
- Simplify `AsyncCacheCell` [#229](https://github.com/jet/equinox/pull/229)

### Removed
Expand Down
80 changes: 40 additions & 40 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,23 +164,23 @@ slightly differently:

![Equinox.EventStore/SqlStreamStore c4model.com Code - another process; using snapshotting](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.github.com/jet/equinox/master/diagrams/EventStoreCode.puml&idx=3&fmt=svg)

# Equinox.Cosmos
# Equinox.CosmosStore

## Container Diagram for `Equinox.Cosmos`
## Container Diagram for `Equinox.CosmosStore`

![Equinox.Cosmos c4model.com Container Diagram](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.github.com/jet/equinox/master/diagrams/CosmosContainer.puml?fmt=svg)
![Equinox.CosmosStore c4model.com Container Diagram](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.github.com/jet/equinox/master/diagrams/CosmosContainer.puml?fmt=svg)

## Component Diagram for `Equinox.Cosmos`
## Component Diagram for `Equinox.CosmosStore`

![Equinox.Cosmos c4model.com Component Diagram](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.github.com/jet/equinox/master/diagrams/CosmosComponent.puml?fmt=svg)
![Equinox.CosmosStore c4model.com Component Diagram](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.github.com/jet/equinox/master/diagrams/CosmosComponent.puml?fmt=svg)

## Code Diagrams for `Equinox.Cosmos`
## Code Diagrams for `Equinox.CosmosStore`

This diagram walks through the basic sequence of operations, where:
- this node has not yet read this stream (i.e. there's nothing in the Cache)
- when we do read it, the Read call returns `404` (with a charge of `1 RU`)

![Equinox.Cosmos c4model.com Code - first Time](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.github.com/jet/equinox/master/diagrams/CosmosCode.puml&idx=0&fmt=svg)
![Equinox.CosmosStore c4model.com Code - first Time](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.github.com/jet/equinox/master/diagrams/CosmosCode.puml&idx=0&fmt=svg)

Next, we extend the scenario to show:
- how state held in the Cache influences the Cosmos APIs used
Expand All @@ -194,12 +194,12 @@ Next, we extend the scenario to show:
- when there's conflict and we're giving up (throw
`MaxAttemptsExceededException`)

![Equinox.Cosmos c4model.com Code - with cache, snapshotting](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.github.com/jet/equinox/master/diagrams/CosmosCode.puml&idx=1&fmt=svg)
![Equinox.CosmosStore c4model.com Code - with cache, snapshotting](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.github.com/jet/equinox/master/diagrams/CosmosCode.puml&idx=1&fmt=svg)

After the write, we circle back to illustrate the effect of the caching when we
have correct state (we get a `304 Not Mofified` and pay only `1 RU`)

![Equinox.Cosmos c4model.com Code - next time; same process, i.e. cached](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.github.com/jet/equinox/master/diagrams/CosmosCode.puml&idx=2&fmt=svg)
![Equinox.CosmosStore c4model.com Code - next time; same process, i.e. cached](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.github.com/jet/equinox/master/diagrams/CosmosCode.puml&idx=2&fmt=svg)

In other processes (when a cache is not fully in sync), the sequence runs
slightly differently:
Expand All @@ -208,7 +208,7 @@ slightly differently:
suitable snapshot that passes the `isOrigin` predicate is found within the
_Tip_

![Equinox.Cosmos c4model.com Code - another process; using snapshotting](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.github.com/jet/equinox/master/diagrams/CosmosCode.puml&idx=3&fmt=svg)
![Equinox.CosmosStore c4model.com Code - another process; using snapshotting](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.github.com/jet/equinox/master/diagrams/CosmosCode.puml&idx=3&fmt=svg)

# Glossary

Expand Down Expand Up @@ -410,12 +410,12 @@ module EventStore =

module Cosmos =
let accessStrategy =
Equinox.Cosmos.AccessStrategy.Snapshot (Fold.isOrigin, Fold.snapshot)
Equinox.CosmosStore.AccessStrategy.Snapshot (Fold.isOrigin, Fold.snapshot)
let create (context, cache) =
let cacheStrategy =
Equinox.Cosmos.CachingStrategy.SlidingWindow (cache, System.TimeSpan.FromMinutes 20.)
Equinox.CosmosStore.CachingStrategy.SlidingWindow (cache, System.TimeSpan.FromMinutes 20.)
let resolver =
Equinox.Cosmos.Resolver(context, Events.codec, Fold.fold, Fold.initial, cacheStrategy, accessStrategy)
Equinox.CosmCosmosStoreos.Resolver(context, Events.codec, Fold.fold, Fold.initial, cacheStrategy, accessStrategy)
create resolver.Resolve
```

Expand Down Expand Up @@ -1558,12 +1558,12 @@ not reading data redundantly, and not feeding back into the oneself (although
having separate roundtrips obviously has implications).

<a name="cosmos-storage-model"></a>
# `Equinox.Cosmos` CosmosDB Storage Model
# `Equinox.CosmosStore` CosmosDB Storage Model

This article provides a walkthrough of how `Equinox.Cosmos` encodes, writes and
This article provides a walkthrough of how `Equinox.CosmosStore` encodes, writes and
reads records from a stream under its control.

The code (see [source](src/Equinox.Cosmos/Cosmos.fs#L6)) contains lots of
The code (see [source](src/Equinox.CosmosStore/CosmosStore.fs#L6)) contains lots of
comments and is intended to be read - this just provides some background.

## Batches
Expand Down Expand Up @@ -1648,7 +1648,7 @@ basic elements

- Unfolds - the term `unfold` is based on the well known 'standard' FP function
of that name, bearing the signature `'state -> 'event seq`. **=> For
`Equinox.Cosmos`, one might say `unfold` yields _projection_ s as _event_ s
`Equinox.CosmosStore`, one might say `unfold` yields _projection_ s as _event_ s
to _snapshot_ the _state_ as at that _position_ in the _stream_**.

## Generating and saving `unfold`ed events
Expand Down Expand Up @@ -1742,9 +1742,9 @@ based on the events presented.

This covers what the most complete possible implementation of the JS Stored
Procedure (see
[source](https://github.com/jet/equinox/blob/tip-isa-batch/src/Equinox.Cosmos/Cosmos.fs#L302))
[source](https://github.com/jet/equinox/blob/tip-isa-batch/src/Equinox.CosmosStore/Cosmos.fs#L302))
does when presented with a batch to be written. (NB The present implementation
is slightly simplified; see [source](src/Equinox.Cosmos/Cosmos.fs#L303).
is slightly simplified; see [source](src/Equinox.CosmosStore/CosmosStore.fs#L404).

The `sync` stored procedure takes as input, a document that is almost identical
to the format of the _`Tip`_ batch (in fact, if the stream is found to be
Expand Down Expand Up @@ -1780,9 +1780,9 @@ stream). The request includes the following elements:
retrying in the case of conflict, _without any events being written per state
change_)

## Equinox.Cosmos.Core.Events
## Equinox.CosmosStore.Core.Events

The `Equinox.Cosmos.Core` namespace provides a lower level API that can be used
The `Equinox.CosmosStore.Core` namespace provides a lower level API that can be used
to manipulate events stored within a Azure CosmosDb using optimized native
access patterns.

Expand All @@ -1807,7 +1807,7 @@ following key benefits:

```fsharp

open Equinox.Cosmos.Core
open Equinox.CosmosStore.Core
// open MyCodecs.Json // example of using specific codec which can yield UTF-8
// byte arrays from a type using `Json.toBytes` via Fleece
// or similar
Expand All @@ -1818,7 +1818,7 @@ type EventData with

// Load connection sring from your Key Vault (example here is the CosmosDb
// simulator's well known key)
let connectionString: string =
let connectionString : string =
"AccountEndpoint=https://localhost:8081;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==;"

// Forward to Log (you can use `Log.Logger` and/or `Log.ForContext` if your app
Expand All @@ -1829,22 +1829,22 @@ let outputLog = LoggerConfiguration().WriteTo.NLog().CreateLogger()
let gatewayLog =
outputLog.ForContext(Serilog.Core.Constants.SourceContextPropertyName, "Equinox")

// When starting the app, we connect (once)
let connector : Equinox.Cosmos.Connector =
Connector(
let factory : Equinox.CosmosStore.CosmosStoreClientFactory =
CosmosStoreClientFactory(
requestTimeout = TimeSpan.FromSeconds 5.,
maxRetryAttemptsOnThrottledRequests = 1,
maxRetryWaitTimeInSeconds = 3,
log = gatewayLog)
let cnx =
connector.Connect("Application.CommandProcessor", Discovery.FromConnectionString connectionString)
let client =
factory.Create("Application.CommandProcessor", Discovery.FromConnectionString connectionString)
|> Async.RunSynchronously

let client = factory.Create(Discovery.ConnectionString connectionString)

// If storing in a single collection, one specifies the db and collection
// alternately use the overload that defers the mapping until the stream one is
// writing to becomes clear
let containerMap = Containers("databaseName", "containerName")
let ctx = Context(cnx, containerMap, gatewayLog)
// alternately use the overload that defers the mapping until the stream one is writing to becomes clear
let connection = CosmosStoreConnection(client, "databaseName", "containerName")
let ctx = EventsContext(connection, gatewayLog)

//
// Write an event
Expand All @@ -1870,7 +1870,7 @@ An Access Strategy defines any optimizations regarding how one arrives at a
State of an Aggregate based on the Events stored in a Stream in a Store.

The specifics of an Access Strategy depend on what makes sense for a given
Store, i.e. `Equinox.Cosmos` necessarily has a significantly different set of
Store, i.e. `Equinox.CosmosStore` necessarily has a significantly different set of
strategies than `Equinox.EventStore` (although there is an intersection).

Access Strategies only affect performance; you should still be able to infer
Expand All @@ -1881,9 +1881,9 @@ NOTE: its not important to select a strategy until you've actually actually
modelled your aggregate, see [what if I change my access
strategy](#changing-access-strategy)

## `Equinox.Cosmos.AccessStrategy`
## `Equinox.CosmosStore.AccessStrategy`

TL;DR `Equinox.Cosmos`: (see also: [the storage
TL;DR `Equinox.CosmosStore`: (see also: [the storage
model](cosmos-storage-model) for a deep dive, and [glossary,
below the table](#access-strategy-glossary) for definition of terms)
- keeps all the Events for a Stream in a single [CosmosDB _logical
Expand Down Expand Up @@ -2073,20 +2073,20 @@ EventStore, and it's Store adapter is the most proven and is pretty feature
rich relative to the need of consumers to date. Some things remain though:

- Provide a low level walking events in F# API akin to
`Equinox.Cosmos.Core.Events`; this would allow consumers to jump from direct
`Equinox.CosmosStore.Core.Events`; this would allow consumers to jump from direct
use of `EventStore.ClientAPI` -> `Equinox.EventStore.Core.Events` ->
`Equinox.Stream` (with the potential to swap stores once one gets to using
`Equinox.Stream`)
- Get conflict handling as efficient and predictable as for `Equinox.Cosmos`
- Get conflict handling as efficient and predictable as for `Equinox.CosmosStore`
https://github.com/jet/equinox/issues/28
- provide for snapshots to be stored out of the stream, and loaded in a
customizable manner in a manner analogous to
[the proposed comparable `Equinox.Cosmos` facility](https://github.com/jet/equinox/issues/61).
[the proposed comparable `Equinox.CosmosStore` facility](https://github.com/jet/equinox/issues/61).

## Wouldn't it be nice - `Equinox.Cosmos`
## Wouldn't it be nice - `Equinox.CosmosStore`

- Enable snapshots to be stored outside of the main collection in
`Equinox.Cosmos` [#61](https://github.com/jet/equinox/issues/61)
`Equinox.CosmosStore` [#61](https://github.com/jet/equinox/issues/61)
- Multiple writers support for `u`nfolds (at present a `sync` completely
replaces the unfolds in the Tip; this will be extended by having the stored
proc maintain the union of the unfolds in play (both for semi-related
Expand Down
4 changes: 2 additions & 2 deletions Equinox.sln
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Equinox.MemoryStore.Integra
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Equinox.Tool", "tools\Equinox.Tool\Equinox.Tool.fsproj", "{C8992C1C-6DC5-42CD-A3D7-1C5663433FED}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Equinox.Cosmos", "src\Equinox.Cosmos\Equinox.Cosmos.fsproj", "{54EA6187-9F9F-4D67-B602-163D011E43E6}"
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Equinox.CosmosStore", "src\Equinox.CosmosStore\Equinox.CosmosStore.fsproj", "{54EA6187-9F9F-4D67-B602-163D011E43E6}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Equinox.Cosmos.Integration", "tests\Equinox.Cosmos.Integration\Equinox.Cosmos.Integration.fsproj", "{DE0FEBF0-72DC-4D4A-BBA7-788D875D6B4B}"
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Equinox.CosmosStore.Integration", "tests\Equinox.CosmosStore.Integration\Equinox.CosmosStore.Integration.fsproj", "{DE0FEBF0-72DC-4D4A-BBA7-788D875D6B4B}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "TodoBackend", "samples\TodoBackend\TodoBackend.fsproj", "{EC2EC658-3D85-44F3-AD2F-52AFCAFF8871}"
EndProject
Expand Down
Loading