task

package
v1.23.2 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TaskFunction_SyncAlertRuleState   = "sync-alertrule-state"
	TaskFunction_CheckAlertRuleConfig = "check-alertrule-config"
	TaskFunction_SyncSystemAlertRule  = "sync-system-alertrule"
)
View Source
const RemoveConsumerDuration = 5 * time.Minute
View Source
const TaskFunction_ArchiveTasks = "task-archive"
View Source
const TaskFunction_ClusterSync = "cluster-sync"
View Source
const TaskFunction_HelmSyncCharts = "helm-sync-charts"

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, rediscli *redis.Client,
	db *database.Database,
	gitp *git.SimpleLocalProvider,
	argocd *argo.Client,
	helmOptions *helm.Options,
	agents *agents.ClientSet,
) error

Types

type AlertRuleSyncTasker added in v1.23.0

type AlertRuleSyncTasker struct {
	DB *database.Database
	// contains filtered or unexported fields
}

func (*AlertRuleSyncTasker) CheckAlertRuleConfig added in v1.23.0

func (t *AlertRuleSyncTasker) CheckAlertRuleConfig(ctx context.Context) error

func (*AlertRuleSyncTasker) Crontasks added in v1.23.0

func (s *AlertRuleSyncTasker) Crontasks() map[string]Task

func (*AlertRuleSyncTasker) ProvideFuntions added in v1.23.0

func (t *AlertRuleSyncTasker) ProvideFuntions() map[string]interface{}

func (*AlertRuleSyncTasker) SyncAlertRuleState added in v1.23.0

func (t *AlertRuleSyncTasker) SyncAlertRuleState(ctx context.Context) error

func (*AlertRuleSyncTasker) SyncSystemAlertRule added in v1.23.0

func (t *AlertRuleSyncTasker) SyncSystemAlertRule(ctx context.Context) error

type ApplicationTasker

type ApplicationTasker struct {
	*application.ApplicationProcessor
}

func MustNewApplicationTasker

func MustNewApplicationTasker(db *database.Database, gitp *git.SimpleLocalProvider, argo *argo.Client, redis *redis.Client, agents *agents.ClientSet) *ApplicationTasker

func (*ApplicationTasker) ProvideFuntions

func (t *ApplicationTasker) ProvideFuntions() map[string]interface{}

type ClusterSyncTasker added in v1.22.0

type ClusterSyncTasker struct {
	DB *database.Database
	// contains filtered or unexported fields
}

func (*ClusterSyncTasker) Crontasks added in v1.22.0

func (s *ClusterSyncTasker) Crontasks() map[string]Task

func (*ClusterSyncTasker) ProvideFuntions added in v1.22.0

func (t *ClusterSyncTasker) ProvideFuntions() map[string]interface{}

func (*ClusterSyncTasker) Sync added in v1.22.0

func (t *ClusterSyncTasker) Sync(ctx context.Context) error

type CronTask

type CronTask struct {
	CronExp string
	Task    Task
}

type CronTasker

type CronTasker interface {
	Crontasks() map[string]Task // cron表达式 -> 任务
}

某些任务处理本身会有定时任务,可以实现该接口

type HelmSyncTasker

type HelmSyncTasker struct {
	DB           *database.Database
	ChartRepoUrl string
}

func (*HelmSyncTasker) Crontasks

func (s *HelmSyncTasker) Crontasks() map[string]Task

func (*HelmSyncTasker) ProvideFuntions

func (t *HelmSyncTasker) ProvideFuntions() map[string]interface{}

func (*HelmSyncTasker) SyncCharts

func (t *HelmSyncTasker) SyncCharts(ctx context.Context) error

type ProcessorContext

type ProcessorContext struct {
	Logger logr.Logger
	// contains filtered or unexported fields
}

func (*ProcessorContext) RegisterTasker

func (p *ProcessorContext) RegisterTasker(taskers ...Tasker) error

func (*ProcessorContext) Run

func (p *ProcessorContext) Run(ctx context.Context) error

func (*ProcessorContext) RunCronTasksWithLock

func (p *ProcessorContext) RunCronTasksWithLock(ctx context.Context) error

由于worker是多副本的,且crontask 只能在 worker上运行cron。 为了避免多个worker都执行,使用redis 锁选择一个worker来触发这些crontask

type SampleTasker

type SampleTasker struct{}

func (*SampleTasker) Crontasks

func (s *SampleTasker) Crontasks() map[string]Task

func (*SampleTasker) ProvideFuntions

func (s *SampleTasker) ProvideFuntions() map[string]interface{}

type Task

type Task = workflow.Task

type TaskArchiverTasker

type TaskArchiverTasker struct {
	Databse *database.Database

	Redis *redis.Client
	// contains filtered or unexported fields
}

用于转移超过时间的任务记录至database

func NewTaskArchiverTasker

func NewTaskArchiverTasker(databse *database.Database, redis *redis.Client) *TaskArchiverTasker

func (*TaskArchiverTasker) ArchiveOutdated

func (t *TaskArchiverTasker) ArchiveOutdated(ctx context.Context) error

func (*TaskArchiverTasker) Crontasks

func (t *TaskArchiverTasker) Crontasks() map[string]Task

func (*TaskArchiverTasker) ProvideFuntions

func (t *TaskArchiverTasker) ProvideFuntions() map[string]interface{}

func (*TaskArchiverTasker) RemoveOffline

func (t *TaskArchiverTasker) RemoveOffline(ctx context.Context) error

RemoveOffline 删除长时间不活跃的worker正在处理的任务

type Tasker

type Tasker interface {
	ProvideFuntions() map[string]interface{}
}

Jump to

Keyboard shortcuts

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