Skip to content

Commit

Permalink
refactor: better object names + entity and stream repos will short-ci…
Browse files Browse the repository at this point in the history
…rcuit returns true if there are no messages to commit
  • Loading branch information
the-avid-engineer committed Jan 10, 2024
1 parent 5f8d36d commit 4831091
Show file tree
Hide file tree
Showing 62 changed files with 446 additions and 436 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ public interface IMultipleEntityRepository<TEntity> : IDisposableResource
/// Atomically commits a source.
/// </summary>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns><c>true</c> if the commit succeeded, or <c>false</c> if the commit failed.</returns>
/// <returns>Only returns <c>false</c> if there are uncommitted messages.</returns>
Task<bool> Commit(CancellationToken cancellationToken = default);
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ public interface ISingleEntityRepository<TEntity> : IDisposableResource
/// Atomically commits a source.
/// </summary>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns><c>true</c> if the commit succeeded, or <c>false</c> if the commit failed.</returns>
/// <returns>Only returns <c>false</c> if there are uncommitted messages.</returns>
Task<bool> Commit(CancellationToken cancellationToken = default);
}
4 changes: 2 additions & 2 deletions src/EntityDb.Abstractions/Projections/IProjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ public interface IProjection<TProjection> : IState<TProjection>
void Mutate(Source source);

/// <summary>
/// Returns a <see cref="ISourceDataQuery" /> that finds sources that need to be passed to the reducer.
/// Returns a <see cref="ISourceDataDataQuery" /> that finds sources that need to be passed to the reducer.
/// </summary>
/// <param name="serviceProvider">A service provider for fetching repositories.</param>
/// <param name="projectionPointer">A pointer to the desired projection state</param>
/// <param name="cancellationToken">A cancellation token</param>
/// <returns>
/// A <see cref="IQuery" /> that is used to load the rest of the messages for the given projection
/// A <see cref="IDataQuery" /> that is used to load the rest of the messages for the given projection
/// pointer.
/// </returns>
IAsyncEnumerable<Source> EnumerateSources(IServiceProvider serviceProvider, Pointer projectionPointer,
Expand Down
86 changes: 43 additions & 43 deletions src/EntityDb.Abstractions/Sources/ISourceRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,135 +14,135 @@ public interface ISourceRepository : IDisposableResource
/// <summary>
/// Returns the source ids which are found by a message group query.
/// </summary>
/// <param name="sourceDataQuery">The source data query.</param>
/// <param name="sourceDataDataQuery">The source data query.</param>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns>The source ids which are found by <paramref name="sourceDataQuery" />.</returns>
IAsyncEnumerable<Id> EnumerateSourceIds(ISourceDataQuery sourceDataQuery,
/// <returns>The source ids which are found by <paramref name="sourceDataDataQuery" />.</returns>
IAsyncEnumerable<Id> EnumerateSourceIds(ISourceDataDataQuery sourceDataDataQuery,
CancellationToken cancellationToken = default);

/// <summary>
/// Returns the source ids which are found by a message query.
/// </summary>
/// <param name="messageDataQuery">The message data query.</param>
/// <param name="messageDataDataQuery">The message data query.</param>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns>The source ids which are found by <paramref name="messageDataQuery" />.</returns>
IAsyncEnumerable<Id> EnumerateSourceIds(IMessageDataQuery messageDataQuery,
/// <returns>The source ids which are found by <paramref name="messageDataDataQuery" />.</returns>
IAsyncEnumerable<Id> EnumerateSourceIds(IMessageDataDataQuery messageDataDataQuery,
CancellationToken cancellationToken = default);

/// <summary>
/// Returns the source ids which are found by a lease query.
/// </summary>
/// <param name="leaseQuery">The lease query.</param>
/// <param name="leaseDataDataQuery">The lease query.</param>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns>The source ids which are found by <paramref name="leaseQuery" />.</returns>
IAsyncEnumerable<Id> EnumerateSourceIds(ILeaseQuery leaseQuery,
/// <returns>The source ids which are found by <paramref name="leaseDataDataQuery" />.</returns>
IAsyncEnumerable<Id> EnumerateSourceIds(ILeaseDataDataQuery leaseDataDataQuery,
CancellationToken cancellationToken = default);

/// <summary>
/// Returns the source ids which are found by a tag query.
/// </summary>
/// <param name="tagQuery">The tag query.</param>
/// <param name="tagDataDataQuery">The tag query.</param>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns>The source ids which are found by <paramref name="tagQuery" />.</returns>
IAsyncEnumerable<Id> EnumerateSourceIds(ITagQuery tagQuery,
/// <returns>The source ids which are found by <paramref name="tagDataDataQuery" />.</returns>
IAsyncEnumerable<Id> EnumerateSourceIds(ITagDataDataQuery tagDataDataQuery,
CancellationToken cancellationToken = default);

/// <summary>
/// Returns the state pointers which are found by a agentSignature query.
/// </summary>
/// <param name="sourceDataQuery">The source data query.</param>
/// <param name="sourceDataDataQuery">The source data query.</param>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns>The state pointers which are found by <paramref name="sourceDataQuery" />.</returns>
IAsyncEnumerable<Pointer> EnumerateStatePointers(ISourceDataQuery sourceDataQuery,
/// <returns>The state pointers which are found by <paramref name="sourceDataDataQuery" />.</returns>
IAsyncEnumerable<Pointer> EnumerateStatePointers(ISourceDataDataQuery sourceDataDataQuery,
CancellationToken cancellationToken = default);

/// <summary>
/// Returns the state pointers which are found by a message query.
/// </summary>
/// <param name="messageDataQuery">The message data query.</param>
/// <param name="messageDataDataQuery">The message data query.</param>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns>The state pointers which are found by <paramref name="messageDataQuery" />.</returns>
IAsyncEnumerable<Pointer> EnumerateStatePointers(IMessageDataQuery messageDataQuery,
/// <returns>The state pointers which are found by <paramref name="messageDataDataQuery" />.</returns>
IAsyncEnumerable<Pointer> EnumerateStatePointers(IMessageDataDataQuery messageDataDataQuery,
CancellationToken cancellationToken = default);

/// <summary>
/// Returns the state pointers which are found by a lease query.
/// </summary>
/// <param name="leaseQuery">The lease query.</param>
/// <param name="leaseDataDataQuery">The lease query.</param>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns>The state pointers which are found by <paramref name="leaseQuery" />.</returns>
IAsyncEnumerable<Pointer> EnumerateStatePointers(ILeaseQuery leaseQuery,
/// <returns>The state pointers which are found by <paramref name="leaseDataDataQuery" />.</returns>
IAsyncEnumerable<Pointer> EnumerateStatePointers(ILeaseDataDataQuery leaseDataDataQuery,
CancellationToken cancellationToken = default);

/// <summary>
/// Returns the state pointers which are found by a tag query.
/// </summary>
/// <param name="tagQuery">The tag query.</param>
/// <param name="tagDataDataQuery">The tag query.</param>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns>The state pointers which are found by <paramref name="tagQuery" />.</returns>
IAsyncEnumerable<Pointer> EnumerateStatePointers(ITagQuery tagQuery,
/// <returns>The state pointers which are found by <paramref name="tagDataDataQuery" />.</returns>
IAsyncEnumerable<Pointer> EnumerateStatePointers(ITagDataDataQuery tagDataDataQuery,
CancellationToken cancellationToken = default);

/// <summary>
/// Returns the agentSignatures which are found by an message group query.
/// </summary>
/// <param name="sourceDataQuery">The source data query.</param>
/// <param name="sourceDataDataQuery">The source data query.</param>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns>The agent signatures which are found by <paramref name="sourceDataQuery" />.</returns>
IAsyncEnumerable<object> EnumerateAgentSignatures(ISourceDataQuery sourceDataQuery,
/// <returns>The agent signatures which are found by <paramref name="sourceDataDataQuery" />.</returns>
IAsyncEnumerable<object> EnumerateAgentSignatures(ISourceDataDataQuery sourceDataDataQuery,
CancellationToken cancellationToken = default);

/// <summary>
/// Returns the deltas which are found by a message query.
/// </summary>
/// <param name="messageDataQuery">The message data query.</param>
/// <param name="messageDataDataQuery">The message data query.</param>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns>The deltas which are found by <paramref name="messageDataQuery" />.</returns>
IAsyncEnumerable<object> EnumerateDeltas(IMessageDataQuery messageDataQuery,
/// <returns>The deltas which are found by <paramref name="messageDataDataQuery" />.</returns>
IAsyncEnumerable<object> EnumerateDeltas(IMessageDataDataQuery messageDataDataQuery,
CancellationToken cancellationToken = default);

/// <summary>
/// Returns the leases which are found by a lease query.
/// </summary>
/// <param name="leaseQuery">The lease query.</param>
/// <param name="leaseDataDataQuery">The lease query.</param>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns>The leases which are found by <paramref name="leaseQuery" />.</returns>
IAsyncEnumerable<ILease> EnumerateLeases(ILeaseQuery leaseQuery,
/// <returns>The leases which are found by <paramref name="leaseDataDataQuery" />.</returns>
IAsyncEnumerable<ILease> EnumerateLeases(ILeaseDataDataQuery leaseDataDataQuery,
CancellationToken cancellationToken = default);

/// <summary>
/// Returns the tags which are found by a tag query.
/// </summary>
/// <param name="tagQuery">The tag query.</param>
/// <param name="tagDataDataQuery">The tag query.</param>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns>The tags which are found by <paramref name="tagQuery" />.</returns>
IAsyncEnumerable<ITag> EnumerateTags(ITagQuery tagQuery,
/// <returns>The tags which are found by <paramref name="tagDataDataQuery" />.</returns>
IAsyncEnumerable<ITag> EnumerateTags(ITagDataDataQuery tagDataDataQuery,
CancellationToken cancellationToken = default);

/// <summary>
/// Returns the annotated agent signatures which are found by a message group query.
/// </summary>
/// <param name="sourceDataQuery">The source data query.</param>
/// <param name="sourceDataDataQuery">The source data query.</param>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns>The annotated agent signatures which are found by <paramref name="sourceDataQuery" />.</returns>
/// <returns>The annotated agent signatures which are found by <paramref name="sourceDataDataQuery" />.</returns>
IAsyncEnumerable<IAnnotatedSourceData<object>> EnumerateAnnotatedAgentSignatures(
ISourceDataQuery sourceDataQuery,
ISourceDataDataQuery sourceDataDataQuery,
CancellationToken cancellationToken = default);

/// <summary>
/// Returns the annotated deltas which are found by a message query.
/// </summary>
/// <param name="messageDataQuery">The message data query.</param>
/// <param name="messageDataDataQuery">The message data query.</param>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns>The annotated deltas which are found by <paramref name="messageDataQuery" />.</returns>
IAsyncEnumerable<IAnnotatedMessageData<object>> EnumerateAnnotatedDeltas(IMessageDataQuery messageDataQuery,
/// <returns>The annotated deltas which are found by <paramref name="messageDataDataQuery" />.</returns>
IAsyncEnumerable<IAnnotatedMessageData<object>> EnumerateAnnotatedDeltas(IMessageDataDataQuery messageDataDataQuery,
CancellationToken cancellationToken = default);

/// <summary>
/// Atomically commits a single source.
/// </summary>
/// <param name="source">The source.</param>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns><c>true</c> if the insert succeeded, or <c>false</c> if the insert failed.</returns>
/// <returns>Returns <c>true</c> unless the source cannot be committed.</returns>
Task<bool> Commit(Source source, CancellationToken cancellationToken = default);
}
4 changes: 2 additions & 2 deletions src/EntityDb.Abstractions/Sources/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public sealed record Message
public ITag[] AddTags { get; init; } = Array.Empty<ITag>();

/// <summary>
/// The tags to be deleted.
/// The leases to be deleted.
/// </summary>
public ILease[] DeleteLeases { get; init; } = Array.Empty<ILease>();

/// <summary>
/// The aliases to be added.
/// The tags to be deleted.
/// </summary>
public ITag[] DeleteTags { get; init; } = Array.Empty<ITag>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace EntityDb.Abstractions.Sources.Queries.FilterBuilders;

/// <summary>
/// Builds a <typeparamref name="TFilter" /> for an object. Possible objects include:
/// agent signatures, deltas, facts, tags, and aliases
/// agent signatures, deltas, facts, and tags.
/// </summary>
/// <typeparam name="TFilter">The type of filter used by the repository.</typeparam>
public interface IFilterBuilder<TFilter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace EntityDb.Abstractions.Sources.Queries.FilterBuilders;
/// <summary>
/// Builds a <typeparamref name="TFilter" /> for an object associated
/// with a single message. Possible objects include:
/// deltas, facts, tags, and aliases
/// deltas, facts, and tags.
/// </summary>
/// <typeparam name="TFilter">The type of filter used by the repository.</typeparam>
public interface IMessageDataFilterBuilder<TFilter> : IFilterBuilder<TFilter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

/// <summary>
/// Abstracts a query for an object repository. Possible objects include:
/// agentSignatures, deltas, facts, leases, and aliases.
/// agentSignatures, deltas, facts, and leases.
/// </summary>
public interface IQuery
public interface IDataQuery
{
/// <summary>
/// The number of objects to skip.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace EntityDb.Abstractions.Sources.Queries;
/// <summary>
/// Abstracts a query on leases.
/// </summary>
public interface ILeaseQuery : IQuery
public interface ILeaseDataDataQuery : IDataQuery
{
/// <summary>
/// Returns a <typeparamref name="TFilter" /> built from a lease filter builder.
Expand All @@ -22,5 +22,5 @@ public interface ILeaseQuery : IQuery
/// <typeparam name="TSort">The type of sort used by the repository.</typeparam>
/// <param name="builder">The lease sort builder.</param>
/// <returns>A <typeparamref name="TSort" /> built from <paramref name="builder" />.</returns>
TSort? GetSort<TSort>(ILeaseSortBuilder<TSort> builder);
TSort? GetSort<TSort>(ILeaseDataSortBuilder<TSort> builder);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace EntityDb.Abstractions.Sources.Queries;
/// <summary>
/// Abstracts a query on messages.
/// </summary>
public interface IMessageDataQuery : IQuery
public interface IMessageDataDataQuery : IDataQuery
{
/// <summary>
/// Returns a <typeparamref name="TFilter" /> built from a message filter builder.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace EntityDb.Abstractions.Sources.Queries;
/// <summary>
/// Abstracts a query on agentSignatures.
/// </summary>
public interface ISourceDataQuery : IQuery
public interface ISourceDataDataQuery : IDataQuery
{
/// <summary>
/// Returns a <typeparamref name="TFilter" /> built from a agentSignature filter builder.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace EntityDb.Abstractions.Sources.Queries;
/// <summary>
/// Abstracts a query on tags.
/// </summary>
public interface ITagQuery : IQuery
public interface ITagDataDataQuery : IDataQuery
{
/// <summary>
/// Returns a <typeparamref name="TFilter" /> built from a tag filter builder.
Expand All @@ -22,5 +22,5 @@ public interface ITagQuery : IQuery
/// <typeparam name="TSort">The type of sort used by the repository.</typeparam>
/// <param name="builder">The tag sort builder.</param>
/// <returns>A <typeparamref name="TSort" /> built from <paramref name="builder" />.</returns>
TSort? GetSort<TSort>(ITagSortBuilder<TSort> builder);
TSort? GetSort<TSort>(ITagDataSortBuilder<TSort> builder);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace EntityDb.Abstractions.Sources.Queries.SortBuilders;
/// Builds a sort for a lease query.
/// </summary>
/// <typeparam name="TSort">The type of sort used by the repository.</typeparam>
public interface ILeaseSortBuilder<TSort> : IMessageDataSortBuilder<TSort>
public interface ILeaseDataSortBuilder<TSort> : IMessageDataSortBuilder<TSort>
{
/// <summary>
/// Returns a <typeparamref name="TSort" /> that orders leases by <see cref="ILease.Scope" />.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/// <summary>
/// Builds a sort for an object repository. Possible objects include:
/// agentSignatures, deltas, facts, leases, and aliases.
/// agentSignatures, deltas, facts, and leases.
/// </summary>
/// <typeparam name="TSort">The type of sort used by the repository.</typeparam>
public interface ISortBuilder<TSort>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace EntityDb.Abstractions.Sources.Queries.SortBuilders;
/// Builds a sort for a tag query.
/// </summary>
/// <typeparam name="TSort">The type of sort used by the repository.</typeparam>
public interface ITagSortBuilder<TSort> : IMessageDataSortBuilder<TSort>
public interface ITagDataSortBuilder<TSort> : IMessageDataSortBuilder<TSort>
{
/// <summary>
/// Returns a <typeparamref name="TSort" /> that orders tags by <see cref="ITag.Label" />.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public interface IMultipleStreamRepository : IDisposableResource
/// Commits all stages deltas.
/// </summary>
/// <param name="cancellationToken">A cancellation token</param>
/// <returns><c>true</c> if the commit succeeded, or <c>false</c> if the commit failed.</returns>
/// <returns>Only returns <c>false</c> if there are uncommitted messages.</returns>
Task<bool> Commit(CancellationToken cancellationToken = default);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ public interface ISingleStreamRepository : IDisposableResource
/// Commits all stages deltas.
/// </summary>
/// <param name="cancellationToken">A cancellation token</param>
/// <returns><c>true</c> if the commit succeeded, or <c>false</c> if the commit failed.</returns>
/// <returns>Only returns <c>false</c> if there are uncommitted messages.</returns>
Task<bool> Commit(CancellationToken cancellationToken = default);
}
Loading

0 comments on commit 4831091

Please sign in to comment.