Documentation
¶
Index ¶
- Variables
- type Config
- type CreateMirrorChannelInput
- type ExecuteMirrorRunInput
- type MirrorService
- func (m *MirrorService) CreateMirrorChannel(ctx context.Context, in CreateMirrorChannelInput) (*model.MirrorChannel, error)
- func (m *MirrorService) DeleteMirrorChannel(confirm string, id uint) error
- func (m *MirrorService) DeleteMirrorTarget(targetID uint) error
- func (m *MirrorService) ExecuteMirrorRun(ctx context.Context, channelID uint, in ExecuteMirrorRunInput) (*model.MirrorRun, error)
- func (m *MirrorService) GetMirrorChannel(id uint) (*model.MirrorChannel, error)
- func (m *MirrorService) GetMirrorRun(id uint) (*model.MirrorRun, error)
- func (m *MirrorService) GetMirrorVersions(ctx context.Context, channelID uint) (*MirrorVersionsResult, error)
- func (m *MirrorService) ListMirrorChannels(page dao.Pagination) ([]*model.MirrorChannel, int64, error)
- func (m *MirrorService) ListMirrorRuns(channelID uint, page dao.Pagination) ([]*model.MirrorRun, int64, error)
- func (m *MirrorService) PreviewMirrorRun(ctx context.Context, channelID, targetID uint, tag string) (*mirror.TagReport, error)
- func (m *MirrorService) TestMirrorTarget(ctx context.Context, targetID uint) error
- func (m *MirrorService) UpdateMirrorTarget(ctx context.Context, targetID uint, in MirrorTargetInput) (*model.MirrorTarget, error)
- func (m *MirrorService) VerifyMirrorTargetVersion(ctx context.Context, channelID, targetID uint, tag string) (*model.MirrorRun, error)
- type MirrorTargetInput
- type MirrorVersion
- type MirrorVersionTarget
- type MirrorVersionsResult
- type OperationLogService
- func (s *OperationLogService) List(ctx context.Context, offset, limit int, filter *dao.OperationLogFilter) ([]*model.OperationLog, int64, error)
- func (s *OperationLogService) Record(ctx context.Context, entry *model.OperationLog) error
- func (s *OperationLogService) Stats(ctx context.Context) (today, week, total int64, err error)
- type PlatformService
- func (s *PlatformService) CountReposByPlatform(ctx context.Context, platformKey string) (int64, error)
- func (s *PlatformService) CreatePlatform(ctx context.Context, platform *model.Platform) error
- func (s *PlatformService) DeletePlatform(ctx context.Context, key string) error
- func (s *PlatformService) GetPlatform(ctx context.Context, key string) (*model.Platform, error)
- func (s *PlatformService) GetPlatformByID(ctx context.Context, id uint) (*model.Platform, error)
- func (s *PlatformService) ListPlatformRepos(ctx context.Context, key, page, perPage string) ([]*sdkprov.PlatformRepo, error)
- func (s *PlatformService) ListPlatforms(ctx context.Context) ([]*model.Platform, error)
- func (s *PlatformService) ListReposByPlatform(ctx context.Context, platformKey string) ([]*model.Repo, error)
- func (s *PlatformService) SetDefaultPlatform(ctx context.Context, key string) error
- func (s *PlatformService) SyncPlatformRepos(ctx context.Context, key string) (int, error)
- func (s *PlatformService) TestPlatformConnection(ctx context.Context, key string) (*sdkprov.TestConnectionResult, error)
- func (s *PlatformService) UpdatePlatform(ctx context.Context, platform *model.Platform) error
- func (s *PlatformService) UpdatePlatformStatus(ctx context.Context, key, status, testResult string) error
- type RepoService
- func (rs *RepoService) CountRepos() (int64, error)
- func (rs *RepoService) CreateRepo(ctx context.Context, req *model.CreateRepoRequest) (*model.Repo, error)
- func (rs *RepoService) DeleteRepo(ctx context.Context, key string) error
- func (rs *RepoService) GetRepo(ctx context.Context, key string) (*model.Repo, error)
- func (rs *RepoService) GetRepoByKey(key string) (*model.Repo, error)
- func (rs *RepoService) GetRepoWithProvider(repoKey string) (*model.Repo, sdkprov.Provider, error)
- func (rs *RepoService) ListBranches(ctx context.Context, repoKey string) ([]string, error)
- func (rs *RepoService) ListRepos(ctx context.Context, offset, limit int) ([]*model.Repo, int64, error)
- func (rs *RepoService) ListReposWithFilter(ctx context.Context, offset, limit int, filter *dao.RepoFilter) ([]*model.Repo, int64, error)
- func (rs *RepoService) SetWebhookSecret(repoKey, secret string) error
- func (rs *RepoService) TestConnection(ctx context.Context, repoKey string) (*model.TestConnectionResult, error)
- func (rs *RepoService) UpdateRepo(ctx context.Context, req *model.UpdateRepoRequest) (*model.Repo, error)
- type Service
- func (s *Service) CleanupOldData(ctx context.Context, maxAge time.Duration) (events, runs, steps int64, err error)
- func (s *Service) CompleteRun(run *model.SyncRun) error
- func (s *Service) CompleteRunWithTaskUpdate(run *model.SyncRun, task *model.SyncTask) error
- func (s *Service) CountRepos() (int64, error)
- func (s *Service) CountReposByPlatform(ctx context.Context, platformKey string) (int64, error)
- func (s *Service) CountTasksByStatus() (map[string]int64, error)
- func (s *Service) CreatePlatform(ctx context.Context, platform *model.Platform) error
- func (s *Service) CreateRepo(ctx context.Context, req *model.CreateRepoRequest) (*model.Repo, error)
- func (s *Service) CreateRule(ctx context.Context, req *model.CreateRuleRequest) (*model.WebhookRule, error)
- func (s *Service) CreateRun(task *model.SyncTask, trigger string, webhookEventID *uint) (*model.SyncRun, error)
- func (s *Service) CreateRunStep(step *model.SyncRunStep) error
- func (s *Service) CreateTask(ctx context.Context, req *model.CreateTaskRequest) (*model.SyncTask, error)
- func (s *Service) DeleteHistory(ctx context.Context, id uint) error
- func (s *Service) DeletePlatform(ctx context.Context, key string) error
- func (s *Service) DeletePlatformWebhook(ctx context.Context, repoKey string, webhookID int64) error
- func (s *Service) DeleteRepo(ctx context.Context, key string) error
- func (s *Service) DeleteRule(ctx context.Context, id uint) error
- func (s *Service) DeleteTask(ctx context.Context, key string) error
- func (s *Service) GetConfig() *model.Config
- func (s *Service) GetPlatform(ctx context.Context, key string) (*model.Platform, error)
- func (s *Service) GetPlatformByID(ctx context.Context, id uint) (*model.Platform, error)
- func (s *Service) GetRepo(ctx context.Context, key string) (*model.Repo, error)
- func (s *Service) GetRepoByKey(key string) (*model.Repo, error)
- func (s *Service) GetRule(ctx context.Context, id uint) (*model.WebhookRule, error)
- func (s *Service) GetTask(ctx context.Context, key string) (*model.SyncTask, error)
- func (s *Service) GetTempDir(taskKey string) string
- func (s *Service) HealthCheck() map[string]string
- func (s *Service) ListBranches(ctx context.Context, repoKey string) ([]string, error)
- func (s *Service) ListEvents(ctx context.Context, repoKey string, offset, limit int) ([]*model.WebhookEvent, int64, error)
- func (s *Service) ListHistory(ctx context.Context, taskKey string, offset, limit int) ([]*model.SyncRun, int64, error)
- func (s *Service) ListOperations(ctx context.Context, offset, limit int, filter *dao.OperationLogFilter) ([]*model.OperationLog, int64, error)
- func (s *Service) ListPlatformRepos(ctx context.Context, key, page, perPage string) ([]*sdkprov.PlatformRepo, error)
- func (s *Service) ListPlatformWebhooks(ctx context.Context, repoKey string) ([]*sdkprov.PlatformWebhook, error)
- func (s *Service) ListPlatforms(ctx context.Context) ([]*model.Platform, error)
- func (s *Service) ListRepos(ctx context.Context, offset, limit int) ([]*model.Repo, int64, error)
- func (s *Service) ListReposByPlatform(ctx context.Context, platformKey string) ([]*model.Repo, error)
- func (s *Service) ListReposWithFilter(ctx context.Context, offset, limit int, filter *dao.RepoFilter) ([]*model.Repo, int64, error)
- func (s *Service) ListRules(ctx context.Context, repoKey string) ([]*model.WebhookRule, error)
- func (s *Service) ListTasks(ctx context.Context, repoKey string, offset, limit int) ([]*model.SyncTask, int64, error)
- func (s *Service) Mirror() *MirrorService
- func (s *Service) OperationStats(ctx context.Context) (today, week, total int64, err error)
- func (s *Service) PreviewSync(ctx context.Context, req *model.PreviewSyncRequest) (*model.PreviewSyncResult, error)
- func (s *Service) ReceiveWebhook(ctx context.Context, repoKey string, payload *WebhookPayload) error
- func (s *Service) RecordOperation(ctx context.Context, entry *model.OperationLog) error
- func (s *Service) RegisterPlatformWebhook(ctx context.Context, repoKey, callbackURL, secret string, events []string) (*sdkprov.PlatformWebhook, error)
- func (s *Service) RetryEvent(ctx context.Context, eventID uint) error
- func (s *Service) RunTask(ctx context.Context, taskKey string) error
- func (s *Service) RunTaskAsync(taskKey, trigger string, webhookEventID *uint) error
- func (s *Service) RunTaskWithTrigger(ctx context.Context, taskKey, trigger string, webhookEventID *uint) error
- func (s *Service) SetDefaultPlatform(ctx context.Context, key string) error
- func (s *Service) Start() error
- func (s *Service) Stop()
- func (s *Service) SyncPlatformRepos(ctx context.Context, key string) (int, error)
- func (s *Service) TestConnection(ctx context.Context, repoKey string) (*model.TestConnectionResult, error)
- func (s *Service) TestPlatformConnection(ctx context.Context, key string) (*sdkprov.TestConnectionResult, error)
- func (s *Service) UpdatePlatform(ctx context.Context, platform *model.Platform) error
- func (s *Service) UpdatePlatformStatus(ctx context.Context, key, status, testResult string) error
- func (s *Service) UpdateRepo(ctx context.Context, req *model.UpdateRepoRequest) (*model.Repo, error)
- func (s *Service) UpdateRule(ctx context.Context, req *model.UpdateRuleRequest) (*model.WebhookRule, error)
- func (s *Service) UpdateRunStep(step *model.SyncRunStep) error
- func (s *Service) UpdateTask(ctx context.Context, req *model.UpdateTaskRequest) (*model.SyncTask, error)
- func (s *Service) UpdateTaskLastRun(task *model.SyncTask, run *model.SyncRun) error
- type TaskService
- func (ts *TaskService) CleanupOldRunSteps(ctx context.Context, maxAge time.Duration) (int64, error)
- func (ts *TaskService) CleanupOldRuns(ctx context.Context, maxAge time.Duration) (int64, error)
- func (ts *TaskService) CompleteRun(run *model.SyncRun) error
- func (ts *TaskService) CompleteRunWithTaskUpdate(run *model.SyncRun, task *model.SyncTask) error
- func (ts *TaskService) CountTasksByStatus() (map[string]int64, error)
- func (ts *TaskService) CreateRun(task *model.SyncTask, trigger string, webhookEventID *uint) (*model.SyncRun, error)
- func (ts *TaskService) CreateRunStep(step *model.SyncRunStep) error
- func (ts *TaskService) CreateTask(ctx context.Context, req *model.CreateTaskRequest) (*model.SyncTask, error)
- func (ts *TaskService) DeleteHistory(ctx context.Context, id uint) error
- func (ts *TaskService) DeleteTask(ctx context.Context, key string) error
- func (ts *TaskService) FindAllEnabledTasks() ([]*model.SyncTask, error)
- func (ts *TaskService) FindTaskByKey(key string) (*model.SyncTask, error)
- func (ts *TaskService) GetTask(ctx context.Context, key string) (*model.SyncTask, error)
- func (ts *TaskService) ListHistory(ctx context.Context, taskKey string, offset, limit int) ([]*model.SyncRun, int64, error)
- func (ts *TaskService) ListTasks(ctx context.Context, repoKey string, offset, limit int) ([]*model.SyncTask, int64, error)
- func (ts *TaskService) PreviewSync(ctx context.Context, req *model.PreviewSyncRequest) (*model.PreviewSyncResult, error)
- func (ts *TaskService) UpdateRunStep(step *model.SyncRunStep) error
- func (ts *TaskService) UpdateTask(ctx context.Context, req *model.UpdateTaskRequest) (*model.SyncTask, error)
- func (ts *TaskService) UpdateTaskLastRun(task *model.SyncTask, run *model.SyncRun) error
- type WebhookPayload
- type WebhookService
- func (ws *WebhookService) ApplyRules(ctx context.Context, repoKey string, event *model.WebhookEvent, ...)
- func (ws *WebhookService) CleanupOldEvents(ctx context.Context, maxAge time.Duration) (int64, error)
- func (ws *WebhookService) CreateRule(ctx context.Context, req *model.CreateRuleRequest) (*model.WebhookRule, error)
- func (ws *WebhookService) CreateWebhookEvent(event *model.WebhookEvent) error
- func (ws *WebhookService) DeleteRule(ctx context.Context, id uint) error
- func (ws *WebhookService) FindEventByEventID(eventID string) (*model.WebhookEvent, error)
- func (ws *WebhookService) FindEventByID(id uint) (*model.WebhookEvent, error)
- func (ws *WebhookService) GetRule(ctx context.Context, id uint) (*model.WebhookRule, error)
- func (ws *WebhookService) ListEvents(ctx context.Context, repoKey string, offset, limit int) ([]*model.WebhookEvent, int64, error)
- func (ws *WebhookService) ListRules(ctx context.Context, repoKey string) ([]*model.WebhookRule, error)
- func (ws *WebhookService) MarkEventProcessed(event *model.WebhookEvent) error
- func (ws *WebhookService) MarkEventProcessing(ctx context.Context, eventID uint) (*model.WebhookEvent, error)
- func (ws *WebhookService) UpdateRule(ctx context.Context, req *model.UpdateRuleRequest) (*model.WebhookRule, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrRepoNotFound is returned when a repository is not found. ErrRepoNotFound = errors.New("repo not found") // ErrTaskNotFound is returned when a sync task is not found. ErrTaskNotFound = errors.New("task not found") // ErrTaskDisabled is returned when attempting to run a disabled task. ErrTaskDisabled = errors.New("task is disabled") // ErrTaskRunning is returned when a task is already executing (concurrent run skipped). ErrTaskRunning = errors.New("task is already running") // ErrTooManyConcurrent is returned when the global concurrency limit is reached. ErrTooManyConcurrent = errors.New("too many concurrent sync tasks") // ErrRuleNotFound is returned when a webhook rule is not found. ErrRuleNotFound = errors.New("rule not found") // ErrEventNotFound is returned when a webhook event is not found. ErrEventNotFound = errors.New("event not found") )
Functions ¶
This section is empty.
Types ¶
type CreateMirrorChannelInput ¶
type CreateMirrorChannelInput struct {
Name string `json:"name"`
Mode string `json:"mode"`
RepoKey string `json:"repoKey"`
Targets []MirrorTargetInput `json:"targets"`
}
type ExecuteMirrorRunInput ¶
type MirrorService ¶
type MirrorService struct {
// contains filtered or unexported fields
}
MirrorService 镜像通道编排:通道 CRUD、源仓库本地克隆管理、 预检/执行/验证,底层调用 git-ferry-core/mirror。
func NewMirrorService ¶
func NewMirrorService(svc *Service, db *gorm.DB) (*MirrorService, error)
func (*MirrorService) CreateMirrorChannel ¶
func (m *MirrorService) CreateMirrorChannel(ctx context.Context, in CreateMirrorChannelInput) (*model.MirrorChannel, error)
CreateMirrorChannel 创建通道。publish 模式会先拉取源仓库并读取 go.mod, 提前暴露仓库不可达 / module 缺失 / 目标身份相同等问题。
func (*MirrorService) DeleteMirrorChannel ¶
func (m *MirrorService) DeleteMirrorChannel(confirm string, id uint) error
func (*MirrorService) DeleteMirrorTarget ¶
func (m *MirrorService) DeleteMirrorTarget(targetID uint) error
func (*MirrorService) ExecuteMirrorRun ¶
func (m *MirrorService) ExecuteMirrorRun(ctx context.Context, channelID uint, in ExecuteMirrorRunInput) (*model.MirrorRun, error)
ExecuteMirrorRun 创建并异步执行一条镜像 run。同一通道同时只允许一个 进行中的执行(含预检外的写操作),避免克隆目录竞争。
func (*MirrorService) GetMirrorChannel ¶
func (m *MirrorService) GetMirrorChannel(id uint) (*model.MirrorChannel, error)
func (*MirrorService) GetMirrorRun ¶
func (m *MirrorService) GetMirrorRun(id uint) (*model.MirrorRun, error)
GetMirrorRun 单条执行记录详情。
func (*MirrorService) GetMirrorVersions ¶
func (m *MirrorService) GetMirrorVersions(ctx context.Context, channelID uint) (*MirrorVersionsResult, error)
GetMirrorVersions 源仓库 tag 列表 ∪ 执行历史,合并出版本矩阵。
func (*MirrorService) ListMirrorChannels ¶
func (m *MirrorService) ListMirrorChannels(page dao.Pagination) ([]*model.MirrorChannel, int64, error)
func (*MirrorService) ListMirrorRuns ¶
func (m *MirrorService) ListMirrorRuns(channelID uint, page dao.Pagination) ([]*model.MirrorRun, int64, error)
ListMirrorRuns 分页列出通道执行记录。
func (*MirrorService) PreviewMirrorRun ¶
func (m *MirrorService) PreviewMirrorRun(ctx context.Context, channelID, targetID uint, tag string) (*mirror.TagReport, error)
PreviewMirrorRun 对单个 tag 做预检(DryRun,不推送)。
func (*MirrorService) TestMirrorTarget ¶
func (m *MirrorService) TestMirrorTarget(ctx context.Context, targetID uint) error
func (*MirrorService) UpdateMirrorTarget ¶
func (m *MirrorService) UpdateMirrorTarget(ctx context.Context, targetID uint, in MirrorTargetInput) (*model.MirrorTarget, error)
UpdateMirrorTarget 更新目标(凭据为空串表示保持不变)。
func (*MirrorService) VerifyMirrorTargetVersion ¶
func (m *MirrorService) VerifyMirrorTargetVersion(ctx context.Context, channelID, targetID uint, tag string) (*model.MirrorRun, error)
VerifyMirrorTargetVersion 验证目标 module@tag 可被 go 工具链消费。
type MirrorTargetInput ¶
type MirrorTargetInput struct {
Remote string `json:"remote"`
RepoURL string `json:"repoUrl"`
TargetModule string `json:"targetModule"`
CredType string `json:"credType"`
// Credential 明文仅在创建/更新时提交,格式随 CredType:
// token→token 值;ssh_key→私钥 PEM。存储前整体加密。
Credential string `json:"credential"`
Username string `json:"username"`
}
type MirrorVersion ¶
type MirrorVersion struct {
Tag string `json:"tag"`
Commit string `json:"commit,omitempty"`
Targets []MirrorVersionTarget `json:"targets"`
}
type MirrorVersionTarget ¶
type MirrorVersionTarget struct {
TargetID uint `json:"targetId"`
Target string `json:"target"`
State string `json:"state"` // unpublished|published|divergent|failed
ExecutedAt string `json:"executedAt,omitempty"`
Commit string `json:"commit,omitempty"`
Tree string `json:"tree,omitempty"`
Verify string `json:"verify"` // unverified|passed|failed
}
type MirrorVersionsResult ¶
type MirrorVersionsResult struct {
Mode string `json:"mode"`
Module string `json:"module"`
Versions []MirrorVersion `json:"versions"`
}
type OperationLogService ¶
type OperationLogService struct {
// contains filtered or unexported fields
}
OperationLogService 处理审计日志相关操作。
func NewOperationLogService ¶
func NewOperationLogService(opLogDAO *dao.OperationLogDAO) *OperationLogService
NewOperationLogService 创建新的 OperationLogService 实例。
func (*OperationLogService) List ¶
func (s *OperationLogService) List(ctx context.Context, offset, limit int, filter *dao.OperationLogFilter) ([]*model.OperationLog, int64, error)
List 按过滤条件分页返回审计日志。
func (*OperationLogService) Record ¶
func (s *OperationLogService) Record(ctx context.Context, entry *model.OperationLog) error
Record 记录一条审计日志(best-effort,由调用方决定如何处理错误)。
type PlatformService ¶
type PlatformService struct {
// contains filtered or unexported fields
}
PlatformService 平台服务
func NewPlatformService ¶
func NewPlatformService(platformDAO *dao.PlatformDAO, repoDAO *dao.RepoDAO, providerMgr *sdkprov.Manager) *PlatformService
NewPlatformService 创建 PlatformService
func (*PlatformService) CountReposByPlatform ¶
func (s *PlatformService) CountReposByPlatform(ctx context.Context, platformKey string) (int64, error)
CountReposByPlatform 统计平台下的仓库数量(不加载数据)
func (*PlatformService) CreatePlatform ¶
CreatePlatform 创建平台
func (*PlatformService) DeletePlatform ¶
func (s *PlatformService) DeletePlatform(ctx context.Context, key string) error
DeletePlatform 删除平台
func (*PlatformService) GetPlatform ¶
GetPlatform 获取平台
func (*PlatformService) GetPlatformByID ¶
GetPlatformByID 根据 ID 获取平台
func (*PlatformService) ListPlatformRepos ¶
func (s *PlatformService) ListPlatformRepos(ctx context.Context, key, page, perPage string) ([]*sdkprov.PlatformRepo, error)
ListPlatformRepos 列出平台上的仓库
func (*PlatformService) ListPlatforms ¶
ListPlatforms 列出所有平台
func (*PlatformService) ListReposByPlatform ¶
func (s *PlatformService) ListReposByPlatform(ctx context.Context, platformKey string) ([]*model.Repo, error)
ListReposByPlatform 列出平台下的仓库
func (*PlatformService) SetDefaultPlatform ¶
func (s *PlatformService) SetDefaultPlatform(ctx context.Context, key string) error
SetDefaultPlatform 设置默认平台
func (*PlatformService) SyncPlatformRepos ¶
SyncPlatformRepos 同步平台仓库到本地
func (*PlatformService) TestPlatformConnection ¶
func (s *PlatformService) TestPlatformConnection(ctx context.Context, key string) (*sdkprov.TestConnectionResult, error)
TestPlatformConnection 测试平台连接
func (*PlatformService) UpdatePlatform ¶
UpdatePlatform 更新平台
func (*PlatformService) UpdatePlatformStatus ¶
func (s *PlatformService) UpdatePlatformStatus(ctx context.Context, key, status, testResult string) error
UpdatePlatformStatus 更新平台状态
type RepoService ¶
type RepoService struct {
// contains filtered or unexported fields
}
RepoService handles repository-related operations.
func NewRepoService ¶
func NewRepoService(repoDAO *dao.RepoDAO, platformDAO *dao.PlatformDAO, providerMgr *sdkprov.Manager) *RepoService
NewRepoService creates a new RepoService instance.
func (*RepoService) CountRepos ¶
func (rs *RepoService) CountRepos() (int64, error)
CountRepos returns the total repo count via COUNT aggregate.
func (*RepoService) CreateRepo ¶
func (rs *RepoService) CreateRepo(ctx context.Context, req *model.CreateRepoRequest) (*model.Repo, error)
CreateRepo creates a new repository.
func (*RepoService) DeleteRepo ¶
func (rs *RepoService) DeleteRepo(ctx context.Context, key string) error
DeleteRepo deletes a repository by key.
func (*RepoService) GetRepoByKey ¶
func (rs *RepoService) GetRepoByKey(key string) (*model.Repo, error)
GetRepoByKey returns a repository by key.
func (*RepoService) GetRepoWithProvider ¶
GetRepoWithProvider 一次调用完成 repo 查找 + provider 解析, 消除调用方重复的 "GetRepoByKey → nil check → resolveRepoProvider" 样板。
func (*RepoService) ListBranches ¶
ListBranches returns a list of branches for a repository.
func (*RepoService) ListRepos ¶
func (rs *RepoService) ListRepos(ctx context.Context, offset, limit int) ([]*model.Repo, int64, error)
ListRepos returns a paginated list of repositories.
func (*RepoService) ListReposWithFilter ¶
func (rs *RepoService) ListReposWithFilter(ctx context.Context, offset, limit int, filter *dao.RepoFilter) ([]*model.Repo, int64, error)
ListReposWithFilter returns a filtered, sorted, paginated list of repositories.
func (*RepoService) SetWebhookSecret ¶
func (rs *RepoService) SetWebhookSecret(repoKey, secret string) error
SetWebhookSecret 设置仓库的 Webhook 密钥(经 repo_dao 加密落库),供入站验签使用。
func (*RepoService) TestConnection ¶
func (rs *RepoService) TestConnection(ctx context.Context, repoKey string) (*model.TestConnectionResult, error)
TestConnection tests the connection to a repository.
func (*RepoService) UpdateRepo ¶
func (rs *RepoService) UpdateRepo(ctx context.Context, req *model.UpdateRepoRequest) (*model.Repo, error)
UpdateRepo updates an existing repository.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) CleanupOldData ¶
func (*Service) CompleteRun ¶
CompleteRun updates a sync run with final status and details. Satisfies executor.RunManager.
func (*Service) CompleteRunWithTaskUpdate ¶
CompleteRunWithTaskUpdate 在同一事务中完成 run + task 更新. Satisfies executor.RunManager.
func (*Service) CountRepos ¶
CountRepos returns the total repo count via COUNT aggregate (no row loading).
func (*Service) CountReposByPlatform ¶
CountReposByPlatform 统计平台下的仓库数量
func (*Service) CountTasksByStatus ¶
CountTasksByStatus returns task counts grouped by last_status (key "total" = overall).
func (*Service) CreatePlatform ¶
CreatePlatform 创建平台
func (*Service) CreateRepo ¶
func (s *Service) CreateRepo(ctx context.Context, req *model.CreateRepoRequest) (*model.Repo, error)
CreateRepo creates a new repository.
func (*Service) CreateRule ¶
func (s *Service) CreateRule(ctx context.Context, req *model.CreateRuleRequest) (*model.WebhookRule, error)
CreateRule creates a new webhook rule.
func (*Service) CreateRun ¶
func (s *Service) CreateRun(task *model.SyncTask, trigger string, webhookEventID *uint) (*model.SyncRun, error)
CreateRun creates a new sync run record. Satisfies executor.RunManager.
func (*Service) CreateRunStep ¶
func (s *Service) CreateRunStep(step *model.SyncRunStep) error
CreateRunStep creates a new sync run step record. Satisfies executor.RunManager.
func (*Service) CreateTask ¶
func (*Service) DeleteHistory ¶
DeleteHistory deletes a sync run by ID.
func (*Service) DeletePlatform ¶
DeletePlatform 删除平台
func (*Service) DeletePlatformWebhook ¶
DeletePlatformWebhook 删除平台侧的 Webhook。
func (*Service) DeleteRepo ¶
DeleteRepo deletes a repository by key.
func (*Service) DeleteRule ¶
DeleteRule deletes a webhook rule by ID.
func (*Service) GetPlatform ¶
GetPlatform 获取平台
func (*Service) GetPlatformByID ¶
GetPlatformByID returns a platform by ID. Satisfies executor.PlatformProvider.
func (*Service) GetRepoByKey ¶
GetRepoByKey returns a repository by key. Satisfies executor.RepoProvider.
func (*Service) GetTempDir ¶
func (*Service) HealthCheck ¶
HealthCheck checks the health of all dependencies. Returns a map of component name to "ok" or error message. 内部对每个组件设置 5s 超时:基础设施卡住时健康检查不会无限阻塞。
func (*Service) ListBranches ¶
ListBranches returns a list of branches for a repository.
func (*Service) ListEvents ¶
func (s *Service) ListEvents(ctx context.Context, repoKey string, offset, limit int) ([]*model.WebhookEvent, int64, error)
ListEvents returns webhook events for a repository.
func (*Service) ListHistory ¶
func (s *Service) ListHistory(ctx context.Context, taskKey string, offset, limit int) ([]*model.SyncRun, int64, error)
ListHistory returns a paginated list of sync run history.
func (*Service) ListOperations ¶
func (s *Service) ListOperations(ctx context.Context, offset, limit int, filter *dao.OperationLogFilter) ([]*model.OperationLog, int64, error)
ListOperations 按过滤条件分页返回审计日志。
func (*Service) ListPlatformRepos ¶
func (s *Service) ListPlatformRepos(ctx context.Context, key, page, perPage string) ([]*sdkprov.PlatformRepo, error)
ListPlatformRepos 列出平台上的仓库
func (*Service) ListPlatformWebhooks ¶
func (s *Service) ListPlatformWebhooks(ctx context.Context, repoKey string) ([]*sdkprov.PlatformWebhook, error)
ListPlatformWebhooks 列出平台侧已注册的 Webhook。
func (*Service) ListPlatforms ¶
ListPlatforms 列出所有平台
func (*Service) ListReposByPlatform ¶
func (s *Service) ListReposByPlatform(ctx context.Context, platformKey string) ([]*model.Repo, error)
ListReposByPlatform 列出平台下的仓库
func (*Service) ListReposWithFilter ¶
func (s *Service) ListReposWithFilter(ctx context.Context, offset, limit int, filter *dao.RepoFilter) ([]*model.Repo, int64, error)
ListReposWithFilter returns a filtered, sorted, paginated list of repositories.
func (*Service) ListTasks ¶
func (s *Service) ListTasks(ctx context.Context, repoKey string, offset, limit int) ([]*model.SyncTask, int64, error)
ListTasks returns a paginated list of sync tasks.
func (*Service) OperationStats ¶
OperationStats 返回今日、本周、总操作数。
func (*Service) PreviewSync ¶
func (s *Service) PreviewSync(ctx context.Context, req *model.PreviewSyncRequest) (*model.PreviewSyncResult, error)
PreviewSync previews a sync operation.
func (*Service) ReceiveWebhook ¶
func (*Service) RecordOperation ¶
RecordOperation 记录一条审计日志。
func (*Service) RegisterPlatformWebhook ¶
func (s *Service) RegisterPlatformWebhook(ctx context.Context, repoKey, callbackURL, secret string, events []string) (*sdkprov.PlatformWebhook, error)
RegisterPlatformWebhook 在平台侧为仓库注册 Webhook,回调指向本服务的接收端点 (/api/webhook/receive/:repoKey)。secret 非空时持久化到仓库记录(加密存储), 用于入站事件验签。events 为空时默认订阅 push。
func (*Service) RunTaskAsync ¶
RunTaskAsync 异步触发一次同步:校验与并发快速失败在调用方 goroutine 内完成, 实际执行纳入 WaitGroup + bgCtx(优雅关停时被等待/取消),适合 HTTP 手动触发路径, 避免 handler 被分钟级同步任务挂住。返回 nil 仅代表"已受理",结果见执行历史。
func (*Service) RunTaskWithTrigger ¶
func (*Service) SetDefaultPlatform ¶
SetDefaultPlatform 设置默认平台
func (*Service) SyncPlatformRepos ¶
SyncPlatformRepos 同步平台仓库到本地
func (*Service) TestConnection ¶
func (s *Service) TestConnection(ctx context.Context, repoKey string) (*model.TestConnectionResult, error)
TestConnection tests the connection to a repository.
func (*Service) TestPlatformConnection ¶
func (s *Service) TestPlatformConnection(ctx context.Context, key string) (*sdkprov.TestConnectionResult, error)
TestPlatformConnection 测试平台连接
func (*Service) UpdatePlatform ¶
UpdatePlatform 更新平台
func (*Service) UpdatePlatformStatus ¶
UpdatePlatformStatus 更新平台状态
func (*Service) UpdateRepo ¶
func (s *Service) UpdateRepo(ctx context.Context, req *model.UpdateRepoRequest) (*model.Repo, error)
UpdateRepo updates an existing repository.
func (*Service) UpdateRule ¶
func (s *Service) UpdateRule(ctx context.Context, req *model.UpdateRuleRequest) (*model.WebhookRule, error)
UpdateRule updates an existing webhook rule.
func (*Service) UpdateRunStep ¶
func (s *Service) UpdateRunStep(step *model.SyncRunStep) error
UpdateRunStep updates an existing sync run step record. Satisfies executor.RunManager.
func (*Service) UpdateTask ¶
type TaskService ¶
type TaskService struct {
// contains filtered or unexported fields
}
TaskService handles sync task-related operations.
func NewTaskService ¶
func NewTaskService(taskDAO *dao.SyncTaskDAO, runDAO *dao.SyncRunDAO, runStepDAO *dao.SyncRunStepDAO, repoDAO *dao.RepoDAO) *TaskService
NewTaskService creates a new TaskService instance.
func (*TaskService) CleanupOldRunSteps ¶
CleanupOldRunSteps removes sync run steps older than the specified duration.
func (*TaskService) CleanupOldRuns ¶
CleanupOldRuns removes sync runs older than the specified duration.
func (*TaskService) CompleteRun ¶
func (ts *TaskService) CompleteRun(run *model.SyncRun) error
CompleteRun updates a sync run with final status and details.
func (*TaskService) CompleteRunWithTaskUpdate ¶
CompleteRunWithTaskUpdate 在同一事务中完成 run 更新 + task 状态更新,保证原子性。
func (*TaskService) CountTasksByStatus ¶
func (ts *TaskService) CountTasksByStatus() (map[string]int64, error)
CountTasksByStatus returns task counts grouped by last_status (key "total" = overall).
func (*TaskService) CreateRun ¶
func (ts *TaskService) CreateRun(task *model.SyncTask, trigger string, webhookEventID *uint) (*model.SyncRun, error)
CreateRun creates a new sync run record for a task.
func (*TaskService) CreateRunStep ¶
func (ts *TaskService) CreateRunStep(step *model.SyncRunStep) error
CreateRunStep creates a new sync run step record.
func (*TaskService) CreateTask ¶
func (ts *TaskService) CreateTask(ctx context.Context, req *model.CreateTaskRequest) (*model.SyncTask, error)
CreateTask creates a new sync task.
func (*TaskService) DeleteHistory ¶
func (ts *TaskService) DeleteHistory(ctx context.Context, id uint) error
DeleteHistory deletes a sync run by ID.
func (*TaskService) DeleteTask ¶
func (ts *TaskService) DeleteTask(ctx context.Context, key string) error
DeleteTask deletes a sync task by key.
func (*TaskService) FindAllEnabledTasks ¶
func (ts *TaskService) FindAllEnabledTasks() ([]*model.SyncTask, error)
FindAllEnabledTasks returns all enabled sync tasks.
func (*TaskService) FindTaskByKey ¶
func (ts *TaskService) FindTaskByKey(key string) (*model.SyncTask, error)
FindTaskByKey returns a sync task by key (internal use).
func (*TaskService) ListHistory ¶
func (ts *TaskService) ListHistory(ctx context.Context, taskKey string, offset, limit int) ([]*model.SyncRun, int64, error)
ListHistory returns a paginated list of sync run history.
func (*TaskService) ListTasks ¶
func (ts *TaskService) ListTasks(ctx context.Context, repoKey string, offset, limit int) ([]*model.SyncTask, int64, error)
ListTasks returns a paginated list of sync tasks.
func (*TaskService) PreviewSync ¶
func (ts *TaskService) PreviewSync(ctx context.Context, req *model.PreviewSyncRequest) (*model.PreviewSyncResult, error)
PreviewSync previews a sync operation.
func (*TaskService) UpdateRunStep ¶
func (ts *TaskService) UpdateRunStep(step *model.SyncRunStep) error
UpdateRunStep updates an existing sync run step record.
func (*TaskService) UpdateTask ¶
func (ts *TaskService) UpdateTask(ctx context.Context, req *model.UpdateTaskRequest) (*model.SyncTask, error)
UpdateTask updates an existing sync task.
func (*TaskService) UpdateTaskLastRun ¶
UpdateTaskLastRun updates the task's last run time and status.
type WebhookPayload ¶
type WebhookPayload struct {
Method string
Path string
Header map[string][]string
Body []byte
RemoteAddr string
}
WebhookPayload 是协议无关的入站 Webhook 载荷。 core 不提供 HTTP 服务端;壳层(hz/gin/…)负责收包后转成该结构再调用。 内部会拼一个临时 *http.Request 交给 git-platform-sdk 做验签/解析(SDK 契约如此), 库对外 API 不暴露 Web 服务器语义。
type WebhookService ¶
type WebhookService struct {
// contains filtered or unexported fields
}
WebhookService handles webhook-related operations.
func NewWebhookService ¶
func NewWebhookService(ruleDAO *dao.WebhookRuleDAO, eventDAO *dao.WebhookEventDAO, repoDAO *dao.RepoDAO) *WebhookService
NewWebhookService creates a new WebhookService instance.
func (*WebhookService) ApplyRules ¶
func (ws *WebhookService) ApplyRules(ctx context.Context, repoKey string, event *model.WebhookEvent, lastTriggerTime *sync.Map, runTaskFn func(ctx context.Context, taskKey, trigger string, webhookEventID *uint) error, webhookEventID *uint)
ApplyRules applies webhook rules to an event.
func (*WebhookService) CleanupOldEvents ¶
func (ws *WebhookService) CleanupOldEvents(ctx context.Context, maxAge time.Duration) (int64, error)
CleanupOldEvents removes webhook events older than the specified duration.
func (*WebhookService) CreateRule ¶
func (ws *WebhookService) CreateRule(ctx context.Context, req *model.CreateRuleRequest) (*model.WebhookRule, error)
CreateRule creates a new webhook rule.
func (*WebhookService) CreateWebhookEvent ¶
func (ws *WebhookService) CreateWebhookEvent(event *model.WebhookEvent) error
CreateWebhookEvent creates a new webhook event.
func (*WebhookService) DeleteRule ¶
func (ws *WebhookService) DeleteRule(ctx context.Context, id uint) error
DeleteRule deletes a webhook rule by ID.
func (*WebhookService) FindEventByEventID ¶
func (ws *WebhookService) FindEventByEventID(eventID string) (*model.WebhookEvent, error)
FindEventByEventID returns a webhook event by event ID (internal use).
func (*WebhookService) FindEventByID ¶
func (ws *WebhookService) FindEventByID(id uint) (*model.WebhookEvent, error)
FindEventByID returns a webhook event by ID (internal use).
func (*WebhookService) GetRule ¶
func (ws *WebhookService) GetRule(ctx context.Context, id uint) (*model.WebhookRule, error)
GetRule returns a webhook rule by ID.
func (*WebhookService) ListEvents ¶
func (ws *WebhookService) ListEvents(ctx context.Context, repoKey string, offset, limit int) ([]*model.WebhookEvent, int64, error)
ListEvents returns webhook events for a repository.
func (*WebhookService) ListRules ¶
func (ws *WebhookService) ListRules(ctx context.Context, repoKey string) ([]*model.WebhookRule, error)
ListRules returns webhook rules for a repository.
func (*WebhookService) MarkEventProcessed ¶
func (ws *WebhookService) MarkEventProcessed(event *model.WebhookEvent) error
MarkEventProcessed 标记事件为 processed(处理完成后调用)。 用 targeted UPDATE 仅写 status+processed_at,避免全字段回写大 payload。
func (*WebhookService) MarkEventProcessing ¶
func (ws *WebhookService) MarkEventProcessing(ctx context.Context, eventID uint) (*model.WebhookEvent, error)
MarkEventProcessing 查找事件并标记为 processing,返回该事件供后续处理。
func (*WebhookService) UpdateRule ¶
func (ws *WebhookService) UpdateRule(ctx context.Context, req *model.UpdateRuleRequest) (*model.WebhookRule, error)
UpdateRule updates an existing webhook rule.