task

package
v0.3.0-beta.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Created   = "Created"
	Postponed = "Postponed"
	Ready     = "Ready"
	Pending   = "Pending"
	Running   = "Running"
	Succeeded = "Succeeded"
	Failed    = "Failed"
	Canceled  = "Canceled"
)

States

View Source
const (
	Isolated = "isolated"
)

Policies

View Source
const (
	Unit = time.Second
)

Variables

View Source
var (
	Settings = &settings.Settings
	Log      = logr.WithName("task-scheduler")
)

Functions

This section is empty.

Types

type AddonNotFound

type AddonNotFound struct {
	Name string
}

AddonNotFound used to report addon referenced by a task but cannot be found.

func (*AddonNotFound) Error

func (e *AddonNotFound) Error() (s string)

func (*AddonNotFound) Is

func (e *AddonNotFound) Is(err error) (matched bool)

type Manager

type Manager struct {
	// DB
	DB *gorm.DB
	// k8s client.
	Client k8s.Client
	// Addon token scopes.
	Scopes []string
}

Manager provides task management.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

Run the manager.

type Rule

type Rule interface {
	Match(candidate, other *model.Task) bool
}

Rule defines postpone rules.

type RuleIsolated

type RuleIsolated struct {
}

RuleIsolated policy.

func (*RuleIsolated) Match

func (r *RuleIsolated) Match(candidate, other *model.Task) (matched bool)

Match determines the match.

type RuleUnique

type RuleUnique struct {
}

RuleUnique running tasks must be unique by:

  • application
  • variant
  • addon.

func (*RuleUnique) Match

func (r *RuleUnique) Match(candidate, other *model.Task) (matched bool)

Match determines the match.

type Task

type Task struct {
	// model.
	*model.Task
}

Task is an runtime task.

func (*Task) Cancel

func (r *Task) Cancel(client k8s.Client) (err error)

Cancel the task.

func (*Task) Delete

func (r *Task) Delete(client k8s.Client) (err error)

Delete the associated pod as needed.

func (*Task) Reflect

func (r *Task) Reflect(client k8s.Client) (err error)

Reflect finds the associated pod and updates the task state.

func (*Task) Run

func (r *Task) Run(client k8s.Client) (err error)

Run the specified task.

type Validator

type Validator struct {
	// k8s client.
	Client k8s.Client
}

Validator validates task tokens.

func (*Validator) Valid

func (r *Validator) Valid(token *jwt.Token, db *gorm.DB) (valid bool)

Valid token when:

  • The token references a task.
  • The task is valid and running.
  • The task pod valid and pending|running.

Jump to

Keyboard shortcuts

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