Skip to content

Commit

Permalink
net6.0/diff reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Feb 28, 2022
1 parent eaae087 commit 367fb21
Show file tree
Hide file tree
Showing 20 changed files with 44 additions and 49 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The `Unreleased` section name is replaced by the expected version of next releas
### Added
### Changed

- Remove explicit `net461` handling; minimum target now `netstandard 2.1` / `net5.0` [#310](https://github.com/jet/equinox/pull/310)
- Remove explicit `net461` handling; minimum target now `netstandard 2.1` / `net6.0` [#310](https://github.com/jet/equinox/pull/310)

### Removed
### Fixed
Expand Down
4 changes: 2 additions & 2 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<PrOption Condition =" '$(BUILD_PR)' != '%24(SYSTEM.PULLREQUEST.PULLREQUESTNUMBER)' ">/p:BUILD_PR=$(BUILD_PR) </PrOption>
<PackOptions>/p:BUILD_ID=$(BUILD_ID) $(PrOption) -o $(ThisDirAbsolute)bin/nupkg</PackOptions>

<TestOptions>--logger:trx</TestOptions>
</PropertyGroup>

Expand All @@ -36,4 +36,4 @@
<Exec Command="dotnet build samples/Tutorial $(Cfg)" />
</Target>

</Project>
</Project>
2 changes: 1 addition & 1 deletion diagrams/EventStore.puml
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ esproj .U.> reactors : track relevant events fed from
reactors .R.> caches : maintain\nviews\nin
projectors .U.> outputs : emit to

@enduml
@enduml
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "5.0.200",
"version": "6.0",
"rollForward": "latestFeature"
}
}
7 changes: 3 additions & 4 deletions samples/Infrastructure/Infrastructure.fsproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<WarningLevel>5</WarningLevel>
<IsTestProject>false</IsTestProject>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
Expand All @@ -28,10 +28,9 @@

<ItemGroup>
<PackageReference Include="Argu" Version="6.0.0" />
<!--Note .NetCore sufficed package is not an officially suported package and is not longer needed-->
<PackageReference Include="Destructurama.FSharp" Version="1.1.1-dev-00033" />
<PackageReference Include="Destructurama.FSharp" Version="1.2.0" />
<PackageReference Include="FSharp.Core" Version="4.3.4" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.0" />
<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.9.0" />
Expand Down
4 changes: 2 additions & 2 deletions samples/Infrastructure/Storage.fs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module Cosmos =

/// Standing up an Equinox instance is necessary to run for test purposes; You'll need to either:
/// 1) replace connection below with a connection string or Uri+Key for an initialized Equinox instance with a database and collection named "equinox-test"
/// 2) Set the 3x environment variables and create a local Equinox using tools/Equinox.Tool/bin/Release/net5.0/eqx.exe `
/// 2) Set the 3x environment variables and create a local Equinox using tools/Equinox.Tool/bin/Release/net6.0/eqx.exe `
/// init -ru 1000 cosmos -s $env:EQUINOX_COSMOS_CONNECTION -d $env:EQUINOX_COSMOS_DATABASE -c $env:EQUINOX_COSMOS_CONTAINER
open Equinox.CosmosStore
open Serilog
Expand Down Expand Up @@ -171,7 +171,7 @@ module EventStore =
let private createContext connection batchSize = EventStoreContext(connection, BatchingPolicy(maxBatchSize = batchSize))
let config (log: ILogger, storeLog) (cache, unfolds) (args : ParseResults<Arguments>) =
let a = Info(args)
let (timeout, retries) as operationThrottling = a.Timeout, a.Retries
let timeout, retries as operationThrottling = a.Timeout, a.Retries
let heartbeatTimeout = a.HeartbeatTimeout
let concurrentOperationsLimit = a.ConcurrentOperationsLimit
log.Information("EventStoreDB {host} heartbeat: {heartbeat}s timeout: {timeout}s concurrent reqs: {concurrency} retries {retries}",
Expand Down
3 changes: 1 addition & 2 deletions samples/Store/Integration/Integration.fsproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<WarningLevel>5</WarningLevel>
<DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference>
Expand All @@ -21,7 +21,6 @@
<ProjectReference Include="..\..\..\src\Equinox.CosmosStore\Equinox.CosmosStore.fsproj" />
<ProjectReference Include="..\..\..\src\Equinox.EventStore\Equinox.EventStore.fsproj" />
<ProjectReference Include="..\..\..\src\Equinox.MemoryStore\Equinox.MemoryStore.fsproj" />
<ProjectReference Include="..\..\..\src\Equinox\Equinox.fsproj" />
<ProjectReference Include="..\..\..\tests\Equinox.CosmosStore.Integration\Equinox.CosmosStore.Integration.fsproj" />
<ProjectReference Include="..\..\..\tests\Equinox.EventStore.Integration\Equinox.EventStore.Integration.fsproj" />
<ProjectReference Include="..\Domain\Domain.fsproj" />
Expand Down
3 changes: 1 addition & 2 deletions samples/Tutorial/Tutorial.fsproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<WarningLevel>5</WarningLevel>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
Expand All @@ -25,7 +25,6 @@
<ProjectReference Include="..\..\src\Equinox.CosmosStore\Equinox.CosmosStore.fsproj" />
<ProjectReference Include="..\..\src\Equinox.EventStore\Equinox.EventStore.fsproj" />
<ProjectReference Include="..\..\src\Equinox.MemoryStore\Equinox.MemoryStore.fsproj" />
<ProjectReference Include="..\..\src\Equinox\Equinox.fsproj" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions samples/Web/Startup.fs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ type Startup() =
// The key side-effect we want to guarantee is that we reference `FsCodec.SystemTextJson`,
// which will trigger a dependency on `System.Text.Json` >= `6.0.1`
// This makes F# records roundtrip (System.Text.Json v4 required parameterless constructors on records)
|> Seq.iter o.JsonSerializerOptions.Converters.Add)
.SetCompatibilityVersion(CompatibilityVersion.Latest) |> ignore
|> Seq.iter o.JsonSerializerOptions.Converters.Add) |> ignore

let verbose = args.Contains Verbose
let maybeSeq = if args.Contains LocalSeq then Some "http://localhost:5341" else None
Expand Down
2 changes: 1 addition & 1 deletion samples/Web/Web.fsproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Equinox.EventStore/Equinox.EventStore.fsproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<WarningLevel>5</WarningLevel>
<IsTestProject>false</IsTestProject>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
Expand Down
42 changes: 21 additions & 21 deletions src/Equinox.SqlStreamStore/SqlStreamStore.fs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module Log =
// Sidestep Log.ForContext converting to a string; see https://github.com/serilog/serilog/issues/1124
let event (value : Event) (log : ILogger) =
let enrich (e : LogEvent) = e.AddPropertyIfAbsent(LogEventProperty(PropertyTag, ScalarValue(value)))
log.ForContext({ new Serilog.Core.ILogEventEnricher with member __.Enrich(evt, _) = enrich evt })
log.ForContext({ new Serilog.Core.ILogEventEnricher with member _.Enrich(evt, _) = enrich evt })
let withLoggedRetries<'t> retryPolicy (contextLabel : string) (f : ILogger -> Async<'t>) log : Async<'t> =
match retryPolicy with
| None -> f log
Expand Down Expand Up @@ -83,9 +83,9 @@ module Log =
type Counter =
{ mutable count : int64; mutable ms : int64 }
static member Create() = { count = 0L; ms = 0L }
member __.Ingest(ms) =
System.Threading.Interlocked.Increment(&__.count) |> ignore
System.Threading.Interlocked.Add(&__.ms, ms) |> ignore
member x.Ingest(ms) =
System.Threading.Interlocked.Increment(&x.count) |> ignore
System.Threading.Interlocked.Add(&x.ms, ms) |> ignore
type LogSink() =
static let epoch = System.Diagnostics.Stopwatch.StartNew()
static member val Read = Counter.Create() with get, set
Expand All @@ -99,7 +99,7 @@ module Log =
epoch.Restart()
span
interface Serilog.Core.ILogEventSink with
member __.Emit logEvent = logEvent |> function
member _.Emit logEvent = logEvent |> function
| EsMetric (Read stats) -> LogSink.Read.Ingest stats
| EsMetric (Write stats) -> LogSink.Write.Ingest stats
| EsMetric (Resync stats) -> LogSink.Resync.Ingest stats
Expand Down Expand Up @@ -339,34 +339,34 @@ module Token =
newVersion > currentVersion

