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

Adapt to FsCodec name changes #162

Merged
merged 3 commits into from
Sep 22, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The `Unreleased` section name is replaced by the expected version of next releas
### Changed

- Updated `MinVer` to `2.0.0-alpha.2`
- Updated `FsCodec` to `1.0.0-pr.20.rc2.5` to pick up final name changes [#162](https://github.com/jet/equinox/pull/162)
- Replaced `TargetId.AggregateIdEmpty` with `ResolveOption.AssumeEmpty` [#163](https://github.com/jet/equinox/pull/163)

### Removed
Expand Down
2 changes: 1 addition & 1 deletion samples/Store/Domain/Domain.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<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="FsCodec.NewtonsoftJson" Version="1.0.0-rc2" />
<PackageReference Include="FsCodec.NewtonsoftJson" Version="1.0.0-pr.20.rc2.5" />
<PackageReference Include="FSharp.UMX" Version="1.0.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion samples/Store/Integration/CodecIntegration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ let codec = FsCodec.NewtonsoftJson.Codec.Create()
let ``Can roundtrip, rendering correctly`` (x: SimpleDu) =
let serialized = codec.Encode x
render x =! if serialized.Data = null then null else System.Text.Encoding.UTF8.GetString(serialized.Data)
let adapted = FsCodec.Core.IndexedEventData(-1L,false,serialized.EventType,serialized.Data,serialized.Meta,serialized.Timestamp)
let adapted = FsCodec.Core.TimelineEvent.Create(-1L, serialized.EventType, serialized.Data, serialized.Meta, serialized.Timestamp)
let deserialized = codec.TryDecode adapted |> Option.get
deserialized =! x
2 changes: 1 addition & 1 deletion samples/Tutorial/AsAt.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module Events =
// unlike most normal codecs, we have a mapping to supply as we want the Index to be added to each event so we can track it in the State as we fold
let codec =
// our upconversion function doesn't actually fit the term - it just tuples the underlying event
let up (evt : FsCodec.IIndexedEvent<_>,e) : Event =
let up (evt : FsCodec.ITimelineEvent<_>,e) : Event =
evt.Index,e
// as per the `up`, the downcoverter needs to drop the index (which is only there for symmetry), add null metadata
let down (_,e) : Contract * _ option * DateTimeOffset option =
Expand Down
93 changes: 47 additions & 46 deletions src/Equinox.Cosmos/Cosmos.fs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Equinox.Cosmos/Equinox.Cosmos.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<PackageReference Include="FSharp.Core" Version="3.1.2.5" Condition=" '$(TargetFramework)' != 'netstandard2.0' " />
<PackageReference Include="FSharp.Core" Version="4.3.4" Condition=" '$(TargetFramework)' == 'netstandard2.0' " />

<PackageReference Include="FsCodec.NewtonsoftJson" Version="1.0.0-rc2" />
<PackageReference Include="FsCodec.NewtonsoftJson" Version="1.0.0-pr.20.rc2.5" />
<PackageReference Include="FSharp.Control.AsyncSeq" Version="2.0.21" />
<PackageReference Include="Microsoft.Azure.DocumentDB" Version="2.0.0" Condition=" '$(TargetFramework)' != 'netstandard2.0' " />
<PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="2.0.0" Condition=" '$(TargetFramework)' == 'netstandard2.0' " />
Expand Down
2 changes: 1 addition & 1 deletion src/Equinox.EventStore/Equinox.EventStore.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<PackageReference Include="FSharp.Core" Version="4.3.4" Condition=" '$(TargetFramework)' == 'netstandard2.0' " />

<PackageReference Include="EventStore.Client" Version="5.0.1" />
<PackageReference Include="FsCodec" Version="1.0.0-rc2" />
<PackageReference Include="FsCodec" Version="1.0.0-pr.20.rc2.5" />
<PackageReference Include="FSharp.Control.AsyncSeq" Version="2.0.21" />
<PackageReference Include="System.Runtime.Caching" Version="4.5.0" Condition=" '$(TargetFramework)' == 'netstandard2.0' " />
<Reference Include="System.Runtime.Caching" Condition=" '$(TargetFramework)' != 'netstandard2.0'" />
Expand Down
8 changes: 4 additions & 4 deletions src/Equinox.EventStore/EventStore.fs
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,12 @@ module private Read =
return version, events }

module UnionEncoderAdapters =
let encodedEventOfResolvedEvent (x : ResolvedEvent) : FsCodec.IIndexedEvent<byte[]> =
let encodedEventOfResolvedEvent (x : ResolvedEvent) : FsCodec.ITimelineEvent<byte[]> =
let e = x.Event
// Inspecting server code shows both Created and CreatedEpoch are set; taking this as it's less ambiguous than DateTime in the general case
let ts = DateTimeOffset.FromUnixTimeMilliseconds(e.CreatedEpoch)
FsCodec.Core.IndexedEventData(e.EventNumber, (*isUnfold*)false, e.EventType, e.Data, e.Metadata, ts) :> _
let eventDataOfEncodedEvent (x : FsCodec.IEvent<byte[]>) =
FsCodec.Core.TimelineEvent.Create(e.EventNumber, e.EventType, e.Data, e.Metadata, ts) :> _
let eventDataOfEncodedEvent (x : FsCodec.IEventData<byte[]>) =
EventData(Guid.NewGuid(), x.EventType, (*isJson*) true, x.Data, x.Meta)

type Stream = { name: string }
Expand Down Expand Up @@ -378,7 +378,7 @@ type Context(conn : Connection, batching : BatchingPolicy) =
| Some compactionEventIndex ->
Token.ofPreviousStreamVersionAndCompactionEventDataIndex streamToken compactionEventIndex encodedEvents.Length batching.BatchSize version'
return GatewaySyncResult.Written token }
member __.Sync(log, streamName, streamVersion, events: FsCodec.IEvent<byte[]>[]) : Async<GatewaySyncResult> = async {
member __.Sync(log, streamName, streamVersion, events: FsCodec.IEventData<byte[]>[]) : Async<GatewaySyncResult> = async {
let encodedEvents : EventData[] = events |> Array.map UnionEncoderAdapters.eventDataOfEncodedEvent
let! wr = Write.writeEvents log conn.WriteRetryPolicy conn.WriteConnection streamName streamVersion encodedEvents
match wr with
Expand Down
5 changes: 2 additions & 3 deletions tests/Equinox.Cosmos.Integration/CosmosCoreIntegration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

open Equinox.Cosmos.Core
open Equinox.Cosmos.Integration.Infrastructure
open FsCodec
open FSharp.Control
open FsCodec // Shadow FSharp.Control.IEvent
open FsCodec.Core
open Newtonsoft.Json.Linq
open Swensen.Unquote
open Serilog
Expand Down Expand Up @@ -92,7 +91,7 @@ type Tests(testOutputHelper) =
return TestEvents.Create(0,6)
}

let verifyCorrectEventsEx direction baseIndex (expected: IEvent<_>[]) (xs: IIndexedEvent<_>[]) =
let verifyCorrectEventsEx direction baseIndex (expected: IEventData<_>[]) (xs: ITimelineEvent<byte[]>[]) =
let xs, baseIndex =
if direction = Equinox.Cosmos.Store.Direction.Forward then xs, baseIndex
else Array.rev xs, baseIndex - int64 (Array.length expected) + 1L
Expand Down
2 changes: 1 addition & 1 deletion tests/Equinox.Cosmos.Integration/JsonConverterTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ type Base64ZipUtf8Tests() =
let ser = JsonConvert.SerializeObject(e)
test <@ ser.Contains("\"d\":\"") @>
let des = JsonConvert.DeserializeObject<Store.Unfold>(ser)
let d = FsCodec.Core.IndexedEventData(-1L, false, des.c, des.d, null, DateTimeOffset.UtcNow)
let d = FsCodec.Core.TimelineEvent.Create(-1L, des.c, des.d)
let decoded = unionEncoder.TryDecode d |> Option.get
test <@ value = decoded @>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<ItemGroup>
<PackageReference Include="FsCheck.xUnit" Version="2.13.0" />
<PackageReference Include="FsCodec.NewtonsoftJson" Version="1.0.0-rc2" />
<PackageReference Include="FsCodec.NewtonsoftJson" Version="1.0.0-pr.20.rc2.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="4.0.0" />
<Reference Include="System.Runtime.Caching" Condition=" '$(TargetFramework)' != 'netstandard2.0'" />
Expand Down