Go+JS framework for 3factor app
Constraints:
-
Firestore document allows 1 write/sec
-
Firestore path needs to follow a format:
/collection/doc/collection/doc
A task may have the following states:
- Waiting
- Running
- Done (error/success)
- Timeout
Format:
/[waiting|running/done/timeout]/{type}/jobs/{id}
Runners:
job_executor_function<type>
- Triggered by creation in
/waiting/{type}/jobs/*
- Move to
/running/{type}/jobs/{id}
- Execute
- Move to
/done/{type}/jobs/{id}
- Triggered by creation in
timeout_returner
- On schedule (every 5 minutes)
- If timeoutOn is exceeded, moves task to
/waiting/{type}/jobs/*
- Does not handle timeouts
- Function crashes are silent
- Less costly: less writes/reads
- Faster
Format:
/tasks_xxxcol/[waiting|done]/{type}/jobs/{id}
Runner: job_executor_function<type>
:
- Triggered by creation in
/tasks_xxxcol/waiting/{type}/jobs/*
- Execute
- Move to
/tasks_xxxcol/done/{type}/jobs/{id}
Cost:
- Writes: 2 (creation + move) ($0.039 per 100,000 documents)
- Deletes: 1 (creation + move) ()$0.013 per 100,000 documents)
- Reads: 2 (trigger+run, result read) ($0.013 per 100,000 documents)
Total: 0,117$ per 100,000 tasks