Documentation
¶
Index ¶
- Variables
- type Config
- 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) 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) 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(maxAge time.Duration) (events, runs, steps int64, err error)
- func (s *Service) CompleteRun(run *model.SyncRun) error
- func (s *Service) CountRepos() (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) GetAPIKey() string
- func (s *Service) GetConfig() *model.Config
- func (s *Service) GetPlatform(ctx context.Context, key string) (*model.Platform, error)
- func (s *Service) GetPlatformByID(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) 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, req *http.Request) 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) 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(maxAge time.Duration) (int64, error)
- func (ts *TaskService) CleanupOldRuns(maxAge time.Duration) (int64, error)
- func (ts *TaskService) CompleteRun(run *model.SyncRun) 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 WebhookService
- func (ws *WebhookService) ApplyRules(ctx context.Context, repoKey string, event *model.WebhookEvent, ...)
- func (ws *WebhookService) CleanupOldEvents(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 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) 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 ¶ added in v1.5.5
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) 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 ¶ added in v1.6.0
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) CountRepos ¶ added in v1.5.5
CountRepos returns the total repo count via COUNT aggregate (no row loading).
func (*Service) CountTasksByStatus ¶ added in v1.5.5
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 ¶ added in v1.6.0
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.
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 ¶ added in v1.6.0
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 ¶ added in v1.6.0
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) 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 ¶
func (ts *TaskService) CleanupOldRunSteps(maxAge time.Duration) (int64, error)
CleanupOldRunSteps removes sync run steps older than the specified duration.
func (*TaskService) CleanupOldRuns ¶
func (ts *TaskService) CleanupOldRuns(maxAge time.Duration) (int64, error)
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) CountTasksByStatus ¶ added in v1.5.5
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 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(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 ¶ added in v1.5.5
func (ws *WebhookService) MarkEventProcessed(event *model.WebhookEvent) error
MarkEventProcessed 标记事件为 processed(处理完成后调用)。
func (*WebhookService) MarkEventProcessing ¶ added in v1.5.5
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.