Background Job
Lavoro in background
Un lavoro in background è un'attività che il server esegue separatamente dalla pagina o dalla risposta API che può avviarlo. La risposta può completarsi prima che il lavoro sia finito.
accepted request -> persisted job ID -> runner attempt -> terminal result; bounded retryGET /jobs/job_482accepted request -> persisted job ID -> runner attempt -> terminal result; bounded retryJOBUn altro esempio
Una richiesta di report crea il job `report-204` e risponde con un link di stato. Un Kubernetes Job esegue il report fino a quando non ha successo o raggiunge il limite di tentativi, registra quello stato finale e si ferma.
Parti principali
- 01ID del processo e input salvato
- 02Stato accettato o in coda
- 03Runner e tentativo
- 04Progresso o battito cardiaco
- 05Stato di successo o fallimento
- 06Risultato e percorso di recupero
Usalo quando
Usa un lavoro in background quando un'attività lenta può terminare dopo che la persona ha ricevuto una risposta. Salva il suo input, identità, stato e risultato finale.
Non usarlo quando
Non usarlo quando la risposta richiede il risultato immediato. Un esecutore potrebbe tentare nuovamente un lavoro fallito. Aggiungi una regola di sicurezza prima di ripetere addebiti, email o altri effetti.
Nome usato nel codice
accepted request -> persisted job ID -> runner attempt -> terminal result; bounded retry Prima di spedire
Check contracts and invariants, authorization, and input limits. Test retries, one-time effects, timeouts, and partial failures. Verify data integrity, compatibility, monitoring, recovery, and rollback.
Outcome: Complete the task with Lavoro in background (Background Job). User context: Una richiesta di report crea il job `report-204` e risponde con un link di stato. Un Kubernetes Job esegue il report fino a quando non ha successo o raggiunge il limite di tentativi, registra quello stato finale e si ferma. Technical concept or control: Lavoro in background (Background Job). Why it fits: Usa un lavoro in background quando un'attività lenta può terminare dopo che la persona ha ricevuto una risposta. Salva il suo input, identità, stato e risultato finale. Do not use it when: Non usarlo quando la risposta richiede il risultato immediato. Un esecutore potrebbe tentare nuovamente un lavoro fallito. Aggiungi una regola di sicurezza prima di ripetere addebiti, email o altri effetti. Engineering requirements: Define inputs, outputs, contracts, and rules that must always hold. Set authorization and input checks. Define failures, timeouts, retries, one-time effects, data moves, and compatibility limits. Operations: Add useful signals and logs that hide sensitive data. Set capacity limits and write an operator guide. Test recovery and rollback. Acceptance criteria: Contract and failure-path tests pass. Data and authorization rules still hold during retries and partial failures. Check performance limits, monitoring, recovery, and rollback. Evidence and limits (evidence boundary): Nessun singolo standard ufficiale controlla l'intero termine. Il suo significato può cambiare tra team, piattaforme o framework. Unknowns to confirm: Where the code runs, data stores, traffic shape, consistency needs, and the security boundary. Also confirm the compatibility period, service goals, and rollback limits.
Controlla questa richiesta
Review how Lavoro in background (Background Job) is used now. Definition: Un lavoro in background è un'attività che il server esegue separatamente dalla pagina o dalla risposta API che può avviarlo. La risposta può completarsi prima che il lavoro sia finito. Release checks: Check contracts and invariants, authorization, and input limits. Test retries, one-time effects, timeouts, and partial failures. Verify data integrity, compatibility, monitoring, recovery, and rollback. Before changing code, list the evidence, gaps, severity, and the smallest safe fix.