stable · guide · 0.1.0
讀取、cache 與評估
讀取最新 version
Project Credential 需要 configuration:read scope。呼叫
GET /feature-configuration:
: "${MINICENTER_PROJECT_CREDENTIAL:?set the sandbox Project Credential}"
: "${MINICENTER_URL:=https://sandbox.minicenter.otus.tw}"
curl --fail-with-body --include \
--header "Authorization: Bearer ${MINICENTER_PROJECT_CREDENTIAL}" \
"${MINICENTER_URL}/api/v1/feature-configuration"
成功回應包含遞增 version、published_at、max_age_seconds、flags、configuration 與 secret_references,以及 Cache-Control: private, max-age=300、ETag、Vary: Authorization。
Project Client 尚未發布第一個 version 時回 404 Not Found。這是正常 bootstrap 狀態:Project Backend 使用程式碼內建的 safe defaults,不建立空的遠端 snapshot;Platform Operator 發布第一版後再取得 authoritative snapshot。
Cache 到期後以先前 ETag 傳送 If-None-Match。304 Not Modified 表示可更新 cache age 而不替換 snapshot;200 時只接受結構完整且 version 不小於現有有效 version 的 snapshot。
Outage 與 safe default
在 max_age_seconds 內可使用最後一份驗證成功的 snapshot。超過期限或 snapshot 缺失/損壞時,每個 flag 必須回到程式碼內建的 safe_default。不要讓遠端 snapshot 覆寫本地安全預設,也不要把 flag 當作權限檢查。