Skip to content

Commit

Permalink
Add -sl; Polish -Q dump
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Sep 7, 2024
1 parent b48497a commit 605c998
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 43 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ The `Unreleased` section name is replaced by the expected version of next releas
- `eqx stats`: `-I` flag; relabel Documents as Items, retaining existing `-D` flag [#464](https://github.com/jet/equinox/pull/464)
- `eqx`: `-Q` flag omits timestamps from console output logging [#459](https://github.com/jet/equinox/pull/459)
- `Equinox.CosmosStore.Linq`: Add LINQ querying support for Indexed `u`nfolds (`AccessStrategy.Custom`+`CosmosStoreCategory.shouldCompress`) [#450](https://github.com/jet/equinox/pull/450)
- `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) [#450](https://github.com/jet/equinox/pull/450)
- `eqx dump`: `-Q` strips intervals, regularizes snapshots, logs stream names [#450](https://github.com/jet/equinox/pull/450)
- `eqx top`: Support for analyzing space usage for event and view containers by category and/or stream [#450](https://github.com/jet/equinox/pull/450)
- `eqx destroy`: Support for deleting the items(documents) underlying a category/stream/arbitrary `WHERE` clause [#450](https://github.com/jet/equinox/pull/450)

Expand Down
9 changes: 7 additions & 2 deletions src/Equinox.CosmosStore/CosmosStoreLinq.fs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,16 @@ module Internal =
action, items, responses, totalRtt.TotalMilliseconds, totalRdc, miB totalRds, miB totalOds, totalRu, interval.ElapsedMilliseconds) }
/// Runs a query that can be hydrated as 'T
let enum log container cat = enum_ log container "Index" cat Events.LogEventLevel.Information
let exec__<'R> (log: ILogger) (container: Container) cat logLevel (queryDefinition: QueryDefinition): TaskSeq<'R> =
if log.IsEnabled logLevel then log.Write(logLevel, "CosmosStoreQuery.run {cat} {query}", cat, queryDefinition.QueryText)
container.GetItemQueryIterator<'R> queryDefinition |> enum_ log container "Query" cat logLevel
/// Runs a query that renders 'T, Hydrating the results as 'P (can be the same types but e.g. you might want to map an object to a JsonElement etc)
let enumAs<'T, 'P> (log: ILogger) (container: Container) cat logLevel (query: IQueryable<'T>): TaskSeq<'P> =
let queryDefinition = query.ToQueryDefinition()
if log.IsEnabled logLevel then log.Write(logLevel, "CosmosStoreQuery.query {cat} {query}", cat, queryDefinition.QueryText)
container.GetItemQueryIterator<'P> queryDefinition |> enum log container cat
exec__<'P> log container cat logLevel queryDefinition
/// Execute a query, hydrating as 'R
let exec<'R> (log: ILogger) (container: Container) logLevel (queryDefinition: QueryDefinition): TaskSeq<'R> =
exec__<'R> log container "%" logLevel queryDefinition
module AggregateOp =
/// Runs one of the typical Cosmos SDK extensions, e.g. CountAsync, logging the costs
let [<EditorBrowsable(EditorBrowsableState.Never)>] exec (log: ILogger) (container: Container) (op: string) (cat: string) (query: IQueryable<'T>) run render: System.Threading.Tasks.Task<'R> = task {
Expand Down
Loading

0 comments on commit 605c998

Please sign in to comment.