updater

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PerformUpdate

func PerformUpdate(ctx context.Context, info *UpdateInfo) error

PerformUpdate 执行更新

func Rollback added in v0.6.0

func Rollback() error

Rollback 回滚到上一次更新保留的备份版本。

Types

type Assets

type Assets struct {
	Name               string `json:"name"`
	BrowserDownloadURL string `json:"browser_download_url"`
	Size               int64  `json:"size"`
}

GitHubRelease GitHub Release API 响应结构

type GitHubRelease

type GitHubRelease struct {
	TagName string    `json:"tag_name"`
	Name    string    `json:"name"`
	Body    string    `json:"body"`
	Assets  []*Assets `json:"assets"`
}

GitHubRelease GitHub Release API 响应结构

type Service added in v0.7.0

type Service struct {
	// Runtime 是更新镜像和代理配置的只读快照。
	Runtime *config.Runtime
	// HTTPClient 是检查 Release 时使用的客户端。
	HTTPClient *http.Client
	// ReleaseURL 是 Release API 地址,空值使用 GitHub 默认地址。
	ReleaseURL string
	// CurrentVersion 覆盖默认编译版本,便于离线测试。
	CurrentVersion string
}

Service 持有一次更新操作所需的显式配置和 HTTP 依赖。

func NewService added in v0.7.0

func NewService(runtime *config.Runtime, httpClient *http.Client) *Service

NewService 创建显式依赖的更新服务。

func (*Service) CheckUpdate added in v0.7.0

func (s *Service) CheckUpdate(ctx context.Context) (*UpdateInfo, error)

CheckUpdate 使用 Service 的 HTTP 客户端检查最新 Release。

func (*Service) PerformUpdate added in v0.7.0

func (s *Service) PerformUpdate(ctx context.Context, info *UpdateInfo) error

PerformUpdate 执行更新流程并复用现有原子替换实现。

func (*Service) Rollback added in v0.7.0

func (s *Service) Rollback() error

Rollback 回滚上一次更新保留的备份二进制。

type UpdateInfo

type UpdateInfo struct {
	CurrentVersion string
	LatestVersion  string
	HasUpdate      bool
	DownloadURL    string
	ChecksumURL    string
	ReleaseNotes   string
	BinaryName     string
}

UpdateInfo 更新信息

func CheckUpdate

func CheckUpdate(ctx context.Context) (*UpdateInfo, error)

CheckUpdate 检查是否有新版本

Jump to

Keyboard shortcuts

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