Skip to content

Expand, validate & simplify logic before execution #17

@arnodirlam

Description

@arnodirlam

Currently, when executing logic, the mappings and conditions must look up the rules while traversing the requirements. This is true for Dx.Engine and the ecto query builder.

Downsides

  • the lookup is relatively slow (calling functions on modules dynamically) and is executed repeatedly, for each node in the logic tree, for each subject, and for each evaluation after loading data
  • the execution can not be simplified/optimized easily, because there's no easy way to "look ahead"
  • changes in the DSL must often be reflected in the execution, blurring the line of separation of concerns

Solution

We introduce an intermediate data structure, a "plan", based on what's needed in a particular evaluation run (the "logic tree"). This is a subset of the DSL.

The goal is that the Dx.Engine and the ecto query builder receive only the plan and don't need to look up any rules. They only need to understand the plan, and nothing that goes into the plan.

Advantages

  • the plan is created before execution, only once, and can easily be simplified/optimized and then re-used within one evaluation run
  • clear separation of concerns

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions