Skip to content

business_rules

etl_craft.engine.repository.business_rules

Business rules: the rules a task runs, their run log and the keys they flag.

BusinessRule dataclass

One active business rule of a task.

RuleRunBinding dataclass

A rule's run-log row under a task run, and whether it already succeeded there.

fetch_business_rules_for_task

fetch_business_rules_for_task(conn: Connection, task_id: int) -> list[BusinessRule]

Return the active business rules of task_id, in the order they run.

begin_rule_run

begin_rule_run(conn: Connection, business_rule_id: int, task_run_id: int, now: datetime) -> RuleRunBinding

Bind business_rule_id to task_run_id: its existing row, or a new one.

An existing row that did not succeed starts another attempt, IN-PROGRESS again.

finish_rule_run

finish_rule_run(conn: Connection, business_rule_run_id: int, status: str, now: datetime) -> None

End a rule's run-log row with status.

fetch_active_rule_keys

fetch_active_rule_keys(conn: Connection, business_rule_id: int) -> set[str]

Return the keys business_rule_id currently flags.

flag_rule_keys

flag_rule_keys(conn: Connection, rule: BusinessRule, business_rule_run_id: int, keys: Sequence[str], now: datetime) -> None

Flag keys for rule, found by business_rule_run_id.

clear_rule_keys

clear_rule_keys(conn: Connection, business_rule_id: int, keys: Sequence[str], now: datetime) -> None

Clear active flags in batches of at most 1,000 keys on the caller's transaction.