type SqlStreamStoreConnection(readConnection, [<O; D(null)>]?writeConnection, [<O; D(null)>]?readRetryPolicy, [<O; D(null)>]?writeRetryPolicy) =
member __.ReadConnection = readConnection
member __.ReadRetryPolicy = readRetryPolicy
member __.WriteConnection = defaultArg writeConnection readConnection
member __.WriteRetryPolicy = writeRetryPolicy
member _.ReadConnection = readConnection
member _.ReadRetryPolicy = readRetryPolicy
member _.WriteConnection = defaultArg writeConnection readConnection
member _.WriteRetryPolicy = writeRetryPolicy

type BatchingPolicy(getMaxBatchSize : unit -> int, [<O; D(null)>]?batchCountLimit) =
new (maxBatchSize) = BatchingPolicy(fun () -> maxBatchSize)
member __.BatchSize = getMaxBatchSize()
member __.MaxBatches = batchCountLimit
member _.BatchSize = getMaxBatchSize()
member _.MaxBatches = batchCountLimit

[<RequireQualifiedAccess; NoComparison; NoEquality>]
type GatewaySyncResult = Written of StreamToken | ConflictUnknown

type SqlStreamStoreContext(connection : SqlStreamStoreConnection, batching : BatchingPolicy) =
let isResolvedEventEventType (tryDecode, predicate) (e:StreamMessage) =
let isResolvedEventEventType (tryDecode, predicate) (e : StreamMessage) =
let data = e.GetJsonData() |> Async.AwaitTask |> Async.RunSynchronously
predicate (tryDecode data)
let tryIsResolvedEventEventType predicateOption = predicateOption |> Option.map isResolvedEventEventType
member internal _.LoadEmpty streamName = Token.ofUncompactedVersion batching.BatchSize streamName -1L
member _.LoadBatched streamName log (tryDecode, isCompactionEventType): Async<StreamToken * 'event[]> = async {
member _.LoadBatched streamName log (tryDecode, isCompactionEventType) : Async<StreamToken * 'event[]> = async {
let! version, events = Read.loadForwardsFrom log connection.ReadRetryPolicy connection.ReadConnection batching.BatchSize batching.MaxBatches streamName 0L
match tryIsResolvedEventEventType isCompactionEventType with
| None -> return Token.ofNonCompacting streamName version, Array.choose tryDecode events
| Some isCompactionEvent ->
match events |> Array.tryFindBack isCompactionEvent with
| None -> return Token.ofUncompactedVersion batching.BatchSize streamName version, Array.choose tryDecode events
| Some resolvedEvent -> return Token.ofCompactionResolvedEventAndVersion resolvedEvent batching.BatchSize streamName version, Array.choose tryDecode events }
member _.LoadBackwardsStoppingAtCompactionEvent streamName log (tryDecode, isOrigin): Async<StreamToken * 'event []> = async {
member _.LoadBackwardsStoppingAtCompactionEvent streamName log (tryDecode, isOrigin) : Async<StreamToken * 'event []> = async {
let! version, events =
Read.loadBackwardsUntilCompactionOrStart log connection.ReadRetryPolicy connection.ReadConnection batching.BatchSize batching.MaxBatches streamName (tryDecode, isOrigin)
match Array.tryHead events |> Option.filter (function _, Some e -> isOrigin e | _ -> false) with
Expand Down Expand Up @@ -400,7 +400,7 @@ type SqlStreamStoreContext(connection : SqlStreamStoreConnection, batching : Bat
| Some compactionEventIndex ->
Token.ofPreviousStreamVersionAndCompactionEventDataIndex streamToken compactionEventIndex encodedEvents.Length batching.BatchSize version'
return GatewaySyncResult.Written token }
member __.Sync(log, streamName, streamVersion, events : FsCodec.IEventData<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 connection.WriteRetryPolicy connection.WriteConnection streamName streamVersion encodedEvents
match wr with
Expand All @@ -425,7 +425,7 @@ type AccessStrategy<'event, 'state> =

type private CompactionContext(eventsLen : int, capacityBeforeCompaction : int) =
/// Determines whether writing a Compaction event is warranted (based on the existing state and the current accumulated changes)
member __.IsCompactionDue = eventsLen > capacityBeforeCompaction
member _.IsCompactionDue = eventsLen > capacityBeforeCompaction

type private Category<'event, 'state, 'context>(context : SqlStreamStoreContext, codec : FsCodec.IEventCodec<_, _, 'context>, ?access : AccessStrategy<'event, 'state>) =
let tryDecode (e : ResolvedEvent) = e |> UnionEncoderAdapters.encodedEventOfResolvedEvent |> codec.TryDecode
Expand Down Expand Up @@ -453,13 +453,13 @@ type private Category<'event, 'state, 'context>(context : SqlStreamStoreContext,
member _.LoadFromToken (fold : 'state -> 'event seq -> 'state) (state : 'state) (streamName : string) token (log : ILogger) : Async<StreamToken * 'state> =
(load fold) state (context.LoadFromToken false streamName log token (tryDecode, compactionPredicate))
member _.TrySync<'context>
( log : ILogger, fold: 'state -> 'event seq -> 'state,
( log : ILogger, fold : 'state -> 'event seq -> 'state,
(Token.StreamPos (stream,pos) as streamToken), state : 'state, events : 'event list, ctx : 'context option): Async<SyncResult<'state>> = async {
let encode e = codec.Encode(ctx,e)
let encode e = codec.Encode(ctx, e)
let events =
match access with
| None | Some AccessStrategy.LatestKnownEvent -> events
| Some (AccessStrategy.RollingSnapshots (_,compact)) ->
| Some (AccessStrategy.RollingSnapshots (_, compact)) ->
let cc = CompactionContext(List.length events, pos.batchCapacityLimit.Value)
if cc.IsCompactionDue then events @ [fold state events |> compact] else events

Expand Down Expand Up @@ -595,7 +595,7 @@ type ConnectorBase([<O; D(null)>]?readRetryPolicy, [<O; D(null)>]?writeRetryPoli

abstract member Connect : unit -> Async<IStreamStore>

member __.Establish() : Async<SqlStreamStoreConnection> = async {
let! store = __.Connect()
member x.Establish() : Async<SqlStreamStoreConnection> = async {
let! store = x.Connect()
return SqlStreamStoreConnection(readConnection=store, writeConnection=store, ?readRetryPolicy=readRetryPolicy, ?writeRetryPolicy=writeRetryPolicy)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<WarningLevel>5</WarningLevel>
<DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<WarningLevel>5</WarningLevel>
<DefineConstants>$(DefineConstants);STORE_EVENTSTORE</DefineConstants>
Expand All @@ -16,7 +16,6 @@
<ItemGroup>
<ProjectReference Include="..\..\samples\Store\Domain\Domain.fsproj" />
<ProjectReference Include="..\..\src\Equinox.EventStore\Equinox.EventStore.fsproj" />
<ProjectReference Include="..\..\src\Equinox\Equinox.fsproj" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion tests/Equinox.EventStore.Integration/Infrastructure.fs
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ module SerilogHelpers =
member __.Clear () = captured.Clear()
member __.Entries = captured.ToArray()
member __.ChooseCalls chooser = captured |> Seq.choose chooser |> List.ofSeq
member __.ExternalCalls = __.ChooseCalls (function EsEvent (EsAction act) -> Some act | _ -> None)
member __.ExternalCalls = __.ChooseCalls (function EsEvent (EsAction act) -> Some act | _ -> None)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<WarningLevel>5</WarningLevel>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<WarningLevel>5</WarningLevel>
<DefineConstants>$(DefineConstants);STORE_MSSQL</DefineConstants>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<WarningLevel>5</WarningLevel>
<DefineConstants>$(DefineConstants);STORE_MYSQL</DefineConstants>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<WarningLevel>5</WarningLevel>
<DefineConstants>$(DefineConstants);STORE_POSTGRES</DefineConstants>
Expand Down
2 changes: 1 addition & 1 deletion tools/Equinox.Tool/Equinox.Tool.fsproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Exe</OutputType>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<WarningLevel>5</WarningLevel>
Expand Down

0 comments on commit 367fb21

Please sign in to comment.