Files
knowledge-governance/internal/governance/service_target.go
T
姚章浩 1db21fb899 feat(settings): 服务配置四项化并保存时真校验
- 生产/测试 WeKnora 地址、租户 ID、知识库 ID 由静态 env 收敛为版本化 UI 设置,保留修订号与操作人审计
- 新增 serviceverify:保存前真调目标端点探测,端点无效才拒绝;网络抖动或无凭据仅告警
- 迁移 000042(生产 WeKnora 端点)/000043(服务目标);补齐设置候选与校验契约用例
2026-09-30 10:54:07 +08:00

71 lines
3.1 KiB
Go

package governance
import "time"
// ServiceTarget is the operator-level 「服务配置」 target: the console endpoints
// plus the production knowledge base and its tenant. It exists so the save path
// can ask the real endpoint whether the typed values exist, instead of storing
// two numbers nobody ever consumed.
type ServiceTarget struct {
TestBaseURL string
ProductionBaseURL string
ProductionTenantID string
ProductionKnowledgeBaseID string
}
// Statuses of a whole service-target verification.
const (
// ServiceTargetVerified: the endpoint answered and every configured value is
// really there.
ServiceTargetVerified = "verified"
// ServiceTargetMissing: the endpoint answered and the knowledge base (or a
// knowledge base of that tenant) is NOT there. Blocking.
ServiceTargetMissing = "missing"
// ServiceTargetTenantMismatch: the knowledge base exists but belongs to a
// different tenant than the configured production ID. Blocking.
ServiceTargetTenantMismatch = "tenant_mismatch"
// ServiceTargetUnauthorized: the endpoint answered 401/403 — a credential
// problem, not proof about the values. Advisory.
ServiceTargetUnauthorized = "unauthorized"
// ServiceTargetUnreachable: network, timeout or server error. Advisory.
ServiceTargetUnreachable = "unreachable"
// ServiceTargetCannotVerify: nothing to ask with (no endpoint, no key file,
// unusable address). Advisory.
ServiceTargetCannotVerify = "cannot_verify"
// ServiceTargetNotConfigured: both IDs are empty, so there is nothing to
// verify and nothing was.
ServiceTargetNotConfigured = "not_configured"
)
// Statuses of a single endpoint probe.
const (
ServiceEndpointReachable = "reachable"
ServiceEndpointUnauthorized = "unauthorized"
ServiceEndpointUnavailable = "unavailable"
ServiceEndpointNotConfigured = "not_configured"
)
// ServiceEndpointStatus is one endpoint's live reachability, as measured during
// the save. Both endpoints are probed on every save so the console never claims
// 「已配置」without a read behind it.
type ServiceEndpointStatus struct {
Status string `json:"status"`
Message string `json:"message"`
}
// ServiceTargetVerification is the honest outcome of the real read behind a
// 「服务配置」save. Blocked is true only for a definitive negative answer — the
// endpoint answered and the knowledge base / tenant is provably absent. A flaky,
// unauthorized or unconfigured endpoint only warns: an outage must never stop an
// operator from fixing the configuration.
type ServiceTargetVerification struct {
Status string `json:"status"`
Message string `json:"message"`
Blocked bool `json:"blocked"`
KnowledgeBaseName string `json:"knowledge_base_name,omitempty"`
ObservedTenantID string `json:"observed_tenant_id,omitempty"`
TestEndpoint ServiceEndpointStatus `json:"test_endpoint"`
ProductionEndpoint ServiceEndpointStatus `json:"production_endpoint"`
CheckedAt time.Time `json:"checked_at"`
}