Help us shape the future of Go! Take the 2026 Go Developer Survey

executor

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RemoteOrigin = "origin"
	RemoteTarget = "target"
)

Git remote name constants

View Source
const (
	RepoDir = "repo"
)

Work directory subdirectory name

Variables

This section is empty.

Functions

func ClassifyError

func ClassifyError(err error) string

ClassifyError categorizes an error into one of the predefined error types. 优先识别 SDK 结构化错误(provider HTTP 层),再回落到 git 操作关键词匹配。

func RestoreBundle added in v0.5.1

func RestoreBundle(ctx context.Context, bundlePath, destDir string) error

RestoreBundle 从 bundle 恢复到目标目录。 destDir 不存在时创建;已存在且非空则拒绝(防误覆盖)。

func UploadBundle added in v0.5.0

func UploadBundle(ctx context.Context, cfg *S3Config, localPath, objectKey string) error

UploadBundle 把 bundle 文件推到 S3(冷备异地)。 只支持 path-style + SigV4,覆盖 MinIO/阿里 OSS/AWS。

Types

type BundleInfo added in v0.5.1

type BundleInfo struct {
	Name     string    `json:"name"`
	Path     string    `json:"path"`
	Size     int64     `json:"size"`
	ModTime  time.Time `json:"mod_time"`
	TaskKey  string    `json:"task_key,omitempty"`
	Valid    bool      `json:"valid,omitempty"`
	RefSpecs []string  `json:"ref_specs,omitempty"`
}

BundleInfo bundle 文件信息。

func ListBundles added in v0.5.1

func ListBundles(backupDir, taskKey string) ([]BundleInfo, error)

ListBundles 列出 backupDir 下的 bundle(按任务过滤,空=全部)。

func VerifyBundle added in v0.5.1

func VerifyBundle(ctx context.Context, bundlePath string) (*BundleInfo, error)

VerifyBundle 校验 bundle 完整性(git bundle verify)。 返回列出的引用与是否有效。

type Executor

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

func NewExecutor

func NewExecutor(svc Service) (*Executor, error)

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, task *model.SyncTask, trigger string, webhookEventID *uint) (*model.SyncRun, error)

type PlatformProvider

type PlatformProvider interface {
	GetPlatformByID(ctx context.Context, id uint) (*model.Platform, error)
}

PlatformProvider provides platform lookup by ID.

type RepoProvider

type RepoProvider interface {
	GetRepoByKey(key string) (*model.Repo, error)
}

RepoProvider provides repository lookup by key.

type RunManager

type RunManager interface {
	CreateRun(task *model.SyncTask, trigger string, webhookEventID *uint) (*model.SyncRun, error)
	CreateRunStep(step *model.SyncRunStep) error
	UpdateRunStep(step *model.SyncRunStep) error
	CompleteRun(run *model.SyncRun) error
	UpdateTaskLastRun(task *model.SyncTask, run *model.SyncRun) error
	CompleteRunWithTaskUpdate(run *model.SyncRun, task *model.SyncTask) error
}

RunManager handles sync run lifecycle operations.

type S3Config added in v0.5.0

type S3Config struct {
	Endpoint  string `yaml:"endpoint"` // https://s3.amazonaws.com 或 https://oss-cn-hangzhou.aliyuncs.com
	Region    string `yaml:"region"`   // us-east-1 等
	Bucket    string `yaml:"bucket"`
	Prefix    string `yaml:"prefix"` // 对象 key 前缀
	AccessKey string `yaml:"access_key"`
	SecretKey string `yaml:"secret_key"`
	// PathStyle true=MinIO/部分兼容端点
	PathStyle bool `yaml:"path_style"`
}

S3Config S3 兼容对象存储(阿里云 OSS/MinIO/AWS)。

type Service

type Service interface {
	GetTempDir(taskKey string) string
	GetConfig() *model.Config
	RunManager
	RepoProvider
	PlatformProvider
}

Service is the interface the executor depends on. It exposes only the operations the executor needs — no DAO leakage.

Jump to

Keyboard shortcuts

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