Skip to content

Commit

Permalink
Port to Azure.Cosmos / v3 SDK (#144)
Browse files Browse the repository at this point in the history
NOTE eqx dump is broken
  • Loading branch information
bartelink authored Feb 12, 2020
1 parent e80cd11 commit 9d58b7f
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 124 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ The `Unreleased` section name is replaced by the expected version of next releas
## [Unreleased]

### Added

- now targets `Microsoft.Azure.Cosmos` v `3.1.1` (instead of `Microsoft.Azure.DocumentDB`[`.Core`] v 2.x) [#144](https://github.com/jet/equinox/pull/144)

### Changed


Expand Down
1 change: 1 addition & 0 deletions samples/Infrastructure/Infrastructure.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.Seq" Version="4.0.0" />
<PackageReference Include="Microsoft.Azure.Cosmos.Direct" Version="3.1.4" />
<Reference Include="System.Runtime.Caching" Condition=" '$(TargetFramework)' != 'netstandard2.0' " />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions samples/Infrastructure/Storage.fs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module Cosmos =

type [<NoEquality; NoComparison>] Arguments =
| [<AltCommandLine "-V">] VerboseStore
| [<AltCommandLine "-m">] ConnectionMode of Equinox.Cosmos.ConnectionMode
| [<AltCommandLine "-m">] ConnectionMode of Microsoft.Azure.Cosmos.ConnectionMode
| [<AltCommandLine "-o">] Timeout of float
| [<AltCommandLine "-r">] Retries of int
| [<AltCommandLine "-rt">] RetriesWaitTimeS of float
Expand All @@ -54,7 +54,7 @@ module Cosmos =
| Database _ -> "specify a database name for store. (optional if environment variable EQUINOX_COSMOS_DATABASE specified)"
| Container _ -> "specify a container name for store. (optional if environment variable EQUINOX_COSMOS_CONTAINER specified)"
type Info(args : ParseResults<Arguments>) =
member __.Mode = args.GetResult(ConnectionMode,Equinox.Cosmos.ConnectionMode.Direct)
member __.Mode = args.GetResult(ConnectionMode,Microsoft.Azure.Cosmos.ConnectionMode.Direct)
member __.Connection = args.TryGetResult Connection |> defaultWithEnvVar "EQUINOX_COSMOS_CONNECTION" "Connection"
member __.Database = args.TryGetResult Database |> defaultWithEnvVar "EQUINOX_COSMOS_DATABASE" "Database"
member __.Container = args.TryGetResult Container |> defaultWithEnvVar "EQUINOX_COSMOS_CONTAINER" "Container"
Expand Down
13 changes: 12 additions & 1 deletion samples/Tutorial/Sequence.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ module Sequence

open System

// shim for net461
module Seq =
let tryLast (source : seq<_>) =
use e = source.GetEnumerator()
if e.MoveNext() then
let mutable res = e.Current
while (e.MoveNext()) do res <- e.Current
Some res
else
None

// NOTE - these types and the union case names reflect the actual storage formats and hence need to be versioned with care
module Events =

Expand Down Expand Up @@ -57,4 +68,4 @@ module Cosmos =
module RollingUnfolds =

let createService (context,cache) =
createService (context,cache,AccessStrategy.RollingState Fold.snapshot)
createService (context,cache,AccessStrategy.RollingState Fold.snapshot)
5 changes: 5 additions & 0 deletions samples/Tutorial/Tutorial.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<WarningLevel>5</WarningLevel>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference>
</PropertyGroup>

<ItemGroup>
Expand All @@ -29,6 +31,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FSharp.Core" Version="3.1.2.5" Condition=" '$(TargetFramework)' == 'net461' " />
<PackageReference Include="FSharp.Core" Version="4.3.4" Condition=" '$(TargetFramework)' == 'netstandard2.0' " />

<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.Seq" Version="4.0.0" />
<PackageReference Include="FSharp.UMX" Version="1.0.0" />
Expand Down
15 changes: 13 additions & 2 deletions samples/Tutorial/Upload.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ module Upload
open System
open FSharp.UMX

// shim for net461
module Seq =
let tryLast (source : seq<_>) =
use e = source.GetEnumerator()
if e.MoveNext() then
let mutable res = e.Current
while (e.MoveNext()) do res <- e.Current
Some res
else
None

type PurchaseOrderId = int<purchaseOrderId>
and [<Measure>] purchaseOrderId
module PurchaseOrderId =
Expand Down Expand Up @@ -38,7 +49,7 @@ module Fold =
let private evolve _ignoreState = function
| Events.IdAssigned e -> Some e.value
let fold (state: State) (events: seq<Events.Event>) : State =
Seq.tryLast events |> Option.fold evolve state
events |> Seq.tryLast |> Option.fold evolve state

let decide (value : UploadId) (state : Fold.State) : Choice<UploadId,UploadId> * Events.Event list =
match state with
Expand Down Expand Up @@ -67,4 +78,4 @@ module EventStore =
open Equinox.EventStore
let createService context =
let resolve = Resolver(context, Events.codec, Fold.fold, Fold.initial, access=AccessStrategy.LatestKnownEvent).Resolve
create resolve
create resolve
Loading

0 comments on commit 9d58b7f

Please sign in to comment.