Documentation
¶
Overview ¶
Package gitrepo 管理带版本的受管后端仓库。
Index ¶
- Variables
- type CheckResult
- type Error
- type FetchRequest
- type FetchResult
- type Fetcher
- type LoggerFactory
- type MutationCoordinator
- type MutationLease
- type OperationLogger
- type PlanBuilder
- type ProgressEmitter
- type Recovery
- type RecoveryRequest
- type RecoveryResult
- type RemoteCheckResult
- type Revision
- type Service
- func (s *Service) Check(ctx context.Context) (CheckResult, error)
- func (s *Service) CheckRemote(ctx context.Context, policy mirror.Policy) (RemoteCheckResult, error)
- func (s *Service) Stage(ctx context.Context, request StageRequest) (result StageResult, returnErr error)
- func (s *Service) Sync(ctx context.Context, request SyncRequest) (result SyncResult, returnErr error)
- type ServiceOption
- type StageReporter
- type StageRequest
- type StageResult
- type SwapRequest
- type SwapResult
- type Swapper
- type SyncRequest
- type SyncResult
- type Target
- type VerificationRequest
- type Verifier
- type WorkspaceEmitter
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidFetcher = errors.New("git fetcher is invalid")
)
var ErrInvalidVersion = errors.New("version is invalid")
ErrInvalidVersion 表示产品版本不能安全映射为发布分支。
Functions ¶
This section is empty.
Types ¶
type CheckResult ¶
type CheckResult struct {
Healthy bool
Version string
Branch string
Commit string
Source string
Reason string
// contains filtered or unexported fields
}
CheckResult 是 workspace check 的稳定业务结果,不携带路径或 remote URL。
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error 描述工作区 Git 服务失败,供 CLI 映射协议四元组。
type FetchRequest ¶
type FetchRequest struct {
Plan mirror.Plan
Target Target
OperationID string
StageReporter StageReporter
}
FetchRequest 固定一次 Git 获取操作的目标、镜像计划和目录所有者。
type FetchResult ¶
type FetchResult struct {
RepositoryPath string
Revision Revision
DirectoryIdentity *filesystem.DirectoryIdentity
CommitMessage string
}
FetchResult 保存已验证临时仓库的安全路径和最终来源事实。
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
Fetcher 获取并验证一个固定目标分支,不负责激活仓库目录。
func NewFetcher ¶
func NewFetcher( layout *config.Layout, rotator *mirror.Rotator, remover *filesystem.Operator, verifier *Verifier, emitter ProgressEmitter, ) (*Fetcher, error)
NewFetcher 创建使用 go-git 传输和真实静态校验器的仓库获取器。
func (*Fetcher) Fetch ¶
func (f *Fetcher) Fetch(ctx context.Context, request FetchRequest) (FetchResult, error)
Fetch 按镜像计划获取同一 Target,并只返回通过静态校验的临时仓库。
type LoggerFactory ¶
type LoggerFactory func(ctx context.Context, command, operationID string) (OperationLogger, error)
LoggerFactory 延迟创建本次同步的 Runtime logger,确保 check 保持只读。
type MutationCoordinator ¶
type MutationCoordinator interface {
AcquireMutation(context.Context) (MutationLease, error)
Close() error
}
MutationCoordinator 提供一次受管 mutation 操作的锁生命周期。
func NewMutationCoordinator ¶
func NewMutationCoordinator(ctx context.Context, layout *config.Layout) (MutationCoordinator, error)
NewMutationCoordinator 创建可由上层编排持有的生产 mutation 锁协调器。
type MutationLease ¶
type MutationLease interface {
Close() error
}
MutationLease 是跨 workspace 与环境编排共享的 mutation 锁租约。
type OperationLogger ¶
OperationLogger 是同步操作所需的日志生命周期能力。
type PlanBuilder ¶ added in v0.1.7
PlanBuilder 按策略给出 Git 源的尝试顺序;增补 2 C16 起由测速排序实现注入,默认按目录顺序。
type ProgressEmitter ¶
type ProgressEmitter interface {
EmitProgress(event protocol.ProgressEvent) error
}
ProgressEmitter 是 Fetcher 消费的单方法协议进度出口。
type Recovery ¶
type Recovery struct {
// contains filtered or unexported fields
}
Recovery 按 update transaction 和三个精确目录身份恢复中断现场。
func NewRecovery ¶
func NewRecovery( layout *config.Layout, operator *filesystem.Operator, store *state.Store, ) (*Recovery, error)
NewRecovery 创建使用真实 filesystem、state Store 和 go-git reader 的恢复服务。
func (*Recovery) Recover ¶
func (r *Recovery) Recover( ctx context.Context, request RecoveryRequest, ) (RecoveryResult, error)
Recover 在任何目录副作用前完成全部必要身份分类。
type RecoveryRequest ¶
type RecoveryRequest struct {
DiscardStaged bool
LogPath string
StageReporter StageReporter
}
RecoveryRequest 提供补写 repository_changed 所需的当前 Runtime 日志路径。
type RecoveryResult ¶
type RecoveryResult struct {
Recovered bool
MutationApplied bool
EnvironmentWritten bool
TransactionRemoved bool
Version string
Branch string
Commit string
SourceKey string
}
RecoveryResult 保存恢复动作和已证明 active revision 的事实。
type RemoteCheckResult ¶ added in v0.1.2
type RemoteCheckResult struct {
Current CheckResult
RemoteCommit string
UpdateAvailable bool
}
RemoteCheckResult 是 workspace check --remote 的只读结果。
type Revision ¶
type Revision struct {
// contains filtered or unexported fields
}
Revision 保存经静态校验的仓库版本、分支、Commit 和来源。
func NewRevision ¶
NewRevision 构造一个经版本、分支、Commit 和来源校验的稳定 revision。 应用层测试替身和跨包编排只能通过该构造器取得 Revision,不能伪造内部字段。
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service 是 workspace check/sync 的应用服务;check 不创建任何运行时能力。
func NewService ¶
func NewService(layout *config.Layout, options ...ServiceOption) (*Service, error)
NewService 创建使用生产 go-git、filesystem、state 和 Windows Mutex 的服务。
func (*Service) Check ¶
func (s *Service) Check(ctx context.Context) (CheckResult, error)
Check 只读取 app-root/repo 及其 Git 对象,不创建目录、状态、锁、日志或网络请求。
func (*Service) CheckRemote ¶ added in v0.1.2
CheckRemote 只读取当前仓库和远端分支引用,不创建受管状态或下载工作区。
func (*Service) Stage ¶ added in v0.1.2
func (s *Service) Stage(ctx context.Context, request StageRequest) (result StageResult, returnErr error)
Stage 只写独立暂存仓库与 update 事务,允许当前后端保持运行。
func (*Service) Sync ¶
func (s *Service) Sync(ctx context.Context, request SyncRequest) (result SyncResult, returnErr error)
Sync 按冻结顺序执行锁协调、恢复、Git 获取、整体替换和环境失效持久化。
type ServiceOption ¶ added in v0.1.7
type ServiceOption func(*serviceOptions) error
ServiceOption 配置 NewService 的可注入依赖。
func WithPlanBuilder ¶ added in v0.1.7
func WithPlanBuilder(build PlanBuilder) ServiceOption
WithPlanBuilder 注入 Git 源尝试顺序的构造函数(例如 mirror.Ranker 的实测排序)。
type StageReporter ¶
StageReporter 让 CLI 的 stdin 控制 warning 使用当前真实 stage。
type StageRequest ¶ added in v0.1.2
type StageRequest = SyncRequest
StageRequest 使用同一套操作身份与日志依赖;暂存自己获取锁,不接受外部 mutation 租约。
type StageResult ¶ added in v0.1.2
StageResult 只有已完整校验且不同于当前仓库时才报告 Staged。
type SwapRequest ¶
type SwapRequest struct {
Transaction state.TransactionState
Revision Revision
ActiveIdentity *filesystem.DirectoryIdentity
UpdateIdentity *filesystem.DirectoryIdentity
StageReporter StageReporter
// CommitEnvironment 在新仓库激活且 cleanup transaction 持久化后调用。
// 回调必须先持久化 repository_changed,Swapper 才会删除 previous。
CommitEnvironment func(context.Context, Revision) error
}
SwapRequest 把已验证 Revision 绑定到当前 update transaction。
type SwapResult ¶
type SwapResult struct {
Revision Revision
MutationApplied bool
RepositoryActivated bool
CleanupCompleted bool
}
SwapResult 保存目录副作用、激活提交点和旧目录收口事实。
type Swapper ¶
type Swapper struct {
// contains filtered or unexported fields
}
Swapper 通过封闭 filesystem 能力整体替换受管仓库。
func NewSwapper ¶
func NewSwapper( layout *config.Layout, operator *filesystem.Operator, transactions *state.Store, ) (*Swapper, error)
NewSwapper 创建使用真实受控文件系统和状态 Store 的仓库替换器。
func (*Swapper) Swap ¶
func (s *Swapper) Swap(ctx context.Context, request SwapRequest) (SwapResult, error)
Swap 在 update transaction 保护下执行两次 rename 和旧目录收口。
type SyncRequest ¶
type SyncRequest struct {
UseCurrent bool
Target Target
Policy mirror.Policy
OperationID string
PID uint32
MutationLease MutationLease
Emitter WorkspaceEmitter
LoggerFactory LoggerFactory
Auditor filesystem.Auditor
Clock func() time.Time
StageReporter StageReporter
ControlCommandID func() string
}
SyncRequest 描述一次 workspace sync 的外部依赖和稳定身份。
type SyncResult ¶
type SyncResult struct {
Revision Revision
Changed bool
Status protocol.StateStatus
ControlCommandID string
}
SyncResult 是 workspace sync 的稳定业务结果。
type Target ¶
type Target struct {
// contains filtered or unexported fields
}
Target 保存经校验的产品版本及其唯一发布分支。
type VerificationRequest ¶
type VerificationRequest struct {
RepositoryPath string
Target Target
Source mirror.Source
AllowedSources []mirror.Source
}
VerificationRequest 固定静态校验所需的路径、目标和本次网络源集合。
type Verifier ¶
type Verifier struct {
// contains filtered or unexported fields
}
Verifier 校验克隆仓库的来源、分支、对象边界和版本文档。
type WorkspaceEmitter ¶
type WorkspaceEmitter interface {
EmitProgress(protocol.ProgressEvent) error
EmitState(protocol.StateEvent) error
}
WorkspaceEmitter 是同步服务使用的最小协议事件出口。