Skip to content

Commit 6b9e795

Browse files
committed
Tidy
1 parent 8d43b1f commit 6b9e795

File tree

3 files changed

+23
-31
lines changed

3 files changed

+23
-31
lines changed

CHANGELOG.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,18 @@ The `Unreleased` section name is replaced by the expected version of next releas
1616
- `Equinox.CosmosStore`: Group metrics by Category; split out `Tip` activity [#453](https://github.com/jet/equinox/pull/453)
1717
- `Equinox.CosmosStore`: Support Ingesting unfolds [#460](https://github.com/jet/equinox/pull/460)
1818
- `Equinox.CosmosStore.EventsContext.Sync`: Support syncing of unfolds [#460](https://github.com/jet/equinox/pull/460)
19+
- `eqx`: `-Q` flag omits timestamps from console output logging [#459](https://github.com/jet/equinox/pull/459)
20+
- `eqx destroy`: Support for deleting the items (documents) underlying a category/stream/arbitrary `WHERE` clause [#473](https://github.com/jet/equinox/pull/473)
21+
- `eqx top`: Support for analyzing space usage for event and view containers by category and/or stream [#473](https://github.com/jet/equinox/pull/473)
1922
- `eqx dump`, `eqx query`: `-sl` Support for specifying streams to dump via a [CosmosDB `LIKE` expression](https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/query/keywords#like) [#473](https://github.com/jet/equinox/pull/473)
2023
- `eqx dump`: `-Q` strips intervals, regularizes snapshots, logs stream names [#473](https://github.com/jet/equinox/pull/473)
21-
- `eqx destroy`: Support for deleting the items(documents) underlying a category/stream/arbitrary `WHERE` clause [#473](https://github.com/jet/equinox/pull/473)
2224
- `eqx stats`: `-O`, `-N` flags extract oldest and newest `_ts` within a store [#459](https://github.com/jet/equinox/pull/459)
23-
- `eqx stats`: `-U` flag to count streams with unfolds and total number thereof; `-I` alias relabel Documents as Items [#464](https://github.com/jet/equinox/pull/464)
25+
- `eqx stats`: `-U` flag to count streams with unfolds and total number thereof [#464](https://github.com/jet/equinox/pull/464)
2426
- `eqx stats`: `-I` flag; relabel Documents as Items, retaining existing `-D` flag [#464](https://github.com/jet/equinox/pull/464)
25-
- `eqx top`: Support for analyzing space usage for event and view containers by category and/or stream [#473](https://github.com/jet/equinox/pull/473)
26-
- `eqx`: `-Q` flag omits timestamps from console output logging [#459](https://github.com/jet/equinox/pull/459)
2727

2828
### Changed
2929

30+
- `Equinox.*Store`,`Equinox.*Store.Prometheus`: Pin `Equinox` dependencies to `[4.0.0, 5.0.0)`] [#448](https://github.com/jet/equinox/pull/448)
3031
- `Equinox.CosmosStore`: Update `System.Text.Json` dep to `6.0.10` per [CVE-2024-43485](https://github.com/advisories/GHSA-8g4q-xg66-9fp4) [#470](https://github.com/jet/equinox/pull/470)
3132
- `Equinox.CosmosStore`: Minimum `Microsoft.Azure.Cosmos` requirement updated to `3.43.1` to avail of integrated `System.Text.Json` support [#467](https://github.com/jet/equinox/pull/467)
3233
- `Equinox.CosmosStore.CosmosStoreConnector`: Removed mandatory `requestTimeout` argument [#467](https://github.com/jet/equinox/pull/467)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ While Equinox is implemented in F#, and F# is a great fit for writing event-sour
390390
391391
# use a wild card (LIKE) for the stream name
392392
eqx query -cl '$Us%' -un Snapshotted cosmos -d db -c $EQUINOX_COSMOS_VIEWS -b 100000
393-
# > Querying Default: SELECT c.p, c._etag, c.u[0].d FROM c WHERE c.p LIKE "$Us%" AND EXISTS (SELECT VALUE u FROM u IN c.u WHERE u.c = "Snapshotted") {}
393+
# > Querying Default: SELECT c.p, c.u[0].D, c.u[0].d, c._etag FROM c WHERE c.p LIKE "$Us%" AND EXISTS (SELECT VALUE u FROM u IN c.u WHERE u.c = "Snapshotted") {}
394394
# > Page 7166s, 7166u, 0e 320.58RU 3.9s {}
395395
# > Page 1608s, 1608u, 0e 68.59RU 0.9s {}
396396
# > TOTALS 1c, 8774s, 389.17RU 4.7s {}
@@ -403,7 +403,7 @@ While Equinox is implemented in F#, and F# is a great fit for writing event-sour
403403
404404
# add criteria filtering based on an Uncompressed Unfold
405405
eqx query -cn '$User' -un EmailIndex -uc 'u.d.email = "[email protected]"' cosmos -d db -c $EQUINOX_COSMOS_VIEWS -b 100000
406-
# > Querying Default: SELECT c.p, c._etag, c.u[0].d FROM c WHERE c.p LIKE "$User-%" AND EXISTS (SELECT VALUE u FROM u IN c.u WHERE u.c = "EmailIndex" AND u.d.email = "[email protected]") {}
406+
# > Querying Default: SELECT c.p, c.u[0].D, c.u[0].d, c._etag FROM c WHERE c.p LIKE "$User-%" AND EXISTS (SELECT VALUE u FROM u IN c.u WHERE u.c = "EmailIndex" AND u.d.email = "[email protected]") {}
407407
# > Page 0s, 0u, 0e 2.8RU 0.7s {}
408408
# > TOTALS 0c, 0s, 2.80RU 0.7s {} # 👈 only 2.8RU if nothing is returned
409409

tools/Equinox.Tool/Program.fs

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66

77
open Argu
88
open FSharp.AWS.DynamoDB // Throughput
9+
open FSharp.Control
910
open Samples.Infrastructure
1011
open Serilog
1112
open Serilog.Events
1213
open System
1314
open System.Threading
1415

1516
module CosmosInit = Equinox.CosmosStore.Core.Initialization
17+
let inline miB x = Equinox.CosmosStore.Linq.Internal.miB x
1618

1719
let [<Literal>] appName = "equinox-tool"
1820

@@ -118,7 +120,7 @@ and [<NoComparison; NoEquality; RequireSubcommand>] StatsParameters =
118120
| Events -> "Count the number of Events in the store."
119121
| Unfolds -> "Count the number of Unfolds in the store."
120122
| Streams -> "Count the number of Streams in the store."
121-
| Items -> "Count the number of Items(Documents) in the store."
123+
| Items -> "Count the number of Items (documents) in the store."
122124
| Oldest -> "Oldest document, based on the _ts field"
123125
| Newest -> "Newest document, based on the _ts field"
124126
| Parallel -> "Run in Parallel (CAREFUL! can overwhelm RU allocations)."
@@ -144,17 +146,17 @@ and [<NoComparison; NoEquality; RequireSubcommand>] QueryParameters =
144146
| CategoryLike _ -> "Specify category name to match against `p` as a Cosmos LIKE expression (with `%` as wildcard, e.g. `$UserServices-%`)."
145147
| UnfoldName _ -> "Specify unfold Name to match against `u.c`, e.g. `Snapshotted`"
146148
| UnfoldCriteria _ -> "Specify constraints on Unfold (reference unfold fields via `u.d.`, top level fields via `c.`), e.g. `u.d.name = \"TenantName1\"`."
147-
| Mode _ -> "default: `_etag` plus snapwithStream (_etag, p, u[0].d). <- Default for normal queries\n" +
148-
"snaponly: Only read `u[0].d`\n" +
149-
"snapwithstream: Read `u[0].d` and `p` (stream name), but not `_etag`.\n" +
149+
| Mode _ -> "snaponly: Only read `u[0].d+D`\n" +
150+
"snapwithstream: As per `snaponly`, but add `p` (stream name)`.\n" +
151+
"default: As per `snapwithstream`, but add `_etag`\n"+
150152
"readonly: Only read `u`nfolds, not `_etag`.\n" +
151153
"readwithstream: Read `u`nfolds and `p` (stream name), but not `_etag`.\n" +
152-
"raw: Read all Items(documents) in full. <- Default when Output File specified\n"
154+
"raw: Read Items (documents) in full. <- Default when Output File specified"
153155
| File _ -> "Export full retrieved JSON to file. NOTE this switches the default mode to `Raw`"
154156
| Pretty -> "Render the JSON indented over multiple lines"
155157
| Console -> "Also emit the JSON to the console. Default: Gather statistics (but only write to a File if specified)"
156158
| Cosmos _ -> "Parameters for CosmosDB."
157-
and [<RequireQualifiedAccess>] Mode = Default | SnapOnly | SnapWithStream | ReadOnly | ReadWithStream | Raw
159+
and [<RequireQualifiedAccess>] Mode = SnapOnly | SnapWithStream | Default | ReadOnly | ReadWithStream | Raw
158160
and [<RequireQualifiedAccess>] Criteria =
159161
| SingleStream of string | StreamLike of string | CatName of string | CatLike of string | Custom of sql: string | Unfiltered
160162
member x.Sql = x |> function
@@ -346,7 +348,8 @@ and DumpArguments(p: ParseResults<DumpParameters>) =
346348
| Some pattern ->
347349
let container = x.Connect()
348350
let q = Microsoft.Azure.Cosmos.QueryDefinition($"SELECT DISTINCT VALUE c.p from c where c.p LIKE \"{pattern}\"")
349-
Equinox.CosmosStore.Linq.Internal.Query.exec Log.Logger container infoLogLevel q |> FSharp.Control.TaskSeq.toList
351+
Equinox.CosmosStore.Linq.Internal.Query.exec Log.Logger container infoLogLevel q |> TaskSeq.toList
352+
350353
let writeToStatsSinks (c: LoggerConfiguration) =
351354
c.WriteTo.Sink(Equinox.CosmosStore.Core.Log.InternalMetrics.Stats.LogSink())
352355
.WriteTo.Sink(Equinox.DynamoStore.Core.Log.InternalMetrics.Stats.LogSink())
@@ -421,8 +424,6 @@ module CosmosInit =
421424

422425
module CosmosStats =
423426

424-
open FSharp.Control
425-
426427
let run (log : ILogger, _verboseConsole, _maybeSeq) (p : ParseResults<StatsParameters>) =
427428
match p.GetSubCommand() with
428429
| StatsParameters.Cosmos sp ->
@@ -479,8 +480,6 @@ module StreamName =
479480

480481
module CosmosQuery =
481482

482-
open FSharp.Control
483-
let inline miB x = Equinox.CosmosStore.Linq.Internal.miB x
484483
type System.Text.Json.JsonDocument with
485484
member x.Cast<'T>() = System.Text.Json.JsonSerializer.Deserialize<'T>(x.RootElement)
486485
member x.Timestamp =
@@ -494,11 +493,11 @@ module CosmosQuery =
494493
| _ -> ()
495494
let selectedFields =
496495
match a.Mode with
497-
| Mode.Default -> "c._etag, c.p, c.u[0].D, c.u[0].d"
498496
| Mode.SnapOnly -> "c.u[0].D, c.u[0].d"
499497
| Mode.SnapWithStream -> "c.p, c.u[0].D, c.u[0].d"
500-
| Mode.ReadOnly -> "c.u" // TOCONSIDER remove; adjust TryLoad/TryHydrateTip
501-
| Mode.ReadWithStream -> "c.p, c.u" // TOCONSIDER remove; adjust TryLoad/TryHydrateTip
498+
| Mode.Default -> "c.p, c.u[0].D, c.u[0].d, c._etag"
499+
| Mode.ReadOnly -> "c.u"
500+
| Mode.ReadWithStream -> "c.p, c.u"
502501
| Mode.Raw -> "*"
503502
let unfoldFilter =
504503
let exists cond = $"EXISTS (SELECT VALUE u FROM u IN c.u WHERE {cond})"
@@ -549,13 +548,9 @@ module CosmosQuery =
549548

550549
module CosmosTop =
551550

552-
open Equinox.CosmosStore.Linq.Internal
553-
open FSharp.Control
554551
open System.Text.Json
555-
556-
let _t = Unchecked.defaultof<Equinox.CosmosStore.Core.Tip>
557552
let inline tryEquinoxStreamName (x: JsonElement) =
558-
match x.TryProp(nameof _t.p) with
553+
match x.TryProp(nameof Unchecked.defaultof<Equinox.CosmosStore.Core.Tip>.p) with
559554
| ValueSome (je: JsonElement) when je.ValueKind = JsonValueKind.String ->
560555
je.GetString() |> FsCodec.StreamName.parse |> FsCodec.StreamName.toString |> ValueSome
561556
| _ -> ValueNone
@@ -611,7 +606,7 @@ module CosmosTop =
611606
let mutable accI, accE, accU, accRus, accRds, accOds, accBytes, accParse = 0L, 0L, 0L, 0., 0L, 0L, 0L, TimeSpan.Zero
612607
let s = System.Collections.Generic.HashSet()
613608
let group = if a.StreamLevel then id else StreamName.categoryName
614-
try for rtt, rc, items, rdc, rds, ods in a.Execute(sql a) |> Query.enum__ do
609+
try for rtt, rc, items, rdc, rds, ods in a.Execute(sql a) |> Equinox.CosmosStore.Linq.Internal.Query.enum__ do
615610
let mutable pageI, pageE, pageU, pageB, pageCc, pageDm, newestTs, sw = 0, 0, 0, 0L, 0L, 0L, DateTime.MinValue, System.Diagnostics.Stopwatch.StartNew()
616611
for x in items do
617612
newestTs <- max newestTs x.Timestamp
@@ -662,9 +657,6 @@ module CosmosTop =
662657

663658
module CosmosDestroy =
664659

665-
open Equinox.CosmosStore.Linq.Internal
666-
open FSharp.Control
667-
668660
type Sem(max) =
669661
let inner = new SemaphoreSlim(max)
670662
member _.IsEmpty = inner.CurrentCount = max
@@ -695,7 +687,7 @@ module CosmosDestroy =
695687
let mutable accI, accE, accU, accRus, accDelRu, accRds, accOds = 0L, 0L, 0L, 0., 0., 0L, 0L
696688
let deletionDop = Sem a.Dop
697689
let writeResult, readResults = let c = Channel.unboundedSr<struct (float * string)> in Channel.write c.Writer, Channel.readAll c.Reader
698-
try for rtt, rc, items, rdc, rds, ods in query |> Query.enum__ do
690+
try for rtt, rc, items, rdc, rds, ods in query |> Equinox.CosmosStore.Linq.Internal.Query.enum__ do
699691
let mutable pageI, pageE, pageU, pRu, iRu = 0, 0, 0, 0., 0.
700692
let pageSw, intervalSw = System.Diagnostics.Stopwatch.StartNew(), System.Diagnostics.Stopwatch.StartNew()
701693
let drainResults () =
@@ -754,7 +746,6 @@ module CosmosDestroy =
754746
module DynamoInit =
755747

756748
open Equinox.DynamoStore
757-
758749
let table (log : ILogger) (p: ParseResults<TableParameters>) = async {
759750
let a = DynamoInitArguments p
760751
match p.GetSubCommand() with

0 commit comments

Comments
 (0)