-
Notifications
You must be signed in to change notification settings - Fork 68
The command execution pipeline
Aaron Hanusa edited this page Feb 4, 2021
·
1 revision
This sequence diagram models the asynchronous command execution pipeline detailing the flow of calls between objects when the command returned from the ServiceBase.InsertCommand method is invoked.
- A client application invokes
ServiceBase.InsertCommand
, supplying a DTO. - ServiceBase creates an instance of ExecutionContext.
- ServiceBase creates an instance of ServiceCommand. Note that there are many constructor arguments left out for the sake of brevity.
- The client is returned an instance of the service command created in step 3.
- The client invokes
ServiceCommand.ExecuteAsync
. - ServiceCommand invokes
ServiceBase.OnInsertCommandInitializationAsync
, passing in the execution context created in step 2 and the DTO from step 1. - ServiceCommand invokes
ServiceBase.OnInsertCommandGetRulesAsync
, passing in the execution context created in step 2 and the DTO from step 1. - If any rules are returned from step 7, each one is validated, by invoking
IRule.ExecuteAsync
. - If all rules are validated successfully:
- ServiceCommand invokes
ServiceBase.OnInsertCommandValidationSuccessAsync
, passing in the execution context create in step 2 and the DTO from step 1. - ServiceBase invokes
IDataProxy.InsertAsync
, passing in the DTO received from step 1. - ServiceBase receives a new DTO instance created by
IDataProxy.InsertAsync
. - ServiceBase returns the new instance of the DTO to ServiceCommand.
- ServiceCommand instantiates an instance of ExecutionResult, passing in the new DTO instance, and returns it to the client application.
- ServiceCommand invokes
- If validation of any of the rules fail:
- ServiceCommand instantiates an instance of ExecutionResult, passing in errors from all failed rules, and returns it to the client application.
By overriding methods of ServiceBase, namely OnInsertCommandInitializationAsync
, OnInsertCommandGetRulesAsync
, and OnInsertCommandValidationSuccessAsync
, you have the opportunity to inject initialization logic, business rules, and command logic into the command execution pipeline, respectively.