doctor

package
v0.1.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package doctor 提供只读运行环境诊断服务。

所有检查只读取受管根目录;doctor 不获取 mutation/backend 锁、不创建、 不修改也不删除任何持久化状态。网络、uv 版本与磁盘探测通过 Probes 注入, 单元测试不触碰真实公网或用户机器工具。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check struct {
	ID      string
	Name    string
	Status  Status
	Message string
	Details map[string]any
}

Check 描述一次检查的名称、稳定结果与补充事实。

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error 描述 doctor 服务失败,供 cli 会话框架映射协议四元组。 它实现 cli 侧消费方定义的 operationError 窄接口,是 doctor 与 cli 之间 唯一的失败契约:生产路径用于协议事件发射失败(见 newOutputError), cli 的注入式测试替身也用它构造服务级失败。

func NewError

func NewError(
	code protocol.Code,
	stage protocol.Stage,
	message string,
	details map[string]any,
	cause error,
) *Error

NewError 构造 doctor 服务错误。

func (*Error) Code

func (e *Error) Code() protocol.Code

func (*Error) Details

func (e *Error) Details() map[string]any

func (*Error) Error

func (e *Error) Error() string

func (*Error) Message

func (e *Error) Message() string

func (*Error) Stage

func (e *Error) Stage() protocol.Stage

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Probes

type Probes struct {
	UVVersion           func(ctx context.Context, exePath string) (string, error)
	UVVersionWithLayout func(ctx context.Context, layout *config.Layout, exePath string) (string, error)
	DiskFree            func(ctx context.Context, path string) (uint64, error)
	FileSystem          func(ctx context.Context, path string) (string, error)
}

Probes 是 doctor 需要注入替身的只读探测点。

func ProductionProbes

func ProductionProbes() Probes

ProductionProbes 返回生产环境探测实现。

func ProductionProbesForLayout

func ProductionProbesForLayout(layout *config.Layout) Probes

ProductionProbesForLayout 返回使用真实 managed runtime 目录的生产探针。

type Report

type Report struct {
	Checks  []Check
	Summary Summary
}

Report 是 doctor 的结构化输出。

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service 组合布局与探针执行全部检查。

func New

func New(layout *config.Layout, probes Probes) (*Service, error)

New 创建只读诊断服务,layout 与两个探针都不可为空。

func (*Service) Run

func (s *Service) Run(ctx context.Context, emitter *protocol.Emitter) (Report, error)

Run 执行全部检查并逐项发射 progress 事件。 单项异常只影响该项状态,不提前终止;Run 正常路径不失败。

type Status

type Status string

Status 是单个检查项的稳定结果。

const (
	StatusOK      Status = "ok"
	StatusMissing Status = "missing"
	StatusError   Status = "error"
)

func (Status) String

func (s Status) String() string

String 返回 Status 的稳定字面量。

func (Status) Valid

func (s Status) Valid() bool

Valid 报告 Status 是否属于稳定全集。

type Summary

type Summary struct {
	Total   int
	OK      int
	Missing int
	Error   int
}

Summary 汇总一次诊断的计数。

func (Summary) Worst

func (s Summary) Worst() Status

Worst 返回本次诊断的最差检查项状态,用于汇总输出。 空报告视为 ok:没有检查项就没有坏消息。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL