File size: 674 Bytes
45dc2a1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
"""
Everything that happens "when its time comes", run from one place so a single timer drives it:
queued and scheduled sends, and automations (sequences, recurring and date-based sends).
See docs/blueprint/adr/0004.
"""

from __future__ import annotations

from datetime import datetime

from backend import automations, delivery, sending


def run_due(now: datetime | None = None, budget_seconds: float = 240) -> dict:
    # Automations first, so the campaigns they make are picked up in the same pass.
    made = automations.run_due(now)
    sends = sending.run_due(now, budget_seconds)
    return {"automations": made, "sends": sends, "delivery": delivery.run_due(now)}