Documentation
¶
Index ¶
- Constants
- Variables
- func ValidateCheckInterval(value time.Duration) error
- type Activation
- type Channel
- type EndpointRestartGate
- type FileStore
- func (store *FileStore) Activate(stagedDirectory string) (Activation, error)
- func (store *FileStore) BinaryPath() string
- func (store *FileStore) ClearFailClosed() error
- func (store *FileStore) CreateDownloadStage() (string, string, error)
- func (store *FileStore) Current() (Manifest, error)
- func (store *FileStore) FailClosed() (bool, error)
- func (store *FileStore) FinalizeDownloadedStage(directory string, identity ReleaseIdentity, ...) (Manifest, error)
- func (store *FileStore) LatestBackup() (string, Manifest, error)
- func (store *FileStore) ManifestPath() string
- func (store *FileStore) MarkFailClosed() error
- func (store *FileStore) Prepare() error
- func (store *FileStore) Recover() error
- func (store *FileStore) RemoveStage(directory string)
- func (store *FileStore) Restore(activation Activation) error
- func (store *FileStore) RevertActivation(activation Activation) error
- func (store *FileStore) SetStagedVersion(directory string, manifest Manifest, reportedVersion string) (Manifest, error)
- func (store *FileStore) StageAdopted(sourcePath, reportedVersion string, now time.Time) (string, Manifest, error)
- func (store *FileStore) StageBackup(backupPath string) (string, error)
- func (store *FileStore) StageBootstrap(binaryPath, manifestPath string) (string, Manifest, error)
- type GitHubClient
- type GitHubClientOptions
- type Manager
- func (manager *Manager) AdoptExternal(ctx context.Context, sourcePath string) (Manifest, bool, error)
- func (manager *Manager) BinaryPath() string
- func (manager *Manager) Bootstrap(ctx context.Context, binaryPath, manifestPath string) (Manifest, bool, error)
- func (manager *Manager) Check(ctx context.Context, actorAdminID string) (ReleaseIdentity, error)
- func (manager *Manager) Due(ctx context.Context, now time.Time) (bool, error)
- func (manager *Manager) FailClosed() bool
- func (manager *Manager) Recover(ctx context.Context) error
- func (manager *Manager) Rollback(ctx context.Context, actorAdminID string) (result Manifest, resultErr error)
- func (manager *Manager) SafetyBlocked(ctx context.Context) (bool, error)
- func (manager *Manager) ScheduleStartupCheck(ctx context.Context) error
- func (manager *Manager) SetWake(wake func())
- func (manager *Manager) Settings(ctx context.Context) (Settings, error)
- func (manager *Manager) Status(ctx context.Context) (Status, error)
- func (manager *Manager) Update(ctx context.Context, actorAdminID string) (Manifest, bool, error)
- func (manager *Manager) UpdateSettings(ctx context.Context, actorAdminID string, settings Settings) error
- type ManagerOptions
- type Manifest
- type ReleaseIdentity
- type Repository
- type Settings
- type State
- type Status
- type Upstream
Constants ¶
const ( ChannelRelease Channel = "release" ChannelAlpha Channel = "alpha" DefaultCheckInterval = 24 * time.Hour ManagedBinaryPath = "/var/lib/m-ui/core/current/mihomo" )
const ( UpstreamRepository = "MetaCubeX/mihomo" AlphaTag = "Prerelease-Alpha" )
Variables ¶
var ( ErrDegraded = errors.New("core updates are disabled while the system is degraded") ErrExternal = errors.New("external Mihomo core is not managed by m-ui") ErrNoBackup = errors.New("no previous managed Mihomo core backup is available") ErrMihomoRestartRequired = errors.New("mihomo restart is required before core mutation") )
Functions ¶
func ValidateCheckInterval ¶
Types ¶
type Activation ¶
type Activation struct {
// contains filtered or unexported fields
}
type EndpointRestartGate ¶ added in v0.1.1
EndpointRestartGate is implemented by the durable settings store. Core activation restarts Mihomo, so it must not be allowed to apply a different binary while a previously saved endpoint candidate still awaits its explicit restart boundary.
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
func NewFileStore ¶
func (*FileStore) Activate ¶
func (store *FileStore) Activate(stagedDirectory string) (Activation, error)
func (*FileStore) BinaryPath ¶
func (*FileStore) ClearFailClosed ¶
func (*FileStore) CreateDownloadStage ¶
func (*FileStore) FailClosed ¶
FailClosed reports the durable safety sentinel used when a core rollback cannot be completed. The sentinel is intentionally separate from the SQLite bit so a database outage cannot make an unsafe core look healthy.
func (*FileStore) FinalizeDownloadedStage ¶
func (*FileStore) ManifestPath ¶
func (*FileStore) MarkFailClosed ¶
func (*FileStore) RemoveStage ¶
func (*FileStore) Restore ¶
func (store *FileStore) Restore(activation Activation) error
func (*FileStore) RevertActivation ¶
func (store *FileStore) RevertActivation(activation Activation) error
func (*FileStore) SetStagedVersion ¶
func (*FileStore) StageAdopted ¶
func (*FileStore) StageBackup ¶
type GitHubClient ¶
type GitHubClient struct {
// contains filtered or unexported fields
}
func NewGitHubClient ¶
func NewGitHubClient(options GitHubClientOptions) (*GitHubClient, error)
func (*GitHubClient) Download ¶
func (client *GitHubClient) Download( ctx context.Context, identity ReleaseIdentity, destination io.Writer, ) (string, int64, error)
func (*GitHubClient) Resolve ¶
func (client *GitHubClient) Resolve( ctx context.Context, channel Channel, architecture string, ) (ReleaseIdentity, error)
type GitHubClientOptions ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager(options ManagerOptions) (*Manager, error)
func (*Manager) AdoptExternal ¶
func (*Manager) BinaryPath ¶
func (*Manager) FailClosed ¶
func (*Manager) SafetyBlocked ¶
SafetyBlocked exposes the same durable and in-memory fail-closed decision used by every core operation. Configuration publication and background schedulers use this gate as well, so a rollback failure cannot leave another mutating path active when persisting degraded state also failed.
func (*Manager) ScheduleStartupCheck ¶ added in v0.2.0
ScheduleStartupCheck makes a persisted automatic-update preference take effect on every m-ui start. This is intentionally independent of the m-ui binary version: upgrades, container recreation, and ordinary service restarts all converge to the newest build in the user's selected channel.
func (*Manager) SetWake ¶
func (manager *Manager) SetWake(wake func())
SetWake installs the scheduler wake-up hook after both components have been constructed. It is deliberately optional so short-lived CLI control planes do not need a scheduler.
type ManagerOptions ¶
type ManagerOptions struct {
Repository Repository
Upstream Upstream
Files *FileStore
Process mihomo.CoreProcess
Controller mihomo.CoreController
Coordinator *operation.Coordinator
EndpointGate EndpointRestartGate
ConfigPath string
Architecture string
Clock func() time.Time
HealthCheck func(context.Context) error
HealthTimeout time.Duration
HealthInterval time.Duration
Logger *slog.Logger
NewCLI func(string) (mihomo.CoreCLI, error)
}
type Manifest ¶
type Manifest struct {
SchemaVersion int `json:"schema_version"`
Source string `json:"source"`
VerifiedSource bool `json:"verified_source"`
Identity ReleaseIdentity `json:"identity"`
CompressedSHA256 string `json:"compressed_sha256"`
BinarySHA256 string `json:"binary_sha256"`
BinarySize int64 `json:"binary_size"`
BinaryReportedVersion string `json:"binary_reported_version"`
InstalledAt time.Time `json:"installed_at"`
}
type ReleaseIdentity ¶
type ReleaseIdentity struct {
Channel Channel `json:"channel"`
Repository string `json:"repository"`
ReleaseID int64 `json:"release_id"`
TagName string `json:"tag_name"`
Prerelease bool `json:"prerelease"`
PublishedAt time.Time `json:"published_at"`
TargetCommitish string `json:"target_commitish,omitempty"`
AssetID int64 `json:"asset_id"`
AssetName string `json:"asset_name"`
AssetSize int64 `json:"asset_size"`
AssetDigestSHA256 string `json:"asset_digest_sha256"`
BrowserDownloadURL string `json:"-"`
BinaryReportedVersion string `json:"binary_reported_version,omitempty"`
}
func (ReleaseIdentity) SameRelease ¶
func (identity ReleaseIdentity) SameRelease(other ReleaseIdentity) bool
func (ReleaseIdentity) Validate ¶
func (identity ReleaseIdentity) Validate() error
type Repository ¶
type Repository interface {
CoreSettings(context.Context) (Settings, error)
UpdateCoreSettings(context.Context, Settings, time.Time) error
CoreState(context.Context) (State, error)
SaveCoreState(context.Context, State) error
CoreSystemDegraded(context.Context) (bool, error)
MarkDegraded(context.Context, string, string, time.Time) error
RecordCoreAudit(
context.Context,
string,
string,
string,
string,
time.Time,
) error
}
type Settings ¶
type Settings struct {
Channel Channel `json:"channel"`
AutoUpdate bool `json:"auto_update"`
CheckInterval time.Duration `json:"check_interval"`
Managed bool `json:"managed"`
ExternalPath string `json:"external_path,omitempty"`
}
func (Settings) MarshalJSON ¶
type State ¶
type State struct {
Current *Manifest `json:"current,omitempty"`
Available *ReleaseIdentity `json:"available,omitempty"`
LastCheckAt *time.Time `json:"last_check_at,omitempty"`
LastCheckResult string `json:"last_check_result,omitempty"`
LastUpdateAt *time.Time `json:"last_update_at,omitempty"`
LastUpdateResult string `json:"last_update_result,omitempty"`
LastErrorRedacted string `json:"last_error_redacted,omitempty"`
NextCheckAt *time.Time `json:"next_check_at,omitempty"`
UpdateInProgress bool `json:"update_in_progress"`
}
type Status ¶
type Status struct {
Settings Settings `json:"settings"`
State State `json:"state"`
ActualVersion string `json:"actual_version"`
ControllerVersion string `json:"controller_version,omitempty"`
ProcessActive bool `json:"process_active"`
ControllerReachable bool `json:"controller_reachable"`
CurrentBinarySHA256 string `json:"current_binary_sha256,omitempty"`
Managed bool `json:"managed"`
UpdateAvailable bool `json:"update_available"`
RuntimeVersionMatches bool `json:"runtime_version_matches"`
}