-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #328 from J-Tech-Japan/324-needs-contextappendeven…
…ts-multiple-add
- Loading branch information
Showing
20 changed files
with
173 additions
and
99 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
...ges/FeatureCheck.Domain/Aggregates/ALotOfEvents/Commands/ALotOfEventsCreateCommandNext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using FeatureCheck.Domain.Aggregates.ALotOfEvents.Events; | ||
using ResultBoxes; | ||
using Sekiban.Core.Command; | ||
using Sekiban.Core.Events; | ||
namespace FeatureCheck.Domain.Aggregates.ALotOfEvents.Commands; | ||
|
||
public record ALotOfEventsCreateCommandNext(Guid AggregateId, int NumberOfEvents) | ||
: ICommandWithHandler<ALotOfEventsAggregate, ALotOfEventsCreateCommandNext> | ||
{ | ||
public Guid GetAggregateId() => AggregateId; | ||
public static ResultBox<UnitValue> HandleCommand(ALotOfEventsCreateCommandNext command, ICommandContext<ALotOfEventsAggregate> context) => | ||
ResultBox.FromValue( | ||
Enumerable.Range(1, command.NumberOfEvents) | ||
.Select(i => (IEventPayloadApplicableTo<ALotOfEventsAggregate>)new ALotOfEventsSingleEvent(i.ToString())) | ||
.ToArray()) | ||
.Conveyor(context.AppendEvents); | ||
} |
12 changes: 12 additions & 0 deletions
12
...rnalUsages/FeatureCheck.Domain/Aggregates/ALotOfEvents/Commands/TwoEventsCreateCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using FeatureCheck.Domain.Aggregates.ALotOfEvents.Events; | ||
using ResultBoxes; | ||
using Sekiban.Core.Command; | ||
namespace FeatureCheck.Domain.Aggregates.ALotOfEvents.Commands; | ||
|
||
public record TwoEventsCreateCommand(Guid AggregateId) : ICommandWithHandler<ALotOfEventsAggregate, TwoEventsCreateCommand> | ||
{ | ||
|
||
public Guid GetAggregateId() => AggregateId; | ||
public static ResultBox<UnitValue> HandleCommand(TwoEventsCreateCommand command, ICommandContext<ALotOfEventsAggregate> context) => | ||
context.AppendEvents(new ALotOfEventsSingleEvent("0"), new ALotOfEventsSingleEvent("1")); | ||
} |
17 changes: 17 additions & 0 deletions
17
internalUsages/FeatureCheck.Domain/Aggregates/Branches/Commands/ChangeBranchNameNext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using FeatureCheck.Domain.Aggregates.Branches.Events; | ||
using ResultBoxes; | ||
using Sekiban.Core.Command; | ||
using System.ComponentModel.DataAnnotations; | ||
namespace FeatureCheck.Domain.Aggregates.Branches.Commands; | ||
|
||
public record ChangeBranchNameNext( | ||
Guid BranchId, | ||
[property: Required] | ||
[property: MaxLength(20)] | ||
string Name) : ICommandWithHandlerForExistingAggregate<Branch, ChangeBranchNameNext> | ||
{ | ||
|
||
public Guid GetAggregateId() => BranchId; | ||
public static ResultBox<UnitValue> HandleCommand(ChangeBranchNameNext command, ICommandContext<Branch> context) => | ||
context.AppendEvent(new BranchNameChanged(command.Name)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using ResultBoxes; | ||
using Sekiban.Core.Aggregate; | ||
using Sekiban.Core.Command; | ||
using Sekiban.Core.Documents; | ||
using Sekiban.Core.History; | ||
using Sekiban.Core.Query.QueryModel; | ||
using Sekiban.Core.Query.SingleProjections; | ||
namespace Sekiban.Core; | ||
|
||
public class SekibanExecutor( | ||
ICommandExecutor commandExecutor, | ||
IAggregateLoader aggregateLoader, | ||
IQueryExecutor queryExecutor, | ||
IServiceProvider serviceProvider) : ISekibanExecutor | ||
{ | ||
public ResultBox<T1> GetRequiredService<T1>() where T1 : class => ResultBox.WrapTry(serviceProvider.GetRequiredService<T1>); | ||
|
||
public Task<ResultBox<CommandExecutorResponse>> ExecuteCommand<TCommand>(TCommand command, List<CallHistory>? callHistories = null) | ||
where TCommand : ICommandCommon => | ||
commandExecutor.ExecCommandWithResultAsync(command, callHistories); | ||
public Task<ResultBox<CommandExecutorResponse>> ExecuteCommandWithoutValidation<TCommand>( | ||
TCommand command, | ||
List<CallHistory>? callHistories = null) where TCommand : ICommandCommon => | ||
commandExecutor.ExecCommandWithoutValidationWithResultAsync(command, callHistories); | ||
public Task<ResultBox<CommandExecutorResponseWithEvents>> ExecuteCommandWithoutValidationWithEvents<TCommand>( | ||
TCommand command, | ||
List<CallHistory>? callHistories = null) where TCommand : ICommandCommon => | ||
commandExecutor.ExecCommandWithoutValidationWithEventsWithResultAsync(command, callHistories); | ||
|
||
public Task<ResultBox<CommandExecutorResponseWithEvents>> ExecuteCommandWithEvents<TCommand>( | ||
TCommand command, | ||
List<CallHistory>? callHistories = null) where TCommand : ICommandCommon => | ||
commandExecutor.ExecCommandWithEventsWithResultAsync(command, callHistories); | ||
|
||
public Task<ResultBox<AggregateState<TAggregatePayloadCommon>>> GetAggregateState<TAggregatePayloadCommon>( | ||
Guid aggregateId, | ||
string rootPartitionKey = IDocument.DefaultRootPartitionKey, | ||
int? toVersion = null, | ||
SingleProjectionRetrievalOptions? retrievalOptions = null) where TAggregatePayloadCommon : IAggregatePayloadCommon => | ||
aggregateLoader.AsDefaultStateWithResultAsync<TAggregatePayloadCommon>(aggregateId, rootPartitionKey, toVersion, retrievalOptions); | ||
|
||
public Task<ResultBox<AggregateState<TAggregatePayloadCommon>>> GetAggregateStateFromInitial<TAggregatePayloadCommon>( | ||
Guid aggregateId, | ||
string rootPartitionKey = IDocument.DefaultRootPartitionKey, | ||
int? toVersion = null) where TAggregatePayloadCommon : IAggregatePayloadCommon => | ||
aggregateLoader.AsDefaultStateFromInitialWithResultAsync<TAggregatePayloadCommon>(aggregateId, rootPartitionKey, toVersion); | ||
|
||
public Task<ResultBox<SingleProjectionState<TSingleProjectionPayload>>> GetSingleProjectionStateFromInitial<TSingleProjectionPayload>( | ||
Guid aggregateId, | ||
string rootPartitionKey = IDocument.DefaultRootPartitionKey, | ||
int? toVersion = null) where TSingleProjectionPayload : class, ISingleProjectionPayloadCommon => | ||
ResultBox.CheckNullWrapTry( | ||
() => aggregateLoader.AsSingleProjectionStateFromInitialAsync<TSingleProjectionPayload>(aggregateId, rootPartitionKey, toVersion)); | ||
public Task<ResultBox<SingleProjectionState<TSingleProjectionPayload>>> GetSingleProjectionState<TSingleProjectionPayload>( | ||
Guid aggregateId, | ||
string rootPartitionKey = IDocument.DefaultRootPartitionKey, | ||
int? toVersion = null, | ||
SingleProjectionRetrievalOptions? retrievalOptions = null) where TSingleProjectionPayload : class, ISingleProjectionPayloadCommon => | ||
ResultBox.CheckNullWrapTry( | ||
() => aggregateLoader.AsSingleProjectionStateAsync<TSingleProjectionPayload>(aggregateId, rootPartitionKey, toVersion, retrievalOptions)); | ||
public Task<ResultBox<TOutput>> ExecuteQuery<TOutput>(INextQueryCommon<TOutput> query) where TOutput : notnull => | ||
queryExecutor.ExecuteAsync(query); | ||
public Task<ResultBox<ListQueryResult<TOutput>>> ExecuteQuery<TOutput>(INextListQueryCommon<TOutput> query) where TOutput : notnull => | ||
queryExecutor.ExecuteAsync(query); | ||
public Task<ResultBox<ListQueryResult<TOutput>>> ExecuteQuery<TOutput>(IListQueryInput<TOutput> param) where TOutput : IQueryResponse => | ||
queryExecutor.ExecuteWithResultAsync(param); | ||
public Task<ResultBox<TOutput>> ExecuteQuery<TOutput>(IQueryInput<TOutput> param) where TOutput : IQueryResponse => | ||
queryExecutor.ExecuteWithResultAsync(param); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.