Реализовать уровень 4 и упорядочить структуру backend
Добавить crop и WebP, изолированную обработку с таймаутом, lease token, backoff с jitter, реестр failed, безопасный replay и очистку staging. Добавить проверки crash-окон и восстановления. Разделить запуск API, CLI-команды, фоновые процессы и инфраструктуру по пакетам.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package faults
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Only an operator-mounted directory enables faults; clients cannot set them.
|
||||
// Rename makes each injected crash one-shot across automatic container restarts.
|
||||
func Take(point, id string) bool {
|
||||
directory := os.Getenv("PIPELINE_FAULT_DIR")
|
||||
if directory == "" {
|
||||
return false
|
||||
}
|
||||
if _, err := uuid.Parse(id); err != nil {
|
||||
return false
|
||||
}
|
||||
name := filepath.Join(directory, point+"."+id)
|
||||
return os.Rename(name, name+".hit") == nil
|
||||
}
|
||||
func Crash(point, id string) {
|
||||
if Take(point, id) {
|
||||
log.Printf("injected pipeline crash: %s, attachment %s", point, id)
|
||||
os.Exit(86)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user