-
Notifications
You must be signed in to change notification settings - Fork 7
Asynchronous Rules
Arif Yayalar (@ayayalar) edited this page Aug 24, 2018
·
2 revisions
Asynchronous rules executed serially in that same order provided to the rule engine unless the ExecutionOrder
property is specified. It should be used with async programming model.
class QualifiesForFreeShippingAsync: RuleAsync<Order>
{
public async override Task<IRuleResult> InvokeAsync()
{
// Order instance accessible through the Model property.
if (Model.Amount > 50.0m) Model.FreeShipping = true;
return await RuleResult.Nil();
}
}
var ruleResults = await RuleEngine<Order>.GetInstance(order)
.ApplyRules(new QualifiesForFreeShippingAsync())
.ExecuteAsync()
Returning result from a rule is optional. Use it if additional output (e.g. error message, code, etc.) needed. In most cases the
Model
should be the input and the output of the rule engine.
Synchronous Rules |
Asynchronous Rules |
Parallel Rules |
Reactive Rules |
Proactive Rules |
ExceptionHandler Rules |