作業重試和解決方案
目的:明確操作非同步作業並確定性地處理故障狀態。
使用者介面流程
- UI 顯示每個帳戶的佇列和任務狀態。
- 使用者在失敗或卡住時開啟作業詳細資料。
- UI 允許
Trigger、Retry和Resolve。 - UI 反白顯示
last_error_code和last_error_detail。 - UI 在作業操作後刷新任務狀態。
客戶端庫流程
const jobs = await api.jobs.list(accountId, { limit: 50 });
const failed = jobs.data.filter((row) => row.failed_at);
for (const job of failed) {
await api.jobs.retry(job.id);
}
const inFlight = await api.jobs.list(accountId, {
q: "imap_sync_messages",
limit: 20,
});
HTTP/curl 流程
API_BASE_URL="https://api.inbox-manager.com"
curl -sS "${API_BASE_URL}/api/accounts/${ACCOUNT_ID}/jobs?limit=20&offset=0" \
-H "authorization: Bearer ${BEARER_TOKEN}"
curl -sS -X POST "${API_BASE_URL}/api/jobs/${JOB_ID}/trigger" \
-H "authorization: Bearer ${BEARER_TOKEN}" \
-H "content-type: application/json" \
--data '{}'
curl -sS -X POST "${API_BASE_URL}/api/jobs/${JOB_ID}/retry" \
-H "authorization: Bearer ${BEARER_TOKEN}" \
-H "content-type: application/json" \
--data '{}'
curl -sS -X POST "${API_BASE_URL}/api/jobs/${JOB_ID}/resolve" \
-H "authorization: Bearer ${BEARER_TOKEN}" \
-H "content-type: application/json" \
--data '{"note":"handled after provider maintenance window"}'
錯誤分類方向
- 工作人員現在記錄分類
last_error_code值:- 瞬時連接
- 身份驗證
- 授權
- 配置
- 有效負載驗證
- 未找到