From 4831091ea03ed95730f89002892656e93a3dbd62 Mon Sep 17 00:00:00 2001 From: Chris Philips Date: Wed, 10 Jan 2024 00:51:55 -0800 Subject: [PATCH] refactor: better object names + entity and stream repos will short-circuit returns true if there are no messages to commit --- .../Entities/IMultipleEntityRepository.cs | 2 +- .../Entities/ISingleEntityRepository.cs | 2 +- .../Projections/IProjection.cs | 4 +- .../Sources/ISourceRepository.cs | 86 ++++++------ src/EntityDb.Abstractions/Sources/Message.cs | 4 +- .../Queries/FilterBuilders/IFilterBuilder.cs | 2 +- .../IMessageDataFilterBuilder.cs | 2 +- .../Queries/{IQuery.cs => IDataQuery.cs} | 4 +- ...{ILeaseQuery.cs => ILeaseDataDataQuery.cs} | 4 +- ...eDataQuery.cs => IMessageDataDataQuery.cs} | 2 +- ...ceDataQuery.cs => ISourceDataDataQuery.cs} | 2 +- .../{ITagQuery.cs => ITagDataDataQuery.cs} | 4 +- ...ortBuilder.cs => ILeaseDataSortBuilder.cs} | 2 +- .../Queries/SortBuilders/ISortBuilder.cs | 2 +- ...gSortBuilder.cs => ITagDataSortBuilder.cs} | 2 +- .../Streams/IMultipleStreamRepository.cs | 2 +- .../Streams/ISingleStreamRepository.cs | 2 +- .../Entities/MultipleEntityRepository.cs | 7 +- ...Query.cs => ModifiedLeaseDataDataQuery.cs} | 14 +- ...ery.cs => ModifiedMessageDataDataQuery.cs} | 12 +- .../Queries/Modified/ModifiedQueryBase.cs | 8 +- .../Queries/Modified/ModifiedQueryOptions.cs | 8 +- ...uery.cs => ModifiedSourceDataDataQuery.cs} | 12 +- ...agQuery.cs => ModifiedTagDataDataQuery.cs} | 14 +- .../Sources/Queries/QueryExtensions.cs | 44 +++--- .../ReverseLeaseDataSortBuilder.cs | 34 +++++ .../SortBuilders/ReverseLeaseSortBuilder.cs | 34 ----- .../SortBuilders/ReverseTagDataSortBuilder.cs | 29 ++++ .../SortBuilders/ReverseTagSortBuilder.cs | 29 ---- .../SortBuilders/SortBuilderExtensions.cs | 20 +-- ...easesQuery.cs => DeleteLeasesDataQuery.cs} | 6 +- ...eteTagsQuery.cs => DeleteTagsDataQuery.cs} | 6 +- ...etDeltasQuery.cs => GetDeltasDataQuery.cs} | 4 +- ...ery.cs => GetLastStateVersionDataQuery.cs} | 2 +- ...etSourceQuery.cs => GetSourceDataQuery.cs} | 2 +- ...easeQuery.cs => MatchingLeaseDataQuery.cs} | 4 +- ...sesQuery.cs => MatchingLeasesDataQuery.cs} | 4 +- .../BufferBlockSourceReprocessorQueue.cs | 2 +- .../ISourceReprocessorQueueItem.cs | 2 +- .../TestModeSourceReprocessorQueue.cs | 2 +- .../Sources/SourceRepositoryExtensions.cs | 18 +-- .../Sources/SourceRepositoryWrapper.cs | 56 ++++---- .../Streams/MultipleStreamRepository.cs | 7 +- .../Documents/AgentSignatureDocument.cs | 12 +- .../Documents/DeltaDataDocument.cs | 14 +- .../Documents/LeaseDataDocument.cs | 16 +-- .../Documents/TagDataDocument.cs | 16 +-- .../Sources/MongoDbSourceRepository.cs | 56 ++++---- ...SortBuilder.cs => LeaseDataSortBuilder.cs} | 2 +- ...agSortBuilder.cs => TagDataSortBuilder.cs} | 2 +- .../Sessions/MongoDbSourceSessionOptions.cs | 2 +- .../Entities/EntityTests.cs | 4 +- .../Projections/OneToOneProjection.cs | 2 +- ...Query.cs => CountDataDataDataDataQuery.cs} | 6 +- ...ry.cs => SourceIdDataDataDataDataQuery.cs} | 8 +- ...> SourceTimeStampDataDataDataDataQuery.cs} | 10 +- ...Query.cs => StateDataDataDataDataQuery.cs} | 8 +- ...s => StateVersionDataDataDataDataQuery.cs} | 8 +- .../Sources/SourceTests.cs | 130 +++++++++--------- .../Sources/TryCatchSourceRepositoryTests.cs | 60 ++++---- .../Streams/StreamTests.cs | 16 +-- test/EntityDb.Common.Tests/TestsBase.cs | 2 +- 62 files changed, 446 insertions(+), 436 deletions(-) rename src/EntityDb.Abstractions/Sources/Queries/{IQuery.cs => IDataQuery.cs} (81%) rename src/EntityDb.Abstractions/Sources/Queries/{ILeaseQuery.cs => ILeaseDataDataQuery.cs} (88%) rename src/EntityDb.Abstractions/Sources/Queries/{IMessageDataQuery.cs => IMessageDataDataQuery.cs} (93%) rename src/EntityDb.Abstractions/Sources/Queries/{ISourceDataQuery.cs => ISourceDataDataQuery.cs} (93%) rename src/EntityDb.Abstractions/Sources/Queries/{ITagQuery.cs => ITagDataDataQuery.cs} (88%) rename src/EntityDb.Abstractions/Sources/Queries/SortBuilders/{ILeaseSortBuilder.cs => ILeaseDataSortBuilder.cs} (93%) rename src/EntityDb.Abstractions/Sources/Queries/SortBuilders/{ITagSortBuilder.cs => ITagDataSortBuilder.cs} (91%) rename src/EntityDb.Common/Sources/Queries/Modified/{ModifiedLeaseQuery.cs => ModifiedLeaseDataDataQuery.cs} (52%) rename src/EntityDb.Common/Sources/Queries/Modified/{ModifiedMessageDataQuery.cs => ModifiedMessageDataDataQuery.cs} (58%) rename src/EntityDb.Common/Sources/Queries/Modified/{ModifiedSourceDataQuery.cs => ModifiedSourceDataDataQuery.cs} (58%) rename src/EntityDb.Common/Sources/Queries/Modified/{ModifiedTagQuery.cs => ModifiedTagDataDataQuery.cs} (52%) create mode 100644 src/EntityDb.Common/Sources/Queries/SortBuilders/ReverseLeaseDataSortBuilder.cs delete mode 100644 src/EntityDb.Common/Sources/Queries/SortBuilders/ReverseLeaseSortBuilder.cs create mode 100644 src/EntityDb.Common/Sources/Queries/SortBuilders/ReverseTagDataSortBuilder.cs delete mode 100644 src/EntityDb.Common/Sources/Queries/SortBuilders/ReverseTagSortBuilder.cs rename src/EntityDb.Common/Sources/Queries/Standard/{DeleteLeasesQuery.cs => DeleteLeasesDataQuery.cs} (77%) rename src/EntityDb.Common/Sources/Queries/Standard/{DeleteTagsQuery.cs => DeleteTagsDataQuery.cs} (84%) rename src/EntityDb.Common/Sources/Queries/Standard/{GetDeltasQuery.cs => GetDeltasDataQuery.cs} (84%) rename src/EntityDb.Common/Sources/Queries/Standard/{GetLastStateVersionQuery.cs => GetLastStateVersionDataQuery.cs} (81%) rename src/EntityDb.Common/Sources/Queries/Standard/{GetSourceQuery.cs => GetSourceDataQuery.cs} (89%) rename src/EntityDb.Common/Sources/Queries/Standard/{MatchingLeaseQuery.cs => MatchingLeaseDataQuery.cs} (78%) rename src/EntityDb.Common/Sources/Queries/Standard/{MatchingLeasesQuery.cs => MatchingLeasesDataQuery.cs} (83%) rename src/EntityDb.MongoDb/Sources/Queries/SortBuilders/{LeaseSortBuilder.cs => LeaseDataSortBuilder.cs} (81%) rename src/EntityDb.MongoDb/Sources/Queries/SortBuilders/{TagSortBuilder.cs => TagDataSortBuilder.cs} (78%) rename test/EntityDb.Common.Tests/Implementations/Sources/Queries/{CountQuery.cs => CountDataDataDataDataQuery.cs} (84%) rename test/EntityDb.Common.Tests/Implementations/Sources/Queries/{SourceIdQuery.cs => SourceIdDataDataDataDataQuery.cs} (84%) rename test/EntityDb.Common.Tests/Implementations/Sources/Queries/{SourceTimeStampQuery.cs => SourceTimeStampDataDataDataDataQuery.cs} (85%) rename test/EntityDb.Common.Tests/Implementations/Sources/Queries/{StateQuery.cs => StateDataDataDataDataQuery.cs} (83%) rename test/EntityDb.Common.Tests/Implementations/Sources/Queries/{StateVersionQuery.cs => StateVersionDataDataDataDataQuery.cs} (80%) diff --git a/src/EntityDb.Abstractions/Entities/IMultipleEntityRepository.cs b/src/EntityDb.Abstractions/Entities/IMultipleEntityRepository.cs index ef7512b1..87b4cd03 100644 --- a/src/EntityDb.Abstractions/Entities/IMultipleEntityRepository.cs +++ b/src/EntityDb.Abstractions/Entities/IMultipleEntityRepository.cs @@ -60,6 +60,6 @@ public interface IMultipleEntityRepository : IDisposableResource /// Atomically commits a source. /// /// A cancellation token. - /// true if the commit succeeded, or false if the commit failed. + /// Only returns false if there are uncommitted messages. Task Commit(CancellationToken cancellationToken = default); } diff --git a/src/EntityDb.Abstractions/Entities/ISingleEntityRepository.cs b/src/EntityDb.Abstractions/Entities/ISingleEntityRepository.cs index eb3910fc..b3efef1f 100644 --- a/src/EntityDb.Abstractions/Entities/ISingleEntityRepository.cs +++ b/src/EntityDb.Abstractions/Entities/ISingleEntityRepository.cs @@ -42,6 +42,6 @@ public interface ISingleEntityRepository : IDisposableResource /// Atomically commits a source. /// /// A cancellation token. - /// true if the commit succeeded, or false if the commit failed. + /// Only returns false if there are uncommitted messages. Task Commit(CancellationToken cancellationToken = default); } diff --git a/src/EntityDb.Abstractions/Projections/IProjection.cs b/src/EntityDb.Abstractions/Projections/IProjection.cs index 47c016b4..1ddbf4fa 100644 --- a/src/EntityDb.Abstractions/Projections/IProjection.cs +++ b/src/EntityDb.Abstractions/Projections/IProjection.cs @@ -18,13 +18,13 @@ public interface IProjection : IState void Mutate(Source source); /// - /// Returns a that finds sources that need to be passed to the reducer. + /// Returns a that finds sources that need to be passed to the reducer. /// /// A service provider for fetching repositories. /// A pointer to the desired projection state /// A cancellation token /// - /// A that is used to load the rest of the messages for the given projection + /// A that is used to load the rest of the messages for the given projection /// pointer. /// IAsyncEnumerable EnumerateSources(IServiceProvider serviceProvider, Pointer projectionPointer, diff --git a/src/EntityDb.Abstractions/Sources/ISourceRepository.cs b/src/EntityDb.Abstractions/Sources/ISourceRepository.cs index 9cec7a05..6f0ea530 100644 --- a/src/EntityDb.Abstractions/Sources/ISourceRepository.cs +++ b/src/EntityDb.Abstractions/Sources/ISourceRepository.cs @@ -14,128 +14,128 @@ public interface ISourceRepository : IDisposableResource /// /// Returns the source ids which are found by a message group query. /// - /// The source data query. + /// The source data query. /// A cancellation token. - /// The source ids which are found by . - IAsyncEnumerable EnumerateSourceIds(ISourceDataQuery sourceDataQuery, + /// The source ids which are found by . + IAsyncEnumerable EnumerateSourceIds(ISourceDataDataQuery sourceDataDataQuery, CancellationToken cancellationToken = default); /// /// Returns the source ids which are found by a message query. /// - /// The message data query. + /// The message data query. /// A cancellation token. - /// The source ids which are found by . - IAsyncEnumerable EnumerateSourceIds(IMessageDataQuery messageDataQuery, + /// The source ids which are found by . + IAsyncEnumerable EnumerateSourceIds(IMessageDataDataQuery messageDataDataQuery, CancellationToken cancellationToken = default); /// /// Returns the source ids which are found by a lease query. /// - /// The lease query. + /// The lease query. /// A cancellation token. - /// The source ids which are found by . - IAsyncEnumerable EnumerateSourceIds(ILeaseQuery leaseQuery, + /// The source ids which are found by . + IAsyncEnumerable EnumerateSourceIds(ILeaseDataDataQuery leaseDataDataQuery, CancellationToken cancellationToken = default); /// /// Returns the source ids which are found by a tag query. /// - /// The tag query. + /// The tag query. /// A cancellation token. - /// The source ids which are found by . - IAsyncEnumerable EnumerateSourceIds(ITagQuery tagQuery, + /// The source ids which are found by . + IAsyncEnumerable EnumerateSourceIds(ITagDataDataQuery tagDataDataQuery, CancellationToken cancellationToken = default); /// /// Returns the state pointers which are found by a agentSignature query. /// - /// The source data query. + /// The source data query. /// A cancellation token. - /// The state pointers which are found by . - IAsyncEnumerable EnumerateStatePointers(ISourceDataQuery sourceDataQuery, + /// The state pointers which are found by . + IAsyncEnumerable EnumerateStatePointers(ISourceDataDataQuery sourceDataDataQuery, CancellationToken cancellationToken = default); /// /// Returns the state pointers which are found by a message query. /// - /// The message data query. + /// The message data query. /// A cancellation token. - /// The state pointers which are found by . - IAsyncEnumerable EnumerateStatePointers(IMessageDataQuery messageDataQuery, + /// The state pointers which are found by . + IAsyncEnumerable EnumerateStatePointers(IMessageDataDataQuery messageDataDataQuery, CancellationToken cancellationToken = default); /// /// Returns the state pointers which are found by a lease query. /// - /// The lease query. + /// The lease query. /// A cancellation token. - /// The state pointers which are found by . - IAsyncEnumerable EnumerateStatePointers(ILeaseQuery leaseQuery, + /// The state pointers which are found by . + IAsyncEnumerable EnumerateStatePointers(ILeaseDataDataQuery leaseDataDataQuery, CancellationToken cancellationToken = default); /// /// Returns the state pointers which are found by a tag query. /// - /// The tag query. + /// The tag query. /// A cancellation token. - /// The state pointers which are found by . - IAsyncEnumerable EnumerateStatePointers(ITagQuery tagQuery, + /// The state pointers which are found by . + IAsyncEnumerable EnumerateStatePointers(ITagDataDataQuery tagDataDataQuery, CancellationToken cancellationToken = default); /// /// Returns the agentSignatures which are found by an message group query. /// - /// The source data query. + /// The source data query. /// A cancellation token. - /// The agent signatures which are found by . - IAsyncEnumerable EnumerateAgentSignatures(ISourceDataQuery sourceDataQuery, + /// The agent signatures which are found by . + IAsyncEnumerable EnumerateAgentSignatures(ISourceDataDataQuery sourceDataDataQuery, CancellationToken cancellationToken = default); /// /// Returns the deltas which are found by a message query. /// - /// The message data query. + /// The message data query. /// A cancellation token. - /// The deltas which are found by . - IAsyncEnumerable EnumerateDeltas(IMessageDataQuery messageDataQuery, + /// The deltas which are found by . + IAsyncEnumerable EnumerateDeltas(IMessageDataDataQuery messageDataDataQuery, CancellationToken cancellationToken = default); /// /// Returns the leases which are found by a lease query. /// - /// The lease query. + /// The lease query. /// A cancellation token. - /// The leases which are found by . - IAsyncEnumerable EnumerateLeases(ILeaseQuery leaseQuery, + /// The leases which are found by . + IAsyncEnumerable EnumerateLeases(ILeaseDataDataQuery leaseDataDataQuery, CancellationToken cancellationToken = default); /// /// Returns the tags which are found by a tag query. /// - /// The tag query. + /// The tag query. /// A cancellation token. - /// The tags which are found by . - IAsyncEnumerable EnumerateTags(ITagQuery tagQuery, + /// The tags which are found by . + IAsyncEnumerable EnumerateTags(ITagDataDataQuery tagDataDataQuery, CancellationToken cancellationToken = default); /// /// Returns the annotated agent signatures which are found by a message group query. /// - /// The source data query. + /// The source data query. /// A cancellation token. - /// The annotated agent signatures which are found by . + /// The annotated agent signatures which are found by . IAsyncEnumerable> EnumerateAnnotatedAgentSignatures( - ISourceDataQuery sourceDataQuery, + ISourceDataDataQuery sourceDataDataQuery, CancellationToken cancellationToken = default); /// /// Returns the annotated deltas which are found by a message query. /// - /// The message data query. + /// The message data query. /// A cancellation token. - /// The annotated deltas which are found by . - IAsyncEnumerable> EnumerateAnnotatedDeltas(IMessageDataQuery messageDataQuery, + /// The annotated deltas which are found by . + IAsyncEnumerable> EnumerateAnnotatedDeltas(IMessageDataDataQuery messageDataDataQuery, CancellationToken cancellationToken = default); /// @@ -143,6 +143,6 @@ IAsyncEnumerable> EnumerateAnnotatedDeltas(IMessag /// /// The source. /// A cancellation token. - /// true if the insert succeeded, or false if the insert failed. + /// Returns true unless the source cannot be committed. Task Commit(Source source, CancellationToken cancellationToken = default); } diff --git a/src/EntityDb.Abstractions/Sources/Message.cs b/src/EntityDb.Abstractions/Sources/Message.cs index c61de1eb..aacf43dd 100644 --- a/src/EntityDb.Abstractions/Sources/Message.cs +++ b/src/EntityDb.Abstractions/Sources/Message.cs @@ -34,12 +34,12 @@ public sealed record Message public ITag[] AddTags { get; init; } = Array.Empty(); /// - /// The tags to be deleted. + /// The leases to be deleted. /// public ILease[] DeleteLeases { get; init; } = Array.Empty(); /// - /// The aliases to be added. + /// The tags to be deleted. /// public ITag[] DeleteTags { get; init; } = Array.Empty(); } diff --git a/src/EntityDb.Abstractions/Sources/Queries/FilterBuilders/IFilterBuilder.cs b/src/EntityDb.Abstractions/Sources/Queries/FilterBuilders/IFilterBuilder.cs index f9190f59..01297af5 100644 --- a/src/EntityDb.Abstractions/Sources/Queries/FilterBuilders/IFilterBuilder.cs +++ b/src/EntityDb.Abstractions/Sources/Queries/FilterBuilders/IFilterBuilder.cs @@ -4,7 +4,7 @@ namespace EntityDb.Abstractions.Sources.Queries.FilterBuilders; /// /// Builds a for an object. Possible objects include: -/// agent signatures, deltas, facts, tags, and aliases +/// agent signatures, deltas, facts, and tags. /// /// The type of filter used by the repository. public interface IFilterBuilder diff --git a/src/EntityDb.Abstractions/Sources/Queries/FilterBuilders/IMessageDataFilterBuilder.cs b/src/EntityDb.Abstractions/Sources/Queries/FilterBuilders/IMessageDataFilterBuilder.cs index 5a01e242..c1a144f4 100644 --- a/src/EntityDb.Abstractions/Sources/Queries/FilterBuilders/IMessageDataFilterBuilder.cs +++ b/src/EntityDb.Abstractions/Sources/Queries/FilterBuilders/IMessageDataFilterBuilder.cs @@ -6,7 +6,7 @@ namespace EntityDb.Abstractions.Sources.Queries.FilterBuilders; /// /// Builds a for an object associated /// with a single message. Possible objects include: -/// deltas, facts, tags, and aliases +/// deltas, facts, and tags. /// /// The type of filter used by the repository. public interface IMessageDataFilterBuilder : IFilterBuilder diff --git a/src/EntityDb.Abstractions/Sources/Queries/IQuery.cs b/src/EntityDb.Abstractions/Sources/Queries/IDataQuery.cs similarity index 81% rename from src/EntityDb.Abstractions/Sources/Queries/IQuery.cs rename to src/EntityDb.Abstractions/Sources/Queries/IDataQuery.cs index 7d1691f4..9fa5fb9e 100644 --- a/src/EntityDb.Abstractions/Sources/Queries/IQuery.cs +++ b/src/EntityDb.Abstractions/Sources/Queries/IDataQuery.cs @@ -2,9 +2,9 @@ /// /// Abstracts a query for an object repository. Possible objects include: -/// agentSignatures, deltas, facts, leases, and aliases. +/// agentSignatures, deltas, facts, and leases. /// -public interface IQuery +public interface IDataQuery { /// /// The number of objects to skip. diff --git a/src/EntityDb.Abstractions/Sources/Queries/ILeaseQuery.cs b/src/EntityDb.Abstractions/Sources/Queries/ILeaseDataDataQuery.cs similarity index 88% rename from src/EntityDb.Abstractions/Sources/Queries/ILeaseQuery.cs rename to src/EntityDb.Abstractions/Sources/Queries/ILeaseDataDataQuery.cs index c0805d72..7ae12f03 100644 --- a/src/EntityDb.Abstractions/Sources/Queries/ILeaseQuery.cs +++ b/src/EntityDb.Abstractions/Sources/Queries/ILeaseDataDataQuery.cs @@ -6,7 +6,7 @@ namespace EntityDb.Abstractions.Sources.Queries; /// /// Abstracts a query on leases. /// -public interface ILeaseQuery : IQuery +public interface ILeaseDataDataQuery : IDataQuery { /// /// Returns a built from a lease filter builder. @@ -22,5 +22,5 @@ public interface ILeaseQuery : IQuery /// The type of sort used by the repository. /// The lease sort builder. /// A built from . - TSort? GetSort(ILeaseSortBuilder builder); + TSort? GetSort(ILeaseDataSortBuilder builder); } diff --git a/src/EntityDb.Abstractions/Sources/Queries/IMessageDataQuery.cs b/src/EntityDb.Abstractions/Sources/Queries/IMessageDataDataQuery.cs similarity index 93% rename from src/EntityDb.Abstractions/Sources/Queries/IMessageDataQuery.cs rename to src/EntityDb.Abstractions/Sources/Queries/IMessageDataDataQuery.cs index 3002f6cc..f5879451 100644 --- a/src/EntityDb.Abstractions/Sources/Queries/IMessageDataQuery.cs +++ b/src/EntityDb.Abstractions/Sources/Queries/IMessageDataDataQuery.cs @@ -6,7 +6,7 @@ namespace EntityDb.Abstractions.Sources.Queries; /// /// Abstracts a query on messages. /// -public interface IMessageDataQuery : IQuery +public interface IMessageDataDataQuery : IDataQuery { /// /// Returns a built from a message filter builder. diff --git a/src/EntityDb.Abstractions/Sources/Queries/ISourceDataQuery.cs b/src/EntityDb.Abstractions/Sources/Queries/ISourceDataDataQuery.cs similarity index 93% rename from src/EntityDb.Abstractions/Sources/Queries/ISourceDataQuery.cs rename to src/EntityDb.Abstractions/Sources/Queries/ISourceDataDataQuery.cs index 397dab7f..f29bbd78 100644 --- a/src/EntityDb.Abstractions/Sources/Queries/ISourceDataQuery.cs +++ b/src/EntityDb.Abstractions/Sources/Queries/ISourceDataDataQuery.cs @@ -6,7 +6,7 @@ namespace EntityDb.Abstractions.Sources.Queries; /// /// Abstracts a query on agentSignatures. /// -public interface ISourceDataQuery : IQuery +public interface ISourceDataDataQuery : IDataQuery { /// /// Returns a built from a agentSignature filter builder. diff --git a/src/EntityDb.Abstractions/Sources/Queries/ITagQuery.cs b/src/EntityDb.Abstractions/Sources/Queries/ITagDataDataQuery.cs similarity index 88% rename from src/EntityDb.Abstractions/Sources/Queries/ITagQuery.cs rename to src/EntityDb.Abstractions/Sources/Queries/ITagDataDataQuery.cs index 7cd5c5c4..40bc64a7 100644 --- a/src/EntityDb.Abstractions/Sources/Queries/ITagQuery.cs +++ b/src/EntityDb.Abstractions/Sources/Queries/ITagDataDataQuery.cs @@ -6,7 +6,7 @@ namespace EntityDb.Abstractions.Sources.Queries; /// /// Abstracts a query on tags. /// -public interface ITagQuery : IQuery +public interface ITagDataDataQuery : IDataQuery { /// /// Returns a built from a tag filter builder. @@ -22,5 +22,5 @@ public interface ITagQuery : IQuery /// The type of sort used by the repository. /// The tag sort builder. /// A built from . - TSort? GetSort(ITagSortBuilder builder); + TSort? GetSort(ITagDataSortBuilder builder); } diff --git a/src/EntityDb.Abstractions/Sources/Queries/SortBuilders/ILeaseSortBuilder.cs b/src/EntityDb.Abstractions/Sources/Queries/SortBuilders/ILeaseDataSortBuilder.cs similarity index 93% rename from src/EntityDb.Abstractions/Sources/Queries/SortBuilders/ILeaseSortBuilder.cs rename to src/EntityDb.Abstractions/Sources/Queries/SortBuilders/ILeaseDataSortBuilder.cs index ba5b161e..7f2bc14a 100644 --- a/src/EntityDb.Abstractions/Sources/Queries/SortBuilders/ILeaseSortBuilder.cs +++ b/src/EntityDb.Abstractions/Sources/Queries/SortBuilders/ILeaseDataSortBuilder.cs @@ -6,7 +6,7 @@ namespace EntityDb.Abstractions.Sources.Queries.SortBuilders; /// Builds a sort for a lease query. /// /// The type of sort used by the repository. -public interface ILeaseSortBuilder : IMessageDataSortBuilder +public interface ILeaseDataSortBuilder : IMessageDataSortBuilder { /// /// Returns a that orders leases by . diff --git a/src/EntityDb.Abstractions/Sources/Queries/SortBuilders/ISortBuilder.cs b/src/EntityDb.Abstractions/Sources/Queries/SortBuilders/ISortBuilder.cs index 38653ab4..6feae84c 100644 --- a/src/EntityDb.Abstractions/Sources/Queries/SortBuilders/ISortBuilder.cs +++ b/src/EntityDb.Abstractions/Sources/Queries/SortBuilders/ISortBuilder.cs @@ -2,7 +2,7 @@ /// /// Builds a sort for an object repository. Possible objects include: -/// agentSignatures, deltas, facts, leases, and aliases. +/// agentSignatures, deltas, facts, and leases. /// /// The type of sort used by the repository. public interface ISortBuilder diff --git a/src/EntityDb.Abstractions/Sources/Queries/SortBuilders/ITagSortBuilder.cs b/src/EntityDb.Abstractions/Sources/Queries/SortBuilders/ITagDataSortBuilder.cs similarity index 91% rename from src/EntityDb.Abstractions/Sources/Queries/SortBuilders/ITagSortBuilder.cs rename to src/EntityDb.Abstractions/Sources/Queries/SortBuilders/ITagDataSortBuilder.cs index 292defab..d160cccc 100644 --- a/src/EntityDb.Abstractions/Sources/Queries/SortBuilders/ITagSortBuilder.cs +++ b/src/EntityDb.Abstractions/Sources/Queries/SortBuilders/ITagDataSortBuilder.cs @@ -6,7 +6,7 @@ namespace EntityDb.Abstractions.Sources.Queries.SortBuilders; /// Builds a sort for a tag query. /// /// The type of sort used by the repository. -public interface ITagSortBuilder : IMessageDataSortBuilder +public interface ITagDataSortBuilder : IMessageDataSortBuilder { /// /// Returns a that orders tags by . diff --git a/src/EntityDb.Abstractions/Streams/IMultipleStreamRepository.cs b/src/EntityDb.Abstractions/Streams/IMultipleStreamRepository.cs index 75d41d64..8119452c 100644 --- a/src/EntityDb.Abstractions/Streams/IMultipleStreamRepository.cs +++ b/src/EntityDb.Abstractions/Streams/IMultipleStreamRepository.cs @@ -36,6 +36,6 @@ public interface IMultipleStreamRepository : IDisposableResource /// Commits all stages deltas. /// /// A cancellation token - /// true if the commit succeeded, or false if the commit failed. + /// Only returns false if there are uncommitted messages. Task Commit(CancellationToken cancellationToken = default); } diff --git a/src/EntityDb.Abstractions/Streams/ISingleStreamRepository.cs b/src/EntityDb.Abstractions/Streams/ISingleStreamRepository.cs index 8be8471e..7c23c36b 100644 --- a/src/EntityDb.Abstractions/Streams/ISingleStreamRepository.cs +++ b/src/EntityDb.Abstractions/Streams/ISingleStreamRepository.cs @@ -32,6 +32,6 @@ public interface ISingleStreamRepository : IDisposableResource /// Commits all stages deltas. /// /// A cancellation token - /// true if the commit succeeded, or false if the commit failed. + /// Only returns false if there are uncommitted messages. Task Commit(CancellationToken cancellationToken = default); } diff --git a/src/EntityDb.Common/Entities/MultipleEntityRepository.cs b/src/EntityDb.Common/Entities/MultipleEntityRepository.cs index 23cedcd2..242f1ea5 100644 --- a/src/EntityDb.Common/Entities/MultipleEntityRepository.cs +++ b/src/EntityDb.Common/Entities/MultipleEntityRepository.cs @@ -60,7 +60,7 @@ public async Task Load(Pointer entityPointer, CancellationToken cancellationToke var statePointer = state.GetPointer(); - var query = new GetDeltasQuery(entityPointer, statePointer.Version); + var query = new GetDeltasDataQuery(entityPointer, statePointer.Version); var entity = await SourceRepository .EnumerateDeltas(query, cancellationToken) @@ -122,6 +122,11 @@ public void Append(Id entityId, object delta) public async Task Commit(CancellationToken cancellationToken = default) { + if (_messages.Count == 0) + { + return true; + } + var source = new Source { Id = Id.NewId(), diff --git a/src/EntityDb.Common/Sources/Queries/Modified/ModifiedLeaseQuery.cs b/src/EntityDb.Common/Sources/Queries/Modified/ModifiedLeaseDataDataQuery.cs similarity index 52% rename from src/EntityDb.Common/Sources/Queries/Modified/ModifiedLeaseQuery.cs rename to src/EntityDb.Common/Sources/Queries/Modified/ModifiedLeaseDataDataQuery.cs index 4512aa35..d6812239 100644 --- a/src/EntityDb.Common/Sources/Queries/Modified/ModifiedLeaseQuery.cs +++ b/src/EntityDb.Common/Sources/Queries/Modified/ModifiedLeaseDataDataQuery.cs @@ -5,10 +5,10 @@ namespace EntityDb.Common.Sources.Queries.Modified; -internal sealed record ModifiedLeaseQuery : ModifiedQueryBase, ILeaseQuery +internal sealed record ModifiedLeaseDataDataQuery : ModifiedQueryBase, ILeaseDataDataQuery { - public required ILeaseQuery LeaseQuery { get; init; } - protected override IQuery Query => LeaseQuery; + public required ILeaseDataDataQuery LeaseDataDataQuery { get; init; } + protected override IDataQuery DataQuery => LeaseDataDataQuery; public TFilter GetFilter(ILeaseDataFilterBuilder builder) { @@ -16,16 +16,16 @@ public TFilter GetFilter(ILeaseDataFilterBuilder builder) { return builder.Not ( - LeaseQuery.GetFilter(builder) + LeaseDataDataQuery.GetFilter(builder) ); } - return LeaseQuery.GetFilter(builder); + return LeaseDataDataQuery.GetFilter(builder); } - public TSort? GetSort(ILeaseSortBuilder builder) + public TSort? GetSort(ILeaseDataSortBuilder builder) { - return LeaseQuery.GetSort(ModifiedQueryOptions.ReverseSort + return LeaseDataDataQuery.GetSort(ModifiedQueryOptions.ReverseSort ? builder.Reverse() : builder); } diff --git a/src/EntityDb.Common/Sources/Queries/Modified/ModifiedMessageDataQuery.cs b/src/EntityDb.Common/Sources/Queries/Modified/ModifiedMessageDataDataQuery.cs similarity index 58% rename from src/EntityDb.Common/Sources/Queries/Modified/ModifiedMessageDataQuery.cs rename to src/EntityDb.Common/Sources/Queries/Modified/ModifiedMessageDataDataQuery.cs index c7889888..ca7b0831 100644 --- a/src/EntityDb.Common/Sources/Queries/Modified/ModifiedMessageDataQuery.cs +++ b/src/EntityDb.Common/Sources/Queries/Modified/ModifiedMessageDataDataQuery.cs @@ -5,10 +5,10 @@ namespace EntityDb.Common.Sources.Queries.Modified; -internal sealed record ModifiedMessageDataQuery : ModifiedQueryBase, IMessageDataQuery +internal sealed record ModifiedMessageDataDataQuery : ModifiedQueryBase, IMessageDataDataQuery { - public required IMessageDataQuery MessageDataQuery { get; init; } - protected override IQuery Query => MessageDataQuery; + public required IMessageDataDataQuery MessageDataDataQuery { get; init; } + protected override IDataQuery DataQuery => MessageDataDataQuery; public TFilter GetFilter(IMessageDataFilterBuilder builder) { @@ -16,16 +16,16 @@ public TFilter GetFilter(IMessageDataFilterBuilder builder) { return builder.Not ( - MessageDataQuery.GetFilter(builder) + MessageDataDataQuery.GetFilter(builder) ); } - return MessageDataQuery.GetFilter(builder); + return MessageDataDataQuery.GetFilter(builder); } public TSort? GetSort(IMessageDataSortBuilder builder) { - return MessageDataQuery.GetSort(ModifiedQueryOptions.ReverseSort + return MessageDataDataQuery.GetSort(ModifiedQueryOptions.ReverseSort ? builder.Reverse() : builder); } diff --git a/src/EntityDb.Common/Sources/Queries/Modified/ModifiedQueryBase.cs b/src/EntityDb.Common/Sources/Queries/Modified/ModifiedQueryBase.cs index 60bbaaf4..3df744d2 100644 --- a/src/EntityDb.Common/Sources/Queries/Modified/ModifiedQueryBase.cs +++ b/src/EntityDb.Common/Sources/Queries/Modified/ModifiedQueryBase.cs @@ -4,12 +4,12 @@ namespace EntityDb.Common.Sources.Queries.Modified; internal abstract record ModifiedQueryBase { - protected abstract IQuery Query { get; } + protected abstract IDataQuery DataQuery { get; } public required ModifiedQueryOptions ModifiedQueryOptions { get; init; } - public int? Skip => ModifiedQueryOptions.ReplaceSkip ?? Query.Skip; + public int? Skip => ModifiedQueryOptions.ReplaceSkip ?? DataQuery.Skip; - public int? Take => ModifiedQueryOptions.ReplaceTake ?? Query.Take; + public int? Take => ModifiedQueryOptions.ReplaceTake ?? DataQuery.Take; - public object? Options => Query.Options; + public object? Options => DataQuery.Options; } diff --git a/src/EntityDb.Common/Sources/Queries/Modified/ModifiedQueryOptions.cs b/src/EntityDb.Common/Sources/Queries/Modified/ModifiedQueryOptions.cs index 2da67dfe..701382be 100644 --- a/src/EntityDb.Common/Sources/Queries/Modified/ModifiedQueryOptions.cs +++ b/src/EntityDb.Common/Sources/Queries/Modified/ModifiedQueryOptions.cs @@ -23,14 +23,14 @@ public record ModifiedQueryOptions public bool ReverseSort { get; init; } /// - /// If not null, then the new query will return this value for . Otherwise, the new - /// query will return the same as the original query. + /// If not null, then the new query will return this value for . Otherwise, the new + /// query will return the same as the original query. /// public int? ReplaceSkip { get; init; } /// - /// If not null, then the new query will return this value for . Otherwise, the new - /// query will return the same as the original query. + /// If not null, then the new query will return this value for . Otherwise, the new + /// query will return the same as the original query. /// public int? ReplaceTake { get; init; } } diff --git a/src/EntityDb.Common/Sources/Queries/Modified/ModifiedSourceDataQuery.cs b/src/EntityDb.Common/Sources/Queries/Modified/ModifiedSourceDataDataQuery.cs similarity index 58% rename from src/EntityDb.Common/Sources/Queries/Modified/ModifiedSourceDataQuery.cs rename to src/EntityDb.Common/Sources/Queries/Modified/ModifiedSourceDataDataQuery.cs index 3c2c2522..51e8d362 100644 --- a/src/EntityDb.Common/Sources/Queries/Modified/ModifiedSourceDataQuery.cs +++ b/src/EntityDb.Common/Sources/Queries/Modified/ModifiedSourceDataDataQuery.cs @@ -5,10 +5,10 @@ namespace EntityDb.Common.Sources.Queries.Modified; -internal sealed record ModifiedSourceDataQuery : ModifiedQueryBase, ISourceDataQuery +internal sealed record ModifiedSourceDataDataQuery : ModifiedQueryBase, ISourceDataDataQuery { - public required ISourceDataQuery SourceDataQuery { get; init; } - protected override IQuery Query => SourceDataQuery; + public required ISourceDataDataQuery SourceDataDataQuery { get; init; } + protected override IDataQuery DataQuery => SourceDataDataQuery; public TFilter GetFilter(ISourceDataFilterBuilder builder) { @@ -16,16 +16,16 @@ public TFilter GetFilter(ISourceDataFilterBuilder builder) { return builder.Not ( - SourceDataQuery.GetFilter(builder) + SourceDataDataQuery.GetFilter(builder) ); } - return SourceDataQuery.GetFilter(builder); + return SourceDataDataQuery.GetFilter(builder); } public TSort? GetSort(ISourceDataSortBuilder builder) { - return SourceDataQuery.GetSort(ModifiedQueryOptions.ReverseSort + return SourceDataDataQuery.GetSort(ModifiedQueryOptions.ReverseSort ? builder.Reverse() : builder); } diff --git a/src/EntityDb.Common/Sources/Queries/Modified/ModifiedTagQuery.cs b/src/EntityDb.Common/Sources/Queries/Modified/ModifiedTagDataDataQuery.cs similarity index 52% rename from src/EntityDb.Common/Sources/Queries/Modified/ModifiedTagQuery.cs rename to src/EntityDb.Common/Sources/Queries/Modified/ModifiedTagDataDataQuery.cs index 49b003e6..e5c45e9e 100644 --- a/src/EntityDb.Common/Sources/Queries/Modified/ModifiedTagQuery.cs +++ b/src/EntityDb.Common/Sources/Queries/Modified/ModifiedTagDataDataQuery.cs @@ -5,10 +5,10 @@ namespace EntityDb.Common.Sources.Queries.Modified; -internal sealed record ModifiedTagQuery : ModifiedQueryBase, ITagQuery +internal sealed record ModifiedTagDataDataQuery : ModifiedQueryBase, ITagDataDataQuery { - public required ITagQuery TagQuery { get; init; } - protected override IQuery Query => TagQuery; + public required ITagDataDataQuery TagDataDataQuery { get; init; } + protected override IDataQuery DataQuery => TagDataDataQuery; public TFilter GetFilter(ITagDataFilterBuilder builder) { @@ -16,16 +16,16 @@ public TFilter GetFilter(ITagDataFilterBuilder builder) { return builder.Not ( - TagQuery.GetFilter(builder) + TagDataDataQuery.GetFilter(builder) ); } - return TagQuery.GetFilter(builder); + return TagDataDataQuery.GetFilter(builder); } - public TSort? GetSort(ITagSortBuilder builder) + public TSort? GetSort(ITagDataSortBuilder builder) { - return TagQuery.GetSort(ModifiedQueryOptions.ReverseSort + return TagDataDataQuery.GetSort(ModifiedQueryOptions.ReverseSort ? builder.Reverse() : builder); } diff --git a/src/EntityDb.Common/Sources/Queries/QueryExtensions.cs b/src/EntityDb.Common/Sources/Queries/QueryExtensions.cs index 3934cd7a..848cb554 100644 --- a/src/EntityDb.Common/Sources/Queries/QueryExtensions.cs +++ b/src/EntityDb.Common/Sources/Queries/QueryExtensions.cs @@ -9,59 +9,59 @@ namespace EntityDb.Common.Sources.Queries; public static class QueryExtensions { /// - /// Returns a new, modified . The way in which + /// Returns a new, modified . The way in which /// it is modified depends on the parameters of this extension method. /// - /// The source data query. + /// The source data query. /// The options for modifying the query. - /// A new, modified . - public static ISourceDataQuery Modify(this ISourceDataQuery sourceDataQuery, + /// A new, modified . + public static ISourceDataDataQuery Modify(this ISourceDataDataQuery sourceDataDataQuery, ModifiedQueryOptions modifiedQueryOptions) { - return new ModifiedSourceDataQuery + return new ModifiedSourceDataDataQuery { - ModifiedQueryOptions = modifiedQueryOptions, SourceDataQuery = sourceDataQuery, + ModifiedQueryOptions = modifiedQueryOptions, SourceDataDataQuery = sourceDataDataQuery, }; } /// - /// Returns a new, modified . The way in which it is modified depends on the parameters + /// Returns a new, modified . The way in which it is modified depends on the parameters /// of /// this extension method. /// - /// The message data query. + /// The message data query. /// The options for modifying the query. - /// A new, modified . - public static IMessageDataQuery Modify(this IMessageDataQuery messageDataQuery, + /// A new, modified . + public static IMessageDataDataQuery Modify(this IMessageDataDataQuery messageDataDataQuery, ModifiedQueryOptions modifiedQueryOptions) { - return new ModifiedMessageDataQuery + return new ModifiedMessageDataDataQuery { - ModifiedQueryOptions = modifiedQueryOptions, MessageDataQuery = messageDataQuery, + ModifiedQueryOptions = modifiedQueryOptions, MessageDataDataQuery = messageDataDataQuery, }; } /// - /// Returns a new, modified . The way in which it is modified depends on the parameters of + /// Returns a new, modified . The way in which it is modified depends on the parameters of /// this extension method. /// - /// The lease query. + /// The lease query. /// The options for modifying the query. - /// A new, modified . - public static ILeaseQuery Modify(this ILeaseQuery leaseQuery, ModifiedQueryOptions modifiedQueryOptions) + /// A new, modified . + public static ILeaseDataDataQuery Modify(this ILeaseDataDataQuery leaseDataDataQuery, ModifiedQueryOptions modifiedQueryOptions) { - return new ModifiedLeaseQuery { ModifiedQueryOptions = modifiedQueryOptions, LeaseQuery = leaseQuery }; + return new ModifiedLeaseDataDataQuery { ModifiedQueryOptions = modifiedQueryOptions, LeaseDataDataQuery = leaseDataDataQuery }; } /// - /// Returns a new, modified . The way in which it is modified depends on the parameters of this + /// Returns a new, modified . The way in which it is modified depends on the parameters of this /// extension method. /// - /// The tag query. + /// The tag query. /// The options for modifying the query. - /// A new, modified . - public static ITagQuery Modify(this ITagQuery tagQuery, ModifiedQueryOptions modifiedQueryOptions) + /// A new, modified . + public static ITagDataDataQuery Modify(this ITagDataDataQuery tagDataDataQuery, ModifiedQueryOptions modifiedQueryOptions) { - return new ModifiedTagQuery { ModifiedQueryOptions = modifiedQueryOptions, TagQuery = tagQuery }; + return new ModifiedTagDataDataQuery { ModifiedQueryOptions = modifiedQueryOptions, TagDataDataQuery = tagDataDataQuery }; } } diff --git a/src/EntityDb.Common/Sources/Queries/SortBuilders/ReverseLeaseDataSortBuilder.cs b/src/EntityDb.Common/Sources/Queries/SortBuilders/ReverseLeaseDataSortBuilder.cs new file mode 100644 index 00000000..ddf62810 --- /dev/null +++ b/src/EntityDb.Common/Sources/Queries/SortBuilders/ReverseLeaseDataSortBuilder.cs @@ -0,0 +1,34 @@ +using EntityDb.Abstractions.Sources.Queries.SortBuilders; + +namespace EntityDb.Common.Sources.Queries.SortBuilders; + +internal sealed record ReverseLeaseDataSortBuilder : ReverseSortBuilderBase, ILeaseDataSortBuilder +{ + public required ILeaseDataSortBuilder LeaseDataSortBuilder { get; init; } + protected override ISortBuilder SortBuilder => LeaseDataSortBuilder; + + public TSort StateId(bool ascending) + { + return LeaseDataSortBuilder.StateId(!ascending); + } + + public TSort StateVersion(bool ascending) + { + return LeaseDataSortBuilder.StateVersion(!ascending); + } + + public TSort LeaseScope(bool ascending) + { + return LeaseDataSortBuilder.LeaseScope(!ascending); + } + + public TSort LeaseLabel(bool ascending) + { + return LeaseDataSortBuilder.LeaseLabel(!ascending); + } + + public TSort LeaseValue(bool ascending) + { + return LeaseDataSortBuilder.LeaseValue(!ascending); + } +} diff --git a/src/EntityDb.Common/Sources/Queries/SortBuilders/ReverseLeaseSortBuilder.cs b/src/EntityDb.Common/Sources/Queries/SortBuilders/ReverseLeaseSortBuilder.cs deleted file mode 100644 index 68bc45de..00000000 --- a/src/EntityDb.Common/Sources/Queries/SortBuilders/ReverseLeaseSortBuilder.cs +++ /dev/null @@ -1,34 +0,0 @@ -using EntityDb.Abstractions.Sources.Queries.SortBuilders; - -namespace EntityDb.Common.Sources.Queries.SortBuilders; - -internal sealed record ReverseLeaseSortBuilder : ReverseSortBuilderBase, ILeaseSortBuilder -{ - public required ILeaseSortBuilder LeaseSortBuilder { get; init; } - protected override ISortBuilder SortBuilder => LeaseSortBuilder; - - public TSort StateId(bool ascending) - { - return LeaseSortBuilder.StateId(!ascending); - } - - public TSort StateVersion(bool ascending) - { - return LeaseSortBuilder.StateVersion(!ascending); - } - - public TSort LeaseScope(bool ascending) - { - return LeaseSortBuilder.LeaseScope(!ascending); - } - - public TSort LeaseLabel(bool ascending) - { - return LeaseSortBuilder.LeaseLabel(!ascending); - } - - public TSort LeaseValue(bool ascending) - { - return LeaseSortBuilder.LeaseValue(!ascending); - } -} diff --git a/src/EntityDb.Common/Sources/Queries/SortBuilders/ReverseTagDataSortBuilder.cs b/src/EntityDb.Common/Sources/Queries/SortBuilders/ReverseTagDataSortBuilder.cs new file mode 100644 index 00000000..f5ca19ef --- /dev/null +++ b/src/EntityDb.Common/Sources/Queries/SortBuilders/ReverseTagDataSortBuilder.cs @@ -0,0 +1,29 @@ +using EntityDb.Abstractions.Sources.Queries.SortBuilders; + +namespace EntityDb.Common.Sources.Queries.SortBuilders; + +internal sealed record ReverseTagDataSortBuilder : ReverseSortBuilderBase, ITagDataSortBuilder +{ + public required ITagDataSortBuilder TagDataSortBuilder { get; init; } + protected override ISortBuilder SortBuilder => TagDataSortBuilder; + + public TSort StateId(bool ascending) + { + return TagDataSortBuilder.StateId(!ascending); + } + + public TSort StateVersion(bool ascending) + { + return TagDataSortBuilder.StateVersion(!ascending); + } + + public TSort TagLabel(bool ascending) + { + return TagDataSortBuilder.TagLabel(!ascending); + } + + public TSort TagValue(bool ascending) + { + return TagDataSortBuilder.TagValue(!ascending); + } +} diff --git a/src/EntityDb.Common/Sources/Queries/SortBuilders/ReverseTagSortBuilder.cs b/src/EntityDb.Common/Sources/Queries/SortBuilders/ReverseTagSortBuilder.cs deleted file mode 100644 index a13a1f5e..00000000 --- a/src/EntityDb.Common/Sources/Queries/SortBuilders/ReverseTagSortBuilder.cs +++ /dev/null @@ -1,29 +0,0 @@ -using EntityDb.Abstractions.Sources.Queries.SortBuilders; - -namespace EntityDb.Common.Sources.Queries.SortBuilders; - -internal sealed record ReverseTagSortBuilder : ReverseSortBuilderBase, ITagSortBuilder -{ - public required ITagSortBuilder TagSortBuilder { get; init; } - protected override ISortBuilder SortBuilder => TagSortBuilder; - - public TSort StateId(bool ascending) - { - return TagSortBuilder.StateId(!ascending); - } - - public TSort StateVersion(bool ascending) - { - return TagSortBuilder.StateVersion(!ascending); - } - - public TSort TagLabel(bool ascending) - { - return TagSortBuilder.TagLabel(!ascending); - } - - public TSort TagValue(bool ascending) - { - return TagSortBuilder.TagValue(!ascending); - } -} diff --git a/src/EntityDb.Common/Sources/Queries/SortBuilders/SortBuilderExtensions.cs b/src/EntityDb.Common/Sources/Queries/SortBuilders/SortBuilderExtensions.cs index 09022e6f..c80ba5f2 100644 --- a/src/EntityDb.Common/Sources/Queries/SortBuilders/SortBuilderExtensions.cs +++ b/src/EntityDb.Common/Sources/Queries/SortBuilders/SortBuilderExtensions.cs @@ -38,32 +38,32 @@ public static IMessageDataSortBuilder Reverse(this IMessageDataSor } /// - /// Returns a that orders leases in the reverse order of another - /// . + /// Returns a that orders leases in the reverse order of another + /// . /// /// The type of sort used by the repository. /// The lease sort builder. /// - /// A that orders leases in the reverse order of + /// A that orders leases in the reverse order of /// . /// - public static ILeaseSortBuilder Reverse(this ILeaseSortBuilder builder) + public static ILeaseDataSortBuilder Reverse(this ILeaseDataSortBuilder builder) { - return new ReverseLeaseSortBuilder { LeaseSortBuilder = builder }; + return new ReverseLeaseDataSortBuilder { LeaseDataSortBuilder = builder }; } /// - /// Returns a that orders tags in the reverse order of another - /// . + /// Returns a that orders tags in the reverse order of another + /// . /// /// The type of sort used by the repository. /// The tag sort builder. /// - /// A that orders tags in the reverse order of + /// A that orders tags in the reverse order of /// . /// - public static ITagSortBuilder Reverse(this ITagSortBuilder builder) + public static ITagDataSortBuilder Reverse(this ITagDataSortBuilder builder) { - return new ReverseTagSortBuilder { TagSortBuilder = builder }; + return new ReverseTagDataSortBuilder { TagDataSortBuilder = builder }; } } diff --git a/src/EntityDb.Common/Sources/Queries/Standard/DeleteLeasesQuery.cs b/src/EntityDb.Common/Sources/Queries/Standard/DeleteLeasesDataQuery.cs similarity index 77% rename from src/EntityDb.Common/Sources/Queries/Standard/DeleteLeasesQuery.cs rename to src/EntityDb.Common/Sources/Queries/Standard/DeleteLeasesDataQuery.cs index 2678317e..71a4af75 100644 --- a/src/EntityDb.Common/Sources/Queries/Standard/DeleteLeasesQuery.cs +++ b/src/EntityDb.Common/Sources/Queries/Standard/DeleteLeasesDataQuery.cs @@ -5,8 +5,8 @@ namespace EntityDb.Common.Sources.Queries.Standard; -internal sealed record DeleteLeasesQuery(IReadOnlyCollection Leases, - object? Options = null) : ILeaseQuery +internal sealed record DeleteLeasesDataQuery(IReadOnlyCollection Leases, + object? Options = null) : ILeaseDataDataQuery { public TFilter GetFilter(ILeaseDataFilterBuilder builder) { @@ -23,7 +23,7 @@ public TFilter GetFilter(ILeaseDataFilterBuilder builder) ); } - public TSort? GetSort(ILeaseSortBuilder builder) + public TSort? GetSort(ILeaseDataSortBuilder builder) { return default; } diff --git a/src/EntityDb.Common/Sources/Queries/Standard/DeleteTagsQuery.cs b/src/EntityDb.Common/Sources/Queries/Standard/DeleteTagsDataQuery.cs similarity index 84% rename from src/EntityDb.Common/Sources/Queries/Standard/DeleteTagsQuery.cs rename to src/EntityDb.Common/Sources/Queries/Standard/DeleteTagsDataQuery.cs index 3749ca9c..6f44562f 100644 --- a/src/EntityDb.Common/Sources/Queries/Standard/DeleteTagsQuery.cs +++ b/src/EntityDb.Common/Sources/Queries/Standard/DeleteTagsDataQuery.cs @@ -6,8 +6,8 @@ namespace EntityDb.Common.Sources.Queries.Standard; -internal sealed record DeleteTagsQuery - (Id StateId, IReadOnlyCollection Tags, object? Options = null) : ITagQuery +internal sealed record DeleteTagsDataQuery + (Id StateId, IReadOnlyCollection Tags, object? Options = null) : ITagDataDataQuery { public TFilter GetFilter(ITagDataFilterBuilder builder) { @@ -26,7 +26,7 @@ public TFilter GetFilter(ITagDataFilterBuilder builder) ); } - public TSort? GetSort(ITagSortBuilder builder) + public TSort? GetSort(ITagDataSortBuilder builder) { return default; } diff --git a/src/EntityDb.Common/Sources/Queries/Standard/GetDeltasQuery.cs b/src/EntityDb.Common/Sources/Queries/Standard/GetDeltasDataQuery.cs similarity index 84% rename from src/EntityDb.Common/Sources/Queries/Standard/GetDeltasQuery.cs rename to src/EntityDb.Common/Sources/Queries/Standard/GetDeltasDataQuery.cs index 1af0442b..8585252d 100644 --- a/src/EntityDb.Common/Sources/Queries/Standard/GetDeltasQuery.cs +++ b/src/EntityDb.Common/Sources/Queries/Standard/GetDeltasDataQuery.cs @@ -6,8 +6,8 @@ namespace EntityDb.Common.Sources.Queries.Standard; -internal sealed record GetDeltasQuery(Pointer StatePointer, Version PersistedStateVersion, - object? Options = null) : IMessageDataQuery +internal sealed record GetDeltasDataQuery(Pointer StatePointer, Version PersistedStateVersion, + object? Options = null) : IMessageDataDataQuery { public TFilter GetFilter(IMessageDataFilterBuilder builder) { diff --git a/src/EntityDb.Common/Sources/Queries/Standard/GetLastStateVersionQuery.cs b/src/EntityDb.Common/Sources/Queries/Standard/GetLastStateVersionDataQuery.cs similarity index 81% rename from src/EntityDb.Common/Sources/Queries/Standard/GetLastStateVersionQuery.cs rename to src/EntityDb.Common/Sources/Queries/Standard/GetLastStateVersionDataQuery.cs index ac0fd628..0237acde 100644 --- a/src/EntityDb.Common/Sources/Queries/Standard/GetLastStateVersionQuery.cs +++ b/src/EntityDb.Common/Sources/Queries/Standard/GetLastStateVersionDataQuery.cs @@ -5,7 +5,7 @@ namespace EntityDb.Common.Sources.Queries.Standard; -internal sealed record GetLastStateVersionQuery(Id StateId, object? Options = null) : IMessageDataQuery +internal sealed record GetLastStateVersionDataQuery(Id StateId, object? Options = null) : IMessageDataDataQuery { public TFilter GetFilter(IMessageDataFilterBuilder builder) { diff --git a/src/EntityDb.Common/Sources/Queries/Standard/GetSourceQuery.cs b/src/EntityDb.Common/Sources/Queries/Standard/GetSourceDataQuery.cs similarity index 89% rename from src/EntityDb.Common/Sources/Queries/Standard/GetSourceQuery.cs rename to src/EntityDb.Common/Sources/Queries/Standard/GetSourceDataQuery.cs index ca36f8ba..835cdae1 100644 --- a/src/EntityDb.Common/Sources/Queries/Standard/GetSourceQuery.cs +++ b/src/EntityDb.Common/Sources/Queries/Standard/GetSourceDataQuery.cs @@ -5,7 +5,7 @@ namespace EntityDb.Common.Sources.Queries.Standard; -internal sealed record GetSourceQuery(Id SourceId) : ISourceDataQuery, IMessageDataQuery +internal sealed record GetSourceDataQuery(Id SourceId) : ISourceDataDataQuery, IMessageDataDataQuery { public TFilter GetFilter(IMessageDataFilterBuilder builder) { diff --git a/src/EntityDb.Common/Sources/Queries/Standard/MatchingLeaseQuery.cs b/src/EntityDb.Common/Sources/Queries/Standard/MatchingLeaseDataQuery.cs similarity index 78% rename from src/EntityDb.Common/Sources/Queries/Standard/MatchingLeaseQuery.cs rename to src/EntityDb.Common/Sources/Queries/Standard/MatchingLeaseDataQuery.cs index 40aca360..194a97de 100644 --- a/src/EntityDb.Common/Sources/Queries/Standard/MatchingLeaseQuery.cs +++ b/src/EntityDb.Common/Sources/Queries/Standard/MatchingLeaseDataQuery.cs @@ -5,7 +5,7 @@ namespace EntityDb.Common.Sources.Queries.Standard; -internal sealed record MatchingLeaseQuery(ILease Lease) : ILeaseQuery +internal sealed record MatchingLeaseDataQuery(ILease Lease) : ILeaseDataDataQuery { public TFilter GetFilter(ILeaseDataFilterBuilder builder) { @@ -17,7 +17,7 @@ public TFilter GetFilter(ILeaseDataFilterBuilder builder) ); } - public TSort? GetSort(ILeaseSortBuilder builder) + public TSort? GetSort(ILeaseDataSortBuilder builder) { return default; } diff --git a/src/EntityDb.Common/Sources/Queries/Standard/MatchingLeasesQuery.cs b/src/EntityDb.Common/Sources/Queries/Standard/MatchingLeasesDataQuery.cs similarity index 83% rename from src/EntityDb.Common/Sources/Queries/Standard/MatchingLeasesQuery.cs rename to src/EntityDb.Common/Sources/Queries/Standard/MatchingLeasesDataQuery.cs index 3355a99f..611384ea 100644 --- a/src/EntityDb.Common/Sources/Queries/Standard/MatchingLeasesQuery.cs +++ b/src/EntityDb.Common/Sources/Queries/Standard/MatchingLeasesDataQuery.cs @@ -5,7 +5,7 @@ namespace EntityDb.Common.Sources.Queries.Standard; -internal sealed record MatchingLeasesQuery(params ILease[] Leases) : ILeaseQuery +internal sealed record MatchingLeasesDataQuery(params ILease[] Leases) : ILeaseDataDataQuery { public TFilter GetFilter(ILeaseDataFilterBuilder builder) { @@ -21,7 +21,7 @@ public TFilter GetFilter(ILeaseDataFilterBuilder builder) ); } - public TSort? GetSort(ILeaseSortBuilder builder) + public TSort? GetSort(ILeaseDataSortBuilder builder) { return default; } diff --git a/src/EntityDb.Common/Sources/ReprocessorQueues/BufferBlockSourceReprocessorQueue.cs b/src/EntityDb.Common/Sources/ReprocessorQueues/BufferBlockSourceReprocessorQueue.cs index eaf10a55..b6dde1d1 100644 --- a/src/EntityDb.Common/Sources/ReprocessorQueues/BufferBlockSourceReprocessorQueue.cs +++ b/src/EntityDb.Common/Sources/ReprocessorQueues/BufferBlockSourceReprocessorQueue.cs @@ -49,7 +49,7 @@ await _sourceRepositoryFactory.Create(item.SourceSessionOptionsName, cancellationToken); var sourceIds = await sourceRepository - .EnumerateSourceIds(item.Query, cancellationToken) + .EnumerateSourceIds(item.DataQuery, cancellationToken) .ToArrayAsync(cancellationToken); foreach (var sourceId in sourceIds) diff --git a/src/EntityDb.Common/Sources/ReprocessorQueues/ISourceReprocessorQueueItem.cs b/src/EntityDb.Common/Sources/ReprocessorQueues/ISourceReprocessorQueueItem.cs index 5a0aa343..92be236e 100644 --- a/src/EntityDb.Common/Sources/ReprocessorQueues/ISourceReprocessorQueueItem.cs +++ b/src/EntityDb.Common/Sources/ReprocessorQueues/ISourceReprocessorQueueItem.cs @@ -24,7 +24,7 @@ public interface ISourceReprocessorQueueItem /// /// Determines which sources need to be reprocessed. /// - IQuery Query { get; } + IDataQuery DataQuery { get; } /// /// Determines how long to wait between each call to enqueue. diff --git a/src/EntityDb.Common/Sources/ReprocessorQueues/TestModeSourceReprocessorQueue.cs b/src/EntityDb.Common/Sources/ReprocessorQueues/TestModeSourceReprocessorQueue.cs index 97ec9dd4..c882b396 100644 --- a/src/EntityDb.Common/Sources/ReprocessorQueues/TestModeSourceReprocessorQueue.cs +++ b/src/EntityDb.Common/Sources/ReprocessorQueues/TestModeSourceReprocessorQueue.cs @@ -34,7 +34,7 @@ await _sourceRepositoryFactory.Create(item.SourceSessionOptionsName, cancellationToken); var sourceIds = await sourceRepository - .EnumerateSourceIds(item.Query, cancellationToken) + .EnumerateSourceIds(item.DataQuery, cancellationToken) .ToArrayAsync(cancellationToken); foreach (var sourceId in sourceIds) diff --git a/src/EntityDb.Common/Sources/SourceRepositoryExtensions.cs b/src/EntityDb.Common/Sources/SourceRepositoryExtensions.cs index 2ce7477d..cdd404e4 100644 --- a/src/EntityDb.Common/Sources/SourceRepositoryExtensions.cs +++ b/src/EntityDb.Common/Sources/SourceRepositoryExtensions.cs @@ -14,19 +14,19 @@ public static class SourceRepositoryExtensions /// Enumerate source ids for any supported query type /// /// The source repository - /// The query + /// The query /// A cancellation token - /// The source id which are found by + /// The source id which are found by public static IAsyncEnumerable EnumerateSourceIds(this ISourceRepository sourceRepository, - IQuery query, CancellationToken cancellationToken = default) + IDataQuery dataQuery, CancellationToken cancellationToken = default) { - return query switch + return dataQuery switch { - ISourceDataQuery sourceDataQuery => sourceRepository.EnumerateSourceIds(sourceDataQuery, cancellationToken), - IMessageDataQuery messageDataQuery => sourceRepository.EnumerateSourceIds(messageDataQuery, + ISourceDataDataQuery sourceDataQuery => sourceRepository.EnumerateSourceIds(sourceDataQuery, cancellationToken), + IMessageDataDataQuery messageDataQuery => sourceRepository.EnumerateSourceIds(messageDataQuery, cancellationToken), - ILeaseQuery leaseQuery => sourceRepository.EnumerateSourceIds(leaseQuery, cancellationToken), - ITagQuery tagQuery => sourceRepository.EnumerateSourceIds(tagQuery, cancellationToken), + ILeaseDataDataQuery leaseDataQuery => sourceRepository.EnumerateSourceIds(leaseDataQuery, cancellationToken), + ITagDataDataQuery tagDataQuery => sourceRepository.EnumerateSourceIds(tagDataQuery, cancellationToken), _ => AsyncEnumerable.Empty(), }; } @@ -63,7 +63,7 @@ public static async Task GetSource CancellationToken cancellationToken = default ) { - var query = new GetSourceQuery(sourceId); + var query = new GetSourceDataQuery(sourceId); var annotatedAgentSignature = await sourceRepository .EnumerateAnnotatedAgentSignatures(query, cancellationToken) diff --git a/src/EntityDb.Common/Sources/SourceRepositoryWrapper.cs b/src/EntityDb.Common/Sources/SourceRepositoryWrapper.cs index f45f1d5e..a8d8b316 100644 --- a/src/EntityDb.Common/Sources/SourceRepositoryWrapper.cs +++ b/src/EntityDb.Common/Sources/SourceRepositoryWrapper.cs @@ -16,90 +16,90 @@ protected SourceRepositoryWrapper(ISourceRepository sourceRepository) _sourceRepository = sourceRepository; } - public IAsyncEnumerable EnumerateSourceIds(ISourceDataQuery sourceDataQuery, + public IAsyncEnumerable EnumerateSourceIds(ISourceDataDataQuery sourceDataDataQuery, CancellationToken cancellationToken = default) { - return WrapQuery(() => _sourceRepository.EnumerateSourceIds(sourceDataQuery, cancellationToken)); + return WrapQuery(() => _sourceRepository.EnumerateSourceIds(sourceDataDataQuery, cancellationToken)); } - public IAsyncEnumerable EnumerateSourceIds(IMessageDataQuery messageDataQuery, + public IAsyncEnumerable EnumerateSourceIds(IMessageDataDataQuery messageDataDataQuery, CancellationToken cancellationToken = default) { - return WrapQuery(() => _sourceRepository.EnumerateSourceIds(messageDataQuery, cancellationToken)); + return WrapQuery(() => _sourceRepository.EnumerateSourceIds(messageDataDataQuery, cancellationToken)); } - public IAsyncEnumerable EnumerateSourceIds(ILeaseQuery leaseQuery, + public IAsyncEnumerable EnumerateSourceIds(ILeaseDataDataQuery leaseDataDataQuery, CancellationToken cancellationToken = default) { - return WrapQuery(() => _sourceRepository.EnumerateSourceIds(leaseQuery, cancellationToken)); + return WrapQuery(() => _sourceRepository.EnumerateSourceIds(leaseDataDataQuery, cancellationToken)); } - public IAsyncEnumerable EnumerateSourceIds(ITagQuery tagQuery, + public IAsyncEnumerable EnumerateSourceIds(ITagDataDataQuery tagDataDataQuery, CancellationToken cancellationToken = default) { - return WrapQuery(() => _sourceRepository.EnumerateSourceIds(tagQuery, cancellationToken)); + return WrapQuery(() => _sourceRepository.EnumerateSourceIds(tagDataDataQuery, cancellationToken)); } - public IAsyncEnumerable EnumerateStatePointers(ISourceDataQuery sourceDataQuery, + public IAsyncEnumerable EnumerateStatePointers(ISourceDataDataQuery sourceDataDataQuery, CancellationToken cancellationToken = default) { - return WrapQuery(() => _sourceRepository.EnumerateStatePointers(sourceDataQuery, cancellationToken)); + return WrapQuery(() => _sourceRepository.EnumerateStatePointers(sourceDataDataQuery, cancellationToken)); } - public IAsyncEnumerable EnumerateStatePointers(IMessageDataQuery messageDataQuery, + public IAsyncEnumerable EnumerateStatePointers(IMessageDataDataQuery messageDataDataQuery, CancellationToken cancellationToken = default) { - return WrapQuery(() => _sourceRepository.EnumerateStatePointers(messageDataQuery, cancellationToken)); + return WrapQuery(() => _sourceRepository.EnumerateStatePointers(messageDataDataQuery, cancellationToken)); } - public IAsyncEnumerable EnumerateStatePointers(ILeaseQuery leaseQuery, + public IAsyncEnumerable EnumerateStatePointers(ILeaseDataDataQuery leaseDataDataQuery, CancellationToken cancellationToken = default) { - return WrapQuery(() => _sourceRepository.EnumerateStatePointers(leaseQuery, cancellationToken)); + return WrapQuery(() => _sourceRepository.EnumerateStatePointers(leaseDataDataQuery, cancellationToken)); } - public IAsyncEnumerable EnumerateStatePointers(ITagQuery tagQuery, + public IAsyncEnumerable EnumerateStatePointers(ITagDataDataQuery tagDataDataQuery, CancellationToken cancellationToken = default) { - return WrapQuery(() => _sourceRepository.EnumerateStatePointers(tagQuery, cancellationToken)); + return WrapQuery(() => _sourceRepository.EnumerateStatePointers(tagDataDataQuery, cancellationToken)); } - public IAsyncEnumerable EnumerateAgentSignatures(ISourceDataQuery sourceDataQuery, + public IAsyncEnumerable EnumerateAgentSignatures(ISourceDataDataQuery sourceDataDataQuery, CancellationToken cancellationToken = default) { - return WrapQuery(() => _sourceRepository.EnumerateAgentSignatures(sourceDataQuery, cancellationToken)); + return WrapQuery(() => _sourceRepository.EnumerateAgentSignatures(sourceDataDataQuery, cancellationToken)); } - public IAsyncEnumerable EnumerateDeltas(IMessageDataQuery messageDataQuery, + public IAsyncEnumerable EnumerateDeltas(IMessageDataDataQuery messageDataDataQuery, CancellationToken cancellationToken = default) { - return WrapQuery(() => _sourceRepository.EnumerateDeltas(messageDataQuery, cancellationToken)); + return WrapQuery(() => _sourceRepository.EnumerateDeltas(messageDataDataQuery, cancellationToken)); } - public IAsyncEnumerable EnumerateLeases(ILeaseQuery leaseQuery, + public IAsyncEnumerable EnumerateLeases(ILeaseDataDataQuery leaseDataDataQuery, CancellationToken cancellationToken = default) { - return WrapQuery(() => _sourceRepository.EnumerateLeases(leaseQuery, cancellationToken)); + return WrapQuery(() => _sourceRepository.EnumerateLeases(leaseDataDataQuery, cancellationToken)); } - public IAsyncEnumerable EnumerateTags(ITagQuery tagQuery, + public IAsyncEnumerable EnumerateTags(ITagDataDataQuery tagDataDataQuery, CancellationToken cancellationToken = default) { - return WrapQuery(() => _sourceRepository.EnumerateTags(tagQuery, cancellationToken)); + return WrapQuery(() => _sourceRepository.EnumerateTags(tagDataDataQuery, cancellationToken)); } public IAsyncEnumerable> EnumerateAnnotatedAgentSignatures( - ISourceDataQuery sourceDataQuery, + ISourceDataDataQuery sourceDataDataQuery, CancellationToken cancellationToken = default) { return WrapQuery(() => - _sourceRepository.EnumerateAnnotatedAgentSignatures(sourceDataQuery, cancellationToken)); + _sourceRepository.EnumerateAnnotatedAgentSignatures(sourceDataDataQuery, cancellationToken)); } - public IAsyncEnumerable> EnumerateAnnotatedDeltas(IMessageDataQuery messageDataQuery, + public IAsyncEnumerable> EnumerateAnnotatedDeltas(IMessageDataDataQuery messageDataDataQuery, CancellationToken cancellationToken = default) { - return WrapQuery(() => _sourceRepository.EnumerateAnnotatedDeltas(messageDataQuery, cancellationToken)); + return WrapQuery(() => _sourceRepository.EnumerateAnnotatedDeltas(messageDataDataQuery, cancellationToken)); } public virtual Task Commit(Source source, diff --git a/src/EntityDb.Common/Streams/MultipleStreamRepository.cs b/src/EntityDb.Common/Streams/MultipleStreamRepository.cs index df083e0c..98f27c07 100644 --- a/src/EntityDb.Common/Streams/MultipleStreamRepository.cs +++ b/src/EntityDb.Common/Streams/MultipleStreamRepository.cs @@ -82,6 +82,11 @@ public async Task Stage(Key streamKey, Key messageKey, object delta, public async Task Commit(CancellationToken cancellationToken = default) { + if (_messages.Count == 0) + { + return true; + } + var source = new Source { Id = Id.NewId(), @@ -119,7 +124,7 @@ public static ILease GetMessageKeyLease(Key streamKey, Key messageKey) private async Task GetStreamPointer(ILease lease, CancellationToken cancellationToken) { - var query = new MatchingLeaseQuery(lease); + var query = new MatchingLeaseDataQuery(lease); return await SourceRepository .EnumerateStatePointers(query, cancellationToken) diff --git a/src/EntityDb.MongoDb/Documents/AgentSignatureDocument.cs b/src/EntityDb.MongoDb/Documents/AgentSignatureDocument.cs index 21ec9d34..0b84c85b 100644 --- a/src/EntityDb.MongoDb/Documents/AgentSignatureDocument.cs +++ b/src/EntityDb.MongoDb/Documents/AgentSignatureDocument.cs @@ -57,17 +57,17 @@ Source source public static DocumentQuery GetQuery ( - ISourceDataQuery sourceDataQuery + ISourceDataDataQuery sourceDataDataQuery ) { return new DocumentQuery { CollectionName = CollectionName, - Filter = sourceDataQuery.GetFilter(FilterBuilder), - Sort = sourceDataQuery.GetSort(SortBuilder), - Skip = sourceDataQuery.Skip, - Limit = sourceDataQuery.Take, - Options = sourceDataQuery.Options as MongoDbQueryOptions, + Filter = sourceDataDataQuery.GetFilter(FilterBuilder), + Sort = sourceDataDataQuery.GetSort(SortBuilder), + Skip = sourceDataDataQuery.Skip, + Limit = sourceDataDataQuery.Take, + Options = sourceDataDataQuery.Options as MongoDbQueryOptions, }; } } diff --git a/src/EntityDb.MongoDb/Documents/DeltaDataDocument.cs b/src/EntityDb.MongoDb/Documents/DeltaDataDocument.cs index 185d96f4..de1d2ee3 100644 --- a/src/EntityDb.MongoDb/Documents/DeltaDataDocument.cs +++ b/src/EntityDb.MongoDb/Documents/DeltaDataDocument.cs @@ -61,17 +61,17 @@ Message message public static DocumentQuery GetQuery ( - IMessageDataQuery messageDataQuery + IMessageDataDataQuery messageDataDataQuery ) { return new DocumentQuery { CollectionName = CollectionName, - Filter = messageDataQuery.GetFilter(DataFilterBuilder), - Sort = messageDataQuery.GetSort(SortBuilder), - Skip = messageDataQuery.Skip, - Limit = messageDataQuery.Take, - Options = messageDataQuery.Options as MongoDbQueryOptions, + Filter = messageDataDataQuery.GetFilter(DataFilterBuilder), + Sort = messageDataDataQuery.GetSort(SortBuilder), + Skip = messageDataDataQuery.Skip, + Limit = messageDataDataQuery.Take, + Options = messageDataDataQuery.Options as MongoDbQueryOptions, }; } @@ -82,7 +82,7 @@ public static async Task GetLastStateVersion CancellationToken cancellationToken ) { - var lastStateVersionQuery = new GetLastStateVersionQuery(stateId); + var lastStateVersionQuery = new GetLastStateVersionDataQuery(stateId); var document = await GetQuery(lastStateVersionQuery) .Execute(mongoSession, StateVersionProjection, cancellationToken) diff --git a/src/EntityDb.MongoDb/Documents/LeaseDataDocument.cs b/src/EntityDb.MongoDb/Documents/LeaseDataDocument.cs index 93687d22..d4559219 100644 --- a/src/EntityDb.MongoDb/Documents/LeaseDataDocument.cs +++ b/src/EntityDb.MongoDb/Documents/LeaseDataDocument.cs @@ -17,7 +17,7 @@ internal sealed record LeaseDataDocument : MessageDataDocumentBase private static readonly LeaseDataFilterBuilder DataFilterBuilder = new(); - private static readonly LeaseSortBuilder SortBuilder = new(); + private static readonly LeaseDataSortBuilder DataSortBuilder = new(); public required string Scope { get; init; } public required string Label { get; init; } @@ -56,17 +56,17 @@ Message message public static DocumentQuery GetQuery ( - ILeaseQuery leaseQuery + ILeaseDataDataQuery leaseDataDataQuery ) { return new DocumentQuery { CollectionName = CollectionName, - Filter = leaseQuery.GetFilter(DataFilterBuilder), - Sort = leaseQuery.GetSort(SortBuilder), - Skip = leaseQuery.Skip, - Limit = leaseQuery.Take, - Options = leaseQuery.Options as MongoDbQueryOptions, + Filter = leaseDataDataQuery.GetFilter(DataFilterBuilder), + Sort = leaseDataDataQuery.GetSort(DataSortBuilder), + Skip = leaseDataDataQuery.Skip, + Limit = leaseDataDataQuery.Take, + Options = leaseDataDataQuery.Options as MongoDbQueryOptions, }; } @@ -75,7 +75,7 @@ public static DeleteDocumentsCommand GetDeleteCommand Message message ) { - var deleteLeasesQuery = new DeleteLeasesQuery(message.DeleteLeases); + var deleteLeasesQuery = new DeleteLeasesDataQuery(message.DeleteLeases); return new DeleteDocumentsCommand { diff --git a/src/EntityDb.MongoDb/Documents/TagDataDocument.cs b/src/EntityDb.MongoDb/Documents/TagDataDocument.cs index d04a0004..4347bd81 100644 --- a/src/EntityDb.MongoDb/Documents/TagDataDocument.cs +++ b/src/EntityDb.MongoDb/Documents/TagDataDocument.cs @@ -17,7 +17,7 @@ internal sealed record TagDataDocument : MessageDataDocumentBase private static readonly TagDataFilterBuilder DataFilterBuilder = new(); - private static readonly TagSortBuilder SortBuilder = new(); + private static readonly TagDataSortBuilder DataSortBuilder = new(); public required string Label { get; init; } public required string Value { get; init; } @@ -54,17 +54,17 @@ Message message public static DocumentQuery GetQuery ( - ITagQuery tagQuery + ITagDataDataQuery tagDataDataQuery ) { return new DocumentQuery { CollectionName = CollectionName, - Filter = tagQuery.GetFilter(DataFilterBuilder), - Sort = tagQuery.GetSort(SortBuilder), - Skip = tagQuery.Skip, - Limit = tagQuery.Take, - Options = tagQuery.Options as MongoDbQueryOptions, + Filter = tagDataDataQuery.GetFilter(DataFilterBuilder), + Sort = tagDataDataQuery.GetSort(DataSortBuilder), + Skip = tagDataDataQuery.Skip, + Limit = tagDataDataQuery.Take, + Options = tagDataDataQuery.Options as MongoDbQueryOptions, }; } @@ -73,7 +73,7 @@ public static DeleteDocumentsCommand GetDeleteCommand Message message ) { - var deleteTagsQuery = new DeleteTagsQuery(message.StatePointer.Id, message.DeleteTags); + var deleteTagsQuery = new DeleteTagsDataQuery(message.StatePointer.Id, message.DeleteTags); return new DeleteDocumentsCommand { diff --git a/src/EntityDb.MongoDb/Sources/MongoDbSourceRepository.cs b/src/EntityDb.MongoDb/Sources/MongoDbSourceRepository.cs index bb092bd4..24e21f7a 100644 --- a/src/EntityDb.MongoDb/Sources/MongoDbSourceRepository.cs +++ b/src/EntityDb.MongoDb/Sources/MongoDbSourceRepository.cs @@ -29,117 +29,117 @@ IEnvelopeService envelopeService _envelopeService = envelopeService; } - public IAsyncEnumerable EnumerateSourceIds(ISourceDataQuery sourceDataQuery, + public IAsyncEnumerable EnumerateSourceIds(ISourceDataDataQuery sourceDataDataQuery, CancellationToken cancellationToken = default) { return AgentSignatureDocument - .GetQuery(sourceDataQuery) + .GetQuery(sourceDataDataQuery) .EnumerateSourceIds(_mongoSession, cancellationToken); } - public IAsyncEnumerable EnumerateSourceIds(IMessageDataQuery messageDataQuery, + public IAsyncEnumerable EnumerateSourceIds(IMessageDataDataQuery messageDataDataQuery, CancellationToken cancellationToken = default) { return DeltaDataDocument - .GetQuery(messageDataQuery) + .GetQuery(messageDataDataQuery) .EnumerateSourceIds(_mongoSession, cancellationToken); } - public IAsyncEnumerable EnumerateSourceIds(ILeaseQuery leaseQuery, + public IAsyncEnumerable EnumerateSourceIds(ILeaseDataDataQuery leaseDataDataQuery, CancellationToken cancellationToken = default) { return LeaseDataDocument - .GetQuery(leaseQuery) + .GetQuery(leaseDataDataQuery) .EnumerateSourceIds(_mongoSession, cancellationToken); } - public IAsyncEnumerable EnumerateSourceIds(ITagQuery tagQuery, + public IAsyncEnumerable EnumerateSourceIds(ITagDataDataQuery tagDataDataQuery, CancellationToken cancellationToken = default) { return TagDataDocument - .GetQuery(tagQuery) + .GetQuery(tagDataDataQuery) .EnumerateSourceIds(_mongoSession, cancellationToken); } - public IAsyncEnumerable EnumerateStatePointers(ISourceDataQuery sourceDataQuery, + public IAsyncEnumerable EnumerateStatePointers(ISourceDataDataQuery sourceDataDataQuery, CancellationToken cancellationToken = default) { return AgentSignatureDocument - .GetQuery(sourceDataQuery) + .GetQuery(sourceDataDataQuery) .EnumerateSourceDataStatePointers(_mongoSession, cancellationToken); } - public IAsyncEnumerable EnumerateStatePointers(IMessageDataQuery messageDataQuery, + public IAsyncEnumerable EnumerateStatePointers(IMessageDataDataQuery messageDataDataQuery, CancellationToken cancellationToken = default) { return DeltaDataDocument - .GetQuery(messageDataQuery) + .GetQuery(messageDataDataQuery) .EnumerateMessageStatePointers(_mongoSession, cancellationToken); } - public IAsyncEnumerable EnumerateStatePointers(ILeaseQuery leaseQuery, + public IAsyncEnumerable EnumerateStatePointers(ILeaseDataDataQuery leaseDataDataQuery, CancellationToken cancellationToken = default) { return LeaseDataDocument - .GetQuery(leaseQuery) + .GetQuery(leaseDataDataQuery) .EnumerateMessageStatePointers(_mongoSession, cancellationToken); } - public IAsyncEnumerable EnumerateStatePointers(ITagQuery tagQuery, + public IAsyncEnumerable EnumerateStatePointers(ITagDataDataQuery tagDataDataQuery, CancellationToken cancellationToken = default) { return TagDataDocument - .GetQuery(tagQuery) + .GetQuery(tagDataDataQuery) .EnumerateMessageStatePointers(_mongoSession, cancellationToken); } - public IAsyncEnumerable EnumerateAgentSignatures(ISourceDataQuery sourceDataQuery, + public IAsyncEnumerable EnumerateAgentSignatures(ISourceDataDataQuery sourceDataDataQuery, CancellationToken cancellationToken = default) { return AgentSignatureDocument - .GetQuery(sourceDataQuery) + .GetQuery(sourceDataDataQuery) .EnumerateData(_mongoSession, _envelopeService, cancellationToken); } - public IAsyncEnumerable EnumerateDeltas(IMessageDataQuery messageDataQuery, + public IAsyncEnumerable EnumerateDeltas(IMessageDataDataQuery messageDataDataQuery, CancellationToken cancellationToken = default) { return DeltaDataDocument - .GetQuery(messageDataQuery) + .GetQuery(messageDataDataQuery) .EnumerateData(_mongoSession, _envelopeService, cancellationToken); } - public IAsyncEnumerable EnumerateLeases(ILeaseQuery leaseQuery, + public IAsyncEnumerable EnumerateLeases(ILeaseDataDataQuery leaseDataDataQuery, CancellationToken cancellationToken = default) { return LeaseDataDocument - .GetQuery(leaseQuery) + .GetQuery(leaseDataDataQuery) .EnumerateData(_mongoSession, _envelopeService, cancellationToken); } - public IAsyncEnumerable EnumerateTags(ITagQuery tagQuery, + public IAsyncEnumerable EnumerateTags(ITagDataDataQuery tagDataDataQuery, CancellationToken cancellationToken = default) { return TagDataDocument - .GetQuery(tagQuery) + .GetQuery(tagDataDataQuery) .EnumerateData(_mongoSession, _envelopeService, cancellationToken); } public IAsyncEnumerable> EnumerateAnnotatedAgentSignatures( - ISourceDataQuery sourceDataQuery, + ISourceDataDataQuery sourceDataDataQuery, CancellationToken cancellationToken = default) { return AgentSignatureDocument - .GetQuery(sourceDataQuery) + .GetQuery(sourceDataDataQuery) .EnumerateEntitiesAnnotation(_mongoSession, _envelopeService, cancellationToken); } - public IAsyncEnumerable> EnumerateAnnotatedDeltas(IMessageDataQuery messageDataQuery, + public IAsyncEnumerable> EnumerateAnnotatedDeltas(IMessageDataDataQuery messageDataDataQuery, CancellationToken cancellationToken = default) { return DeltaDataDocument - .GetQuery(messageDataQuery) + .GetQuery(messageDataDataQuery) .EnumerateAnnotatedSourceData(_mongoSession, _envelopeService, cancellationToken); } diff --git a/src/EntityDb.MongoDb/Sources/Queries/SortBuilders/LeaseSortBuilder.cs b/src/EntityDb.MongoDb/Sources/Queries/SortBuilders/LeaseDataSortBuilder.cs similarity index 81% rename from src/EntityDb.MongoDb/Sources/Queries/SortBuilders/LeaseSortBuilder.cs rename to src/EntityDb.MongoDb/Sources/Queries/SortBuilders/LeaseDataSortBuilder.cs index 0dc4d24a..556f5f3e 100644 --- a/src/EntityDb.MongoDb/Sources/Queries/SortBuilders/LeaseSortBuilder.cs +++ b/src/EntityDb.MongoDb/Sources/Queries/SortBuilders/LeaseDataSortBuilder.cs @@ -5,7 +5,7 @@ namespace EntityDb.MongoDb.Sources.Queries.SortBuilders; -internal sealed class LeaseSortBuilder : MessageSortBuilder, ILeaseSortBuilder> +internal sealed class LeaseDataSortBuilder : MessageSortBuilder, ILeaseDataSortBuilder> { public SortDefinition LeaseScope(bool ascending) { diff --git a/src/EntityDb.MongoDb/Sources/Queries/SortBuilders/TagSortBuilder.cs b/src/EntityDb.MongoDb/Sources/Queries/SortBuilders/TagDataSortBuilder.cs similarity index 78% rename from src/EntityDb.MongoDb/Sources/Queries/SortBuilders/TagSortBuilder.cs rename to src/EntityDb.MongoDb/Sources/Queries/SortBuilders/TagDataSortBuilder.cs index 6e0622bd..02c5bf65 100644 --- a/src/EntityDb.MongoDb/Sources/Queries/SortBuilders/TagSortBuilder.cs +++ b/src/EntityDb.MongoDb/Sources/Queries/SortBuilders/TagDataSortBuilder.cs @@ -5,7 +5,7 @@ namespace EntityDb.MongoDb.Sources.Queries.SortBuilders; -internal sealed class TagSortBuilder : MessageSortBuilder, ITagSortBuilder> +internal sealed class TagDataSortBuilder : MessageSortBuilder, ITagDataSortBuilder> { public SortDefinition TagLabel(bool ascending) { diff --git a/src/EntityDb.MongoDb/Sources/Sessions/MongoDbSourceSessionOptions.cs b/src/EntityDb.MongoDb/Sources/Sessions/MongoDbSourceSessionOptions.cs index 4a73c490..d3c79d72 100644 --- a/src/EntityDb.MongoDb/Sources/Sessions/MongoDbSourceSessionOptions.cs +++ b/src/EntityDb.MongoDb/Sources/Sessions/MongoDbSourceSessionOptions.cs @@ -15,7 +15,7 @@ public sealed class MongoDbSourceSessionOptions public string ConnectionString { get; set; } = default!; /// - /// The name of the database that contains the collections (AgentSignatures, Deltas, Tags, Leases, Aliases) + /// The name of the database that contains the collections (AgentSignatures, Deltas, Leases, Tags) /// public string DatabaseName { get; set; } = default!; diff --git a/test/EntityDb.Common.Tests/Entities/EntityTests.cs b/test/EntityDb.Common.Tests/Entities/EntityTests.cs index 2b92ca32..cf6cdcab 100644 --- a/test/EntityDb.Common.Tests/Entities/EntityTests.cs +++ b/test/EntityDb.Common.Tests/Entities/EntityTests.cs @@ -101,7 +101,7 @@ private async Task Generic_GivenExistingEntityWithNoPersistedState_WhenGettingEn sourceRepositoryMock .Setup(repository => - repository.EnumerateDeltas(It.IsAny(), It.IsAny())) + repository.EnumerateDeltas(It.IsAny(), It.IsAny())) .Returns(() => AsyncEnumerablePolyfill.FromResult(deltas)) .Verifiable(); @@ -143,7 +143,7 @@ private async Task Generic_GivenExistingEntityWithNoPersistedState_WhenGettingEn sourceRepositoryMock .Verify( - repository => repository.EnumerateDeltas(It.IsAny(), It.IsAny()), + repository => repository.EnumerateDeltas(It.IsAny(), It.IsAny()), Times.Once); } diff --git a/test/EntityDb.Common.Tests/Implementations/Projections/OneToOneProjection.cs b/test/EntityDb.Common.Tests/Implementations/Projections/OneToOneProjection.cs index 6f20874b..8bb3cc7e 100644 --- a/test/EntityDb.Common.Tests/Implementations/Projections/OneToOneProjection.cs +++ b/test/EntityDb.Common.Tests/Implementations/Projections/OneToOneProjection.cs @@ -62,7 +62,7 @@ public async IAsyncEnumerable EnumerateSources [EnumeratorCancellation] CancellationToken cancellationToken ) { - var query = new GetDeltasQuery(projectionPointer, default); + var query = new GetDeltasDataQuery(projectionPointer, default); var sourceRepository = await serviceProvider .GetRequiredService() diff --git a/test/EntityDb.Common.Tests/Implementations/Sources/Queries/CountQuery.cs b/test/EntityDb.Common.Tests/Implementations/Sources/Queries/CountDataDataDataDataQuery.cs similarity index 84% rename from test/EntityDb.Common.Tests/Implementations/Sources/Queries/CountQuery.cs rename to test/EntityDb.Common.Tests/Implementations/Sources/Queries/CountDataDataDataDataQuery.cs index f7d80f8f..20258f8f 100644 --- a/test/EntityDb.Common.Tests/Implementations/Sources/Queries/CountQuery.cs +++ b/test/EntityDb.Common.Tests/Implementations/Sources/Queries/CountDataDataDataDataQuery.cs @@ -5,7 +5,7 @@ namespace EntityDb.Common.Tests.Implementations.Sources.Queries; -public record CountQuery(ulong Gte, ulong Lte, object? Options = null) : ILeaseQuery, ITagQuery +public record CountDataDataDataDataQuery(ulong Gte, ulong Lte, object? Options = null) : ILeaseDataDataQuery, ITagDataDataQuery { public int? Skip => null; @@ -26,7 +26,7 @@ public TFilter GetFilter(ILeaseDataFilterBuilder builder) ); } - public TSort GetSort(ILeaseSortBuilder builder) + public TSort GetSort(ILeaseDataSortBuilder builder) { return builder.Combine ( @@ -49,7 +49,7 @@ public TFilter GetFilter(ITagDataFilterBuilder builder) ); } - public TSort GetSort(ITagSortBuilder builder) + public TSort GetSort(ITagDataSortBuilder builder) { return builder.Combine ( diff --git a/test/EntityDb.Common.Tests/Implementations/Sources/Queries/SourceIdQuery.cs b/test/EntityDb.Common.Tests/Implementations/Sources/Queries/SourceIdDataDataDataDataQuery.cs similarity index 84% rename from test/EntityDb.Common.Tests/Implementations/Sources/Queries/SourceIdQuery.cs rename to test/EntityDb.Common.Tests/Implementations/Sources/Queries/SourceIdDataDataDataDataQuery.cs index 5980fb49..adeb055b 100644 --- a/test/EntityDb.Common.Tests/Implementations/Sources/Queries/SourceIdQuery.cs +++ b/test/EntityDb.Common.Tests/Implementations/Sources/Queries/SourceIdDataDataDataDataQuery.cs @@ -5,15 +5,15 @@ namespace EntityDb.Common.Tests.Implementations.Sources.Queries; -public record SourceIdQuery(Id SourceId, object? Options = null) : ISourceDataQuery, IMessageDataQuery, ILeaseQuery, - ITagQuery +public record SourceIdDataDataDataDataQuery(Id SourceId, object? Options = null) : ISourceDataDataQuery, IMessageDataDataQuery, ILeaseDataDataQuery, + ITagDataDataQuery { public TFilter GetFilter(ILeaseDataFilterBuilder builder) { return builder.SourceIdIn(SourceId); } - public TSort GetSort(ILeaseSortBuilder builder) + public TSort GetSort(ILeaseDataSortBuilder builder) { return builder.Combine ( @@ -60,7 +60,7 @@ public TFilter GetFilter(ITagDataFilterBuilder builder) return builder.SourceIdIn(SourceId); } - public TSort GetSort(ITagSortBuilder builder) + public TSort GetSort(ITagDataSortBuilder builder) { return builder.Combine ( diff --git a/test/EntityDb.Common.Tests/Implementations/Sources/Queries/SourceTimeStampQuery.cs b/test/EntityDb.Common.Tests/Implementations/Sources/Queries/SourceTimeStampDataDataDataDataQuery.cs similarity index 85% rename from test/EntityDb.Common.Tests/Implementations/Sources/Queries/SourceTimeStampQuery.cs rename to test/EntityDb.Common.Tests/Implementations/Sources/Queries/SourceTimeStampDataDataDataDataQuery.cs index 1116d3f8..1ae517b8 100644 --- a/test/EntityDb.Common.Tests/Implementations/Sources/Queries/SourceTimeStampQuery.cs +++ b/test/EntityDb.Common.Tests/Implementations/Sources/Queries/SourceTimeStampDataDataDataDataQuery.cs @@ -5,9 +5,9 @@ namespace EntityDb.Common.Tests.Implementations.Sources.Queries; -public record SourceTimeStampQuery(TimeStamp Gte, TimeStamp Lte, object? Options = null) : ISourceDataQuery, - IMessageDataQuery, - ILeaseQuery, ITagQuery +public record SourceTimeStampDataDataDataDataQuery(TimeStamp Gte, TimeStamp Lte, object? Options = null) : ISourceDataDataQuery, + IMessageDataDataQuery, + ILeaseDataDataQuery, ITagDataDataQuery { public TFilter GetFilter(ILeaseDataFilterBuilder builder) { @@ -18,7 +18,7 @@ public TFilter GetFilter(ILeaseDataFilterBuilder builder) ); } - public TSort GetSort(ILeaseSortBuilder builder) + public TSort GetSort(ILeaseDataSortBuilder builder) { return builder.Combine ( @@ -77,7 +77,7 @@ public TFilter GetFilter(ITagDataFilterBuilder builder) ); } - public TSort GetSort(ITagSortBuilder builder) + public TSort GetSort(ITagDataSortBuilder builder) { return builder.Combine ( diff --git a/test/EntityDb.Common.Tests/Implementations/Sources/Queries/StateQuery.cs b/test/EntityDb.Common.Tests/Implementations/Sources/Queries/StateDataDataDataDataQuery.cs similarity index 83% rename from test/EntityDb.Common.Tests/Implementations/Sources/Queries/StateQuery.cs rename to test/EntityDb.Common.Tests/Implementations/Sources/Queries/StateDataDataDataDataQuery.cs index d2c58e19..dbd580bd 100644 --- a/test/EntityDb.Common.Tests/Implementations/Sources/Queries/StateQuery.cs +++ b/test/EntityDb.Common.Tests/Implementations/Sources/Queries/StateDataDataDataDataQuery.cs @@ -5,15 +5,15 @@ namespace EntityDb.Common.Tests.Implementations.Sources.Queries; -public record StateQuery(Id StateId, object? Options = null) : ISourceDataQuery, IMessageDataQuery, - ILeaseQuery, ITagQuery +public record StateDataDataDataDataQuery(Id StateId, object? Options = null) : ISourceDataDataQuery, IMessageDataDataQuery, + ILeaseDataDataQuery, ITagDataDataQuery { public TFilter GetFilter(ILeaseDataFilterBuilder builder) { return builder.StateIdIn(StateId); } - public TSort GetSort(ILeaseSortBuilder builder) + public TSort GetSort(ILeaseDataSortBuilder builder) { return builder.Combine ( @@ -55,7 +55,7 @@ public TFilter GetFilter(ITagDataFilterBuilder builder) return builder.StateIdIn(StateId); } - public TSort GetSort(ITagSortBuilder builder) + public TSort GetSort(ITagDataSortBuilder builder) { return builder.Combine ( diff --git a/test/EntityDb.Common.Tests/Implementations/Sources/Queries/StateVersionQuery.cs b/test/EntityDb.Common.Tests/Implementations/Sources/Queries/StateVersionDataDataDataDataQuery.cs similarity index 80% rename from test/EntityDb.Common.Tests/Implementations/Sources/Queries/StateVersionQuery.cs rename to test/EntityDb.Common.Tests/Implementations/Sources/Queries/StateVersionDataDataDataDataQuery.cs index fc3d058c..a5e2f648 100644 --- a/test/EntityDb.Common.Tests/Implementations/Sources/Queries/StateVersionQuery.cs +++ b/test/EntityDb.Common.Tests/Implementations/Sources/Queries/StateVersionDataDataDataDataQuery.cs @@ -5,8 +5,8 @@ namespace EntityDb.Common.Tests.Implementations.Sources.Queries; -public record StateVersionQuery(Version Gte, Version Lte, object? Options = null) : IMessageDataQuery, - ILeaseQuery, ITagQuery +public record StateVersionDataDataDataDataQuery(Version Gte, Version Lte, object? Options = null) : IMessageDataDataQuery, + ILeaseDataDataQuery, ITagDataDataQuery { public TFilter GetFilter(ILeaseDataFilterBuilder builder) { @@ -17,7 +17,7 @@ public TFilter GetFilter(ILeaseDataFilterBuilder builder) ); } - public TSort GetSort(ILeaseSortBuilder builder) + public TSort GetSort(ILeaseDataSortBuilder builder) { return builder.StateVersion(true); } @@ -49,7 +49,7 @@ public TFilter GetFilter(ITagDataFilterBuilder builder) ); } - public TSort GetSort(ITagSortBuilder builder) + public TSort GetSort(ITagDataSortBuilder builder) { return builder.StateVersion(true); } diff --git a/test/EntityDb.Common.Tests/Sources/SourceTests.cs b/test/EntityDb.Common.Tests/Sources/SourceTests.cs index 16653b7b..3c30763e 100644 --- a/test/EntityDb.Common.Tests/Sources/SourceTests.cs +++ b/test/EntityDb.Common.Tests/Sources/SourceTests.cs @@ -108,7 +108,7 @@ bool secondaryPreferred private static async Task TestGetSourceIds ( IServiceScope serviceScope, - ISourceDataQuery query, + ISourceDataDataQuery dataQuery, ExpectedObjects expectedObjects ) { @@ -128,14 +128,14 @@ Id[] GetExpectedResults(bool invert) IAsyncEnumerable GetActualResults(ISourceRepository sourceRepository, ModifiedQueryOptions modifiedQueryOptions) { - return sourceRepository.EnumerateSourceIds(query.Modify(modifiedQueryOptions)); + return sourceRepository.EnumerateSourceIds(dataQuery.Modify(modifiedQueryOptions)); } } private static async Task TestGetSourceIds ( IServiceScope serviceScope, - IMessageDataQuery query, + IMessageDataDataQuery dataQuery, ExpectedObjects expectedObjects ) { @@ -147,7 +147,7 @@ ExpectedObjects expectedObjects IAsyncEnumerable GetActualResults(ISourceRepository sourceRepository, ModifiedQueryOptions modifiedQueryOptions) { - return sourceRepository.EnumerateSourceIds(query.Modify(modifiedQueryOptions)); + return sourceRepository.EnumerateSourceIds(dataQuery.Modify(modifiedQueryOptions)); } Id[] GetExpectedResults(bool invert) @@ -162,7 +162,7 @@ Id[] GetExpectedResults(bool invert) private static async Task TestGetSourceIds ( IServiceScope serviceScope, - ILeaseQuery query, + ILeaseDataDataQuery dataDataQuery, ExpectedObjects expectedObjects ) { @@ -182,14 +182,14 @@ Id[] GetExpectedResults(bool invert) IAsyncEnumerable GetActualResults(ISourceRepository sourceRepository, ModifiedQueryOptions modifiedQueryOptions) { - return sourceRepository.EnumerateSourceIds(query.Modify(modifiedQueryOptions)); + return sourceRepository.EnumerateSourceIds(dataDataQuery.Modify(modifiedQueryOptions)); } } private static async Task TestGetSourceIds ( IServiceScope serviceScope, - ITagQuery query, + ITagDataDataQuery dataDataQuery, ExpectedObjects expectedObjects ) { @@ -209,14 +209,14 @@ Id[] GetExpectedResults(bool invert) IAsyncEnumerable GetActualResults(ISourceRepository sourceRepository, ModifiedQueryOptions modifiedQueryOptions) { - return sourceRepository.EnumerateSourceIds(query.Modify(modifiedQueryOptions)); + return sourceRepository.EnumerateSourceIds(dataDataQuery.Modify(modifiedQueryOptions)); } } private static async Task TestGetStateIds ( IServiceScope serviceScope, - ISourceDataQuery query, + ISourceDataDataQuery dataQuery, ExpectedObjects expectedObjects ) { @@ -237,7 +237,7 @@ IAsyncEnumerable GetActualResults(ISourceRepository sourceRepository, ModifiedQueryOptions modifiedQueryOptions) { return sourceRepository - .EnumerateStatePointers(query.Modify(modifiedQueryOptions)) + .EnumerateStatePointers(dataQuery.Modify(modifiedQueryOptions)) .Select(pointer => pointer.Id); } } @@ -245,7 +245,7 @@ IAsyncEnumerable GetActualResults(ISourceRepository sourceRepository, private static async Task TestGetStateIds ( IServiceScope serviceScope, - IMessageDataQuery query, + IMessageDataDataQuery dataQuery, ExpectedObjects expectedObjects ) { @@ -266,7 +266,7 @@ IAsyncEnumerable GetActualResults(ISourceRepository sourceRepository, ModifiedQueryOptions modifiedQueryOptions) { return sourceRepository - .EnumerateStatePointers(query.Modify(modifiedQueryOptions)) + .EnumerateStatePointers(dataQuery.Modify(modifiedQueryOptions)) .Select(pointer => pointer.Id); } } @@ -274,7 +274,7 @@ IAsyncEnumerable GetActualResults(ISourceRepository sourceRepository, private static async Task TestGetStateIds ( IServiceScope serviceScope, - ILeaseQuery query, + ILeaseDataDataQuery dataDataQuery, ExpectedObjects expectedObjects ) { @@ -295,7 +295,7 @@ IAsyncEnumerable GetActualResults(ISourceRepository sourceRepository, ModifiedQueryOptions modifiedQueryOptions) { return sourceRepository - .EnumerateStatePointers(query.Modify(modifiedQueryOptions)) + .EnumerateStatePointers(dataDataQuery.Modify(modifiedQueryOptions)) .Select(pointer => pointer.Id); } } @@ -303,7 +303,7 @@ IAsyncEnumerable GetActualResults(ISourceRepository sourceRepository, private static async Task TestGetStateIds ( IServiceScope serviceScope, - ITagQuery query, + ITagDataDataQuery dataDataQuery, ExpectedObjects expectedObjects ) { @@ -324,7 +324,7 @@ IAsyncEnumerable GetActualResults(ISourceRepository sourceRepository, ModifiedQueryOptions modifiedQueryOptions) { return sourceRepository - .EnumerateStatePointers(query.Modify(modifiedQueryOptions)) + .EnumerateStatePointers(dataDataQuery.Modify(modifiedQueryOptions)) .Select(pointer => pointer.Id); } } @@ -332,7 +332,7 @@ IAsyncEnumerable GetActualResults(ISourceRepository sourceRepository, private static async Task TestGetAgentSignatures ( IServiceScope serviceScope, - ISourceDataQuery query, + ISourceDataDataQuery dataQuery, ExpectedObjects expectedObjects ) { @@ -352,14 +352,14 @@ object[] GetExpectedResults(bool invert) IAsyncEnumerable GetActualResults(ISourceRepository sourceRepository, ModifiedQueryOptions modifiedQueryOptions) { - return sourceRepository.EnumerateAgentSignatures(query.Modify(modifiedQueryOptions)); + return sourceRepository.EnumerateAgentSignatures(dataQuery.Modify(modifiedQueryOptions)); } } private static async Task TestGetDeltas ( IServiceScope serviceScope, - IMessageDataQuery query, + IMessageDataDataQuery dataQuery, ExpectedObjects expectedObjects ) { @@ -379,14 +379,14 @@ object[] GetExpectedResults(bool invert) IAsyncEnumerable GetActualResults(ISourceRepository sourceRepository, ModifiedQueryOptions modifiedQueryOptions) { - return sourceRepository.EnumerateDeltas(query.Modify(modifiedQueryOptions)); + return sourceRepository.EnumerateDeltas(dataQuery.Modify(modifiedQueryOptions)); } } private static async Task TestGetLeases ( IServiceScope serviceScope, - ILeaseQuery query, + ILeaseDataDataQuery dataDataQuery, ExpectedObjects expectedObjects ) { @@ -406,14 +406,14 @@ ILease[] GetExpectedResults(bool invert) IAsyncEnumerable GetActualResults(ISourceRepository sourceRepository, ModifiedQueryOptions modifiedQueryOptions) { - return sourceRepository.EnumerateLeases(query.Modify(modifiedQueryOptions)); + return sourceRepository.EnumerateLeases(dataDataQuery.Modify(modifiedQueryOptions)); } } private static async Task TestGetTags ( IServiceScope serviceScope, - ITagQuery query, + ITagDataDataQuery dataDataQuery, ExpectedObjects expectedObjects ) { @@ -425,7 +425,7 @@ ExpectedObjects expectedObjects IAsyncEnumerable GetActualResults(ISourceRepository sourceRepository, ModifiedQueryOptions modifiedQueryOptions) { - return sourceRepository.EnumerateTags(query.Modify(modifiedQueryOptions)); + return sourceRepository.EnumerateTags(dataDataQuery.Modify(modifiedQueryOptions)); } ITag[] GetExpectedResults(bool invert) @@ -532,13 +532,13 @@ private async Task Generic_GivenSourceAlreadyCommitted_WhenQueryingByData_ThenRe .GetRequiredService>() .Create("Count"); - var query = new CountQuery(gte, lte, options); + var query = new CountDataDataDataDataQuery(gte, lte, options); await PutSources(serviceScope, sources); - await TestGetSourceIds(serviceScope, query as ILeaseQuery, expectedObjects); - await TestGetSourceIds(serviceScope, query as ITagQuery, expectedObjects); - await TestGetStateIds(serviceScope, query as ILeaseQuery, expectedObjects); - await TestGetStateIds(serviceScope, query as ITagQuery, expectedObjects); + await TestGetSourceIds(serviceScope, query as ILeaseDataDataQuery, expectedObjects); + await TestGetSourceIds(serviceScope, query as ITagDataDataQuery, expectedObjects); + await TestGetStateIds(serviceScope, query as ILeaseDataDataQuery, expectedObjects); + await TestGetStateIds(serviceScope, query as ITagDataDataQuery, expectedObjects); await TestGetLeases(serviceScope, query, expectedObjects); await TestGetTags(serviceScope, query, expectedObjects); } @@ -815,7 +815,7 @@ public async Task GivenDeltaCommitted_WhenGettingAnnotatedAgentSignature_ThenRet var committed = await writeRepository.Commit(source); - var query = new StateQuery(expectedStateId); + var query = new StateDataDataDataDataQuery(expectedStateId); // ARRANGE ASSERTIONS @@ -868,7 +868,7 @@ public async Task GivenDeltaCommitted_WhenGettingAnnotatedDeltas_ThenReturnAnnot var committed = await writeRepository.Commit(source); - var query = new GetDeltasQuery(expectedStateId, default); + var query = new GetDeltasDataQuery(expectedStateId, default); // ARRANGE ASSERTIONS @@ -948,7 +948,7 @@ public async Task GivenMessageWithTagsCommitted_WhenRemovingAllTags_ThenSourceHa }, }; - var tagQuery = new DeleteTagsQuery(stateId, tags); + var deleteTagsQuery = new DeleteTagsDataQuery(stateId, tags); // ARRANGE ASSERTIONS @@ -957,13 +957,13 @@ public async Task GivenMessageWithTagsCommitted_WhenRemovingAllTags_ThenSourceHa // ACT var initialTags = await writeRepository - .EnumerateTags(tagQuery) + .EnumerateTags(deleteTagsQuery) .ToArrayAsync(); var finalSourceCommitted = await writeRepository.Commit(finalSource); var finalTags = await writeRepository - .EnumerateTags(tagQuery) + .EnumerateTags(deleteTagsQuery) .ToArrayAsync(); // ASSERT @@ -1021,7 +1021,7 @@ public async Task GivenMessageWithLeasesCommitted_WhenRemovingAllLeases_ThenSour }, }; - var leaseQuery = new DeleteLeasesQuery(leases); + var leaseQuery = new DeleteLeasesDataQuery(leases); // ARRANGE ASSERTIONS @@ -1064,7 +1064,7 @@ public async Task GivenMessageCommitted_WhenQueryingForVersionOne_ThenReturnTheE var source = CreateSource(new[] { 1ul }); - var versionOneQuery = new StateVersionQuery(new Version(1), new Version(1)); + var versionOneQuery = new StateVersionDataDataDataDataQuery(new Version(1), new Version(1)); // ACT @@ -1099,7 +1099,7 @@ public async Task GivenTwoMessagesCommitted_WhenQueryingForVersionTwo_ThenReturn var firstSource = CreateSource(new[] { 1ul }, stateId: stateId); var secondSource = CreateSource(new[] { 2ul }, stateId: stateId); - var versionTwoQuery = new StateVersionQuery(new Version(2), new Version(2)); + var versionTwoQuery = new StateVersionDataDataDataDataQuery(new Version(2), new Version(2)); // ACT @@ -1191,17 +1191,17 @@ public async Task GivenSourceAlreadyCommitted_WhenQueryingBySourceTimeStamp_Then gte.ShouldNotBeNull(); lte.ShouldNotBeNull(); - var query = new SourceTimeStampQuery(gte.Value, lte.Value); + var query = new SourceTimeStampDataDataDataDataQuery(gte.Value, lte.Value); await PutSources(serviceScope, sources); - await TestGetSourceIds(serviceScope, query as ISourceDataQuery, expectedObjects); - await TestGetSourceIds(serviceScope, query as IMessageDataQuery, expectedObjects); - await TestGetSourceIds(serviceScope, query as ILeaseQuery, expectedObjects); - await TestGetSourceIds(serviceScope, query as ITagQuery, expectedObjects); - await TestGetStateIds(serviceScope, query as ISourceDataQuery, expectedObjects); - await TestGetStateIds(serviceScope, query as IMessageDataQuery, expectedObjects); - await TestGetStateIds(serviceScope, query as ILeaseQuery, expectedObjects); - await TestGetStateIds(serviceScope, query as ITagQuery, expectedObjects); + await TestGetSourceIds(serviceScope, query as ISourceDataDataQuery, expectedObjects); + await TestGetSourceIds(serviceScope, query as IMessageDataDataQuery, expectedObjects); + await TestGetSourceIds(serviceScope, query as ILeaseDataDataQuery, expectedObjects); + await TestGetSourceIds(serviceScope, query as ITagDataDataQuery, expectedObjects); + await TestGetStateIds(serviceScope, query as ISourceDataDataQuery, expectedObjects); + await TestGetStateIds(serviceScope, query as IMessageDataDataQuery, expectedObjects); + await TestGetStateIds(serviceScope, query as ILeaseDataDataQuery, expectedObjects); + await TestGetStateIds(serviceScope, query as ITagDataDataQuery, expectedObjects); await TestGetAgentSignatures(serviceScope, query, expectedObjects); await TestGetDeltas(serviceScope, query, expectedObjects); await TestGetLeases(serviceScope, query, expectedObjects); @@ -1271,17 +1271,17 @@ public async Task GivenSourceAlreadyCommitted_WhenQueryingBySourceId_ThenReturnE sourceId.ShouldNotBeNull(); - var query = new SourceIdQuery(sourceId.Value); + var query = new SourceIdDataDataDataDataQuery(sourceId.Value); await PutSources(serviceScope, sources); - await TestGetSourceIds(serviceScope, query as ISourceDataQuery, expectedObjects); - await TestGetSourceIds(serviceScope, query as IMessageDataQuery, expectedObjects); - await TestGetSourceIds(serviceScope, query as ILeaseQuery, expectedObjects); - await TestGetSourceIds(serviceScope, query as ITagQuery, expectedObjects); - await TestGetStateIds(serviceScope, query as ISourceDataQuery, expectedObjects); - await TestGetStateIds(serviceScope, query as IMessageDataQuery, expectedObjects); - await TestGetStateIds(serviceScope, query as ILeaseQuery, expectedObjects); - await TestGetStateIds(serviceScope, query as ITagQuery, expectedObjects); + await TestGetSourceIds(serviceScope, query as ISourceDataDataQuery, expectedObjects); + await TestGetSourceIds(serviceScope, query as IMessageDataDataQuery, expectedObjects); + await TestGetSourceIds(serviceScope, query as ILeaseDataDataQuery, expectedObjects); + await TestGetSourceIds(serviceScope, query as ITagDataDataQuery, expectedObjects); + await TestGetStateIds(serviceScope, query as ISourceDataDataQuery, expectedObjects); + await TestGetStateIds(serviceScope, query as IMessageDataDataQuery, expectedObjects); + await TestGetStateIds(serviceScope, query as ILeaseDataDataQuery, expectedObjects); + await TestGetStateIds(serviceScope, query as ITagDataDataQuery, expectedObjects); await TestGetAgentSignatures(serviceScope, query, expectedObjects); await TestGetDeltas(serviceScope, query, expectedObjects); await TestGetLeases(serviceScope, query, expectedObjects); @@ -1352,17 +1352,17 @@ public async Task GivenSourceAlreadyCommitted_WhenQueryingByStateId_ThenReturnEx stateId.ShouldNotBeNull(); - var query = new StateQuery(stateId.Value); + var query = new StateDataDataDataDataQuery(stateId.Value); await PutSources(serviceScope, sources); - await TestGetSourceIds(serviceScope, query as ISourceDataQuery, expectedObjects); - await TestGetSourceIds(serviceScope, query as IMessageDataQuery, expectedObjects); - await TestGetSourceIds(serviceScope, query as ILeaseQuery, expectedObjects); - await TestGetSourceIds(serviceScope, query as ITagQuery, expectedObjects); - await TestGetStateIds(serviceScope, query as ISourceDataQuery, expectedObjects); - await TestGetStateIds(serviceScope, query as IMessageDataQuery, expectedObjects); - await TestGetStateIds(serviceScope, query as ILeaseQuery, expectedObjects); - await TestGetStateIds(serviceScope, query as ITagQuery, expectedObjects); + await TestGetSourceIds(serviceScope, query as ISourceDataDataQuery, expectedObjects); + await TestGetSourceIds(serviceScope, query as IMessageDataDataQuery, expectedObjects); + await TestGetSourceIds(serviceScope, query as ILeaseDataDataQuery, expectedObjects); + await TestGetSourceIds(serviceScope, query as ITagDataDataQuery, expectedObjects); + await TestGetStateIds(serviceScope, query as ISourceDataDataQuery, expectedObjects); + await TestGetStateIds(serviceScope, query as IMessageDataDataQuery, expectedObjects); + await TestGetStateIds(serviceScope, query as ILeaseDataDataQuery, expectedObjects); + await TestGetStateIds(serviceScope, query as ITagDataDataQuery, expectedObjects); await TestGetAgentSignatures(serviceScope, query, expectedObjects); await TestGetDeltas(serviceScope, query, expectedObjects); await TestGetLeases(serviceScope, query, expectedObjects); @@ -1419,7 +1419,7 @@ public async Task GivenSourceAlreadyCommitted_WhenQueryingByStateVersion_ThenRet var sources = new List { source }; - var query = new StateVersionQuery(new Version(gte), new Version(lte)); + var query = new StateVersionDataDataDataDataQuery(new Version(gte), new Version(lte)); await PutSources(serviceScope, sources); await TestGetDeltas(serviceScope, query, expectedObjects); diff --git a/test/EntityDb.Common.Tests/Sources/TryCatchSourceRepositoryTests.cs b/test/EntityDb.Common.Tests/Sources/TryCatchSourceRepositoryTests.cs index 59328f04..cb801331 100644 --- a/test/EntityDb.Common.Tests/Sources/TryCatchSourceRepositoryTests.cs +++ b/test/EntityDb.Common.Tests/Sources/TryCatchSourceRepositoryTests.cs @@ -27,69 +27,69 @@ public async Task GivenRepositoryAlwaysThrows_WhenExecutingAnyMethod_ThenExcepti sourceRepositoryMock .Setup(repository => - repository.EnumerateSourceIds(It.IsAny(), It.IsAny())) + repository.EnumerateSourceIds(It.IsAny(), It.IsAny())) .Throws(new NotImplementedException()); sourceRepositoryMock .Setup(repository => - repository.EnumerateSourceIds(It.IsAny(), It.IsAny())) + repository.EnumerateSourceIds(It.IsAny(), It.IsAny())) .Throws(new NotImplementedException()); sourceRepositoryMock - .Setup(repository => repository.EnumerateSourceIds(It.IsAny(), It.IsAny())) + .Setup(repository => repository.EnumerateSourceIds(It.IsAny(), It.IsAny())) .Throws(new NotImplementedException()); sourceRepositoryMock - .Setup(repository => repository.EnumerateSourceIds(It.IsAny(), It.IsAny())) + .Setup(repository => repository.EnumerateSourceIds(It.IsAny(), It.IsAny())) .Throws(new NotImplementedException()); sourceRepositoryMock .Setup(repository => - repository.EnumerateStatePointers(It.IsAny(), It.IsAny())) + repository.EnumerateStatePointers(It.IsAny(), It.IsAny())) .Throws(new NotImplementedException()); sourceRepositoryMock .Setup(repository => - repository.EnumerateStatePointers(It.IsAny(), It.IsAny())) + repository.EnumerateStatePointers(It.IsAny(), It.IsAny())) .Throws(new NotImplementedException()); sourceRepositoryMock .Setup(repository => - repository.EnumerateStatePointers(It.IsAny(), It.IsAny())) + repository.EnumerateStatePointers(It.IsAny(), It.IsAny())) .Throws(new NotImplementedException()); sourceRepositoryMock .Setup(repository => - repository.EnumerateStatePointers(It.IsAny(), It.IsAny())) + repository.EnumerateStatePointers(It.IsAny(), It.IsAny())) .Throws(new NotImplementedException()); sourceRepositoryMock .Setup(repository => - repository.EnumerateAgentSignatures(It.IsAny(), It.IsAny())) + repository.EnumerateAgentSignatures(It.IsAny(), It.IsAny())) .Throws(new NotImplementedException()); sourceRepositoryMock .Setup(repository => - repository.EnumerateDeltas(It.IsAny(), It.IsAny())) + repository.EnumerateDeltas(It.IsAny(), It.IsAny())) .Throws(new NotImplementedException()); sourceRepositoryMock - .Setup(repository => repository.EnumerateLeases(It.IsAny(), It.IsAny())) + .Setup(repository => repository.EnumerateLeases(It.IsAny(), It.IsAny())) .Throws(new NotImplementedException()); sourceRepositoryMock - .Setup(repository => repository.EnumerateTags(It.IsAny(), It.IsAny())) + .Setup(repository => repository.EnumerateTags(It.IsAny(), It.IsAny())) .Throws(new NotImplementedException()); sourceRepositoryMock .Setup(repository => - repository.EnumerateAnnotatedAgentSignatures(It.IsAny(), + repository.EnumerateAnnotatedAgentSignatures(It.IsAny(), It.IsAny())) .Throws(new NotImplementedException()); sourceRepositoryMock .Setup(repository => - repository.EnumerateAnnotatedDeltas(It.IsAny(), It.IsAny())) + repository.EnumerateAnnotatedDeltas(It.IsAny(), It.IsAny())) .Throws(new NotImplementedException()); sourceRepositoryMock @@ -103,21 +103,21 @@ public async Task GivenRepositoryAlwaysThrows_WhenExecutingAnyMethod_ThenExcepti // ACT var sourceIdsFromSourceDataQuery = - await tryCatchSourceRepository.EnumerateSourceIds(default(ISourceDataQuery)!).ToArrayAsync(); + await tryCatchSourceRepository.EnumerateSourceIds(default(ISourceDataDataQuery)!).ToArrayAsync(); var sourceIdsFromMessageDataQuery = - await tryCatchSourceRepository.EnumerateSourceIds(default(IMessageDataQuery)!).ToArrayAsync(); - var sourceIdsFromLeaseQuery = - await tryCatchSourceRepository.EnumerateSourceIds(default(ILeaseQuery)!).ToArrayAsync(); - var sourceIdsFromTagQuery = - await tryCatchSourceRepository.EnumerateSourceIds(default(ITagQuery)!).ToArrayAsync(); + await tryCatchSourceRepository.EnumerateSourceIds(default(IMessageDataDataQuery)!).ToArrayAsync(); + var sourceIdsFromLeaseDataQuery = + await tryCatchSourceRepository.EnumerateSourceIds(default(ILeaseDataDataQuery)!).ToArrayAsync(); + var sourceIdsFromTagDataQuery = + await tryCatchSourceRepository.EnumerateSourceIds(default(ITagDataDataQuery)!).ToArrayAsync(); var statePointersFromSourceDataQuery = - await tryCatchSourceRepository.EnumerateStatePointers(default(ISourceDataQuery)!).ToArrayAsync(); + await tryCatchSourceRepository.EnumerateStatePointers(default(ISourceDataDataQuery)!).ToArrayAsync(); var statePointersFromMessageDataQuery = - await tryCatchSourceRepository.EnumerateStatePointers(default(IMessageDataQuery)!).ToArrayAsync(); - var statePointersFromLeaseQuery = - await tryCatchSourceRepository.EnumerateStatePointers(default(ILeaseQuery)!).ToArrayAsync(); - var statePointersFromTagQuery = - await tryCatchSourceRepository.EnumerateStatePointers(default(ITagQuery)!).ToArrayAsync(); + await tryCatchSourceRepository.EnumerateStatePointers(default(IMessageDataDataQuery)!).ToArrayAsync(); + var statePointersFromLeaseDataQuery = + await tryCatchSourceRepository.EnumerateStatePointers(default(ILeaseDataDataQuery)!).ToArrayAsync(); + var statePointersFromTagDataQuery = + await tryCatchSourceRepository.EnumerateStatePointers(default(ITagDataDataQuery)!).ToArrayAsync(); var agentSignatures = await tryCatchSourceRepository.EnumerateAgentSignatures(default!).ToArrayAsync(); var deltas = @@ -135,12 +135,12 @@ public async Task GivenRepositoryAlwaysThrows_WhenExecutingAnyMethod_ThenExcepti sourceIdsFromSourceDataQuery.ShouldBeEmpty(); sourceIdsFromMessageDataQuery.ShouldBeEmpty(); - sourceIdsFromLeaseQuery.ShouldBeEmpty(); - sourceIdsFromTagQuery.ShouldBeEmpty(); + sourceIdsFromLeaseDataQuery.ShouldBeEmpty(); + sourceIdsFromTagDataQuery.ShouldBeEmpty(); statePointersFromSourceDataQuery.ShouldBeEmpty(); statePointersFromMessageDataQuery.ShouldBeEmpty(); - statePointersFromLeaseQuery.ShouldBeEmpty(); - statePointersFromTagQuery.ShouldBeEmpty(); + statePointersFromLeaseDataQuery.ShouldBeEmpty(); + statePointersFromTagDataQuery.ShouldBeEmpty(); agentSignatures.ShouldBeEmpty(); deltas.ShouldBeEmpty(); leases.ShouldBeEmpty(); diff --git a/test/EntityDb.Common.Tests/Streams/StreamTests.cs b/test/EntityDb.Common.Tests/Streams/StreamTests.cs index 65f84404..c66ed23d 100644 --- a/test/EntityDb.Common.Tests/Streams/StreamTests.cs +++ b/test/EntityDb.Common.Tests/Streams/StreamTests.cs @@ -36,14 +36,14 @@ public async Task GivenNewStreamMock_WhenStagingNewMessageKey_ThenCommittedSourc sourceRepositoryMock .InSequence(sequenceMock) .Setup(repository => - repository.EnumerateStatePointers(It.IsAny(), It.IsAny())) + repository.EnumerateStatePointers(It.IsAny(), It.IsAny())) .Returns(AsyncEnumerable.Empty()); // Second query checks if message key lease already exists sourceRepositoryMock .InSequence(sequenceMock) .Setup(repository => - repository.EnumerateStatePointers(It.IsAny(), It.IsAny())) + repository.EnumerateStatePointers(It.IsAny(), It.IsAny())) .Returns(AsyncEnumerable.Empty()); await using var serviceScope = CreateServiceScope(serviceCollection => @@ -119,7 +119,7 @@ public async Task GivenNewStream_WhenStagingNewMessageKey_ThenCommitReturnsTrue( var committed = await writeRepository.Commit(); var statePointerCount = await writeRepository.SourceRepository - .EnumerateStatePointers(new MatchingLeasesQuery(streamKeyLease, messageKeyLease)) + .EnumerateStatePointers(new MatchingLeasesDataQuery(streamKeyLease, messageKeyLease)) .CountAsync(); // ASSERT @@ -145,14 +145,14 @@ public async Task GivenExistingStreamMock_WhenStagingNewMessageKey_ThenCommitted sourceRepositoryMock .InSequence(sequenceMock) .Setup(repository => - repository.EnumerateStatePointers(It.IsAny(), It.IsAny())) + repository.EnumerateStatePointers(It.IsAny(), It.IsAny())) .Returns(AsyncEnumerablePolyfill.FromResult(new[] { statePointer })); // First query checks if message key lease already exists sourceRepositoryMock .InSequence(sequenceMock) .Setup(repository => - repository.EnumerateStatePointers(It.IsAny(), It.IsAny())) + repository.EnumerateStatePointers(It.IsAny(), It.IsAny())) .Returns(AsyncEnumerable.Empty()); await using var serviceScope = CreateServiceScope(serviceCollection => @@ -240,7 +240,7 @@ public async Task GivenExistingStream_WhenStagingNewMessageKey_ThenCommitReturns var secondCommitted = await writeRepository.Commit(); var statePointerCount = await writeRepository.SourceRepository - .EnumerateStatePointers(new MatchingLeasesQuery(streamKeyLease, messageKeyLease1, messageKeyLease2)) + .EnumerateStatePointers(new MatchingLeasesDataQuery(streamKeyLease, messageKeyLease1, messageKeyLease2)) .CountAsync(); // ASSERT @@ -264,14 +264,14 @@ public async Task GivenExistingStreamMock_WhenStagingDuplicateMessageKey_ThenSta sourceRepositoryMock .InSequence(sequenceMock) .Setup(repository => - repository.EnumerateStatePointers(It.IsAny(), It.IsAny())) + repository.EnumerateStatePointers(It.IsAny(), It.IsAny())) .Returns(AsyncEnumerablePolyfill.FromResult(new[] { statePointer })); // Second query checks if message key lease already exists sourceRepositoryMock .InSequence(sequenceMock) .Setup(repository => - repository.EnumerateStatePointers(It.IsAny(), It.IsAny())) + repository.EnumerateStatePointers(It.IsAny(), It.IsAny())) .Returns(AsyncEnumerablePolyfill.FromResult(new[] { statePointer })); await using var serviceScope = CreateServiceScope(serviceCollection => diff --git a/test/EntityDb.Common.Tests/TestsBase.cs b/test/EntityDb.Common.Tests/TestsBase.cs index 9e90b76a..1fb45a6f 100644 --- a/test/EntityDb.Common.Tests/TestsBase.cs +++ b/test/EntityDb.Common.Tests/TestsBase.cs @@ -526,7 +526,7 @@ protected static ISourceRepositoryFactory GetMockedSourceRepositoryFactory( sourceRepositoryMock .Setup(repository => - repository.EnumerateDeltas(It.IsAny(), It.IsAny())) + repository.EnumerateDeltas(It.IsAny(), It.IsAny())) .Returns(AsyncEnumerablePolyfill.FromResult(deltas)); return GetMockedSourceRepositoryFactory(sourceRepositoryMock, new List());