Package com.helix.core
Class DefaultRuleEngine
java.lang.Object
com.helix.core.DefaultRuleEngine
- All Implemented Interfaces:
RuleEngine,AutoCloseable
Default implementation of
RuleEngine orchestrating compilation and execution.-
Constructor Summary
ConstructorsConstructorDescriptionDefaultRuleEngine(RuleCompiler compiler, SyncExecutor syncExecutor, AsyncExecutor asyncExecutor) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Compiles a raw rule into an executable rule instance.execute(CompiledRule rule, ExecutionContext context) Synchronously executes a compiled rule against the provided context.executeAsync(CompiledRule rule, ExecutionContext context) Asynchronously executes a compiled rule against the provided context.
-
Constructor Details
-
DefaultRuleEngine
public DefaultRuleEngine() -
DefaultRuleEngine
public DefaultRuleEngine(RuleCompiler compiler, SyncExecutor syncExecutor, AsyncExecutor asyncExecutor)
-
-
Method Details
-
compile
Description copied from interface:RuleEngineCompiles a raw rule into an executable rule instance.- Specified by:
compilein interfaceRuleEngine- Parameters:
rule- the raw rule definition- Returns:
- compiled rule instance
- Throws:
RuleCompilationException- if compilation fails
-
execute
public ExecutionResult execute(CompiledRule rule, ExecutionContext context) throws RuleExecutionException Description copied from interface:RuleEngineSynchronously executes a compiled rule against the provided context.- Specified by:
executein interfaceRuleEngine- Parameters:
rule- the compiled rulecontext- the execution context- Returns:
- the execution result
- Throws:
RuleExecutionException- if execution fails
-
executeAsync
Description copied from interface:RuleEngineAsynchronously executes a compiled rule against the provided context.- Specified by:
executeAsyncin interfaceRuleEngine- Parameters:
rule- the compiled rulecontext- the execution context- Returns:
- a CompletableFuture wrapping the execution result
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-