job

package
v0.0.0-...-9037469 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyExists    = errors.New("already exists")
	ErrAlreadyCompleted = errors.New("already completed")
)

Functions

This section is empty.

Types

type Controller

type Controller interface {
	List(c *gin.Context)
}

func NewController

func NewController(s Service) Controller

type EventHandler

type EventHandler interface {
	OnEventAdd(event *corev1.Event)
	OnCronJobDelete(cronJob *batchv1.CronJob)
}

func NewEventHandler

func NewEventHandler(s Service, h events.Hub, cronJobLister v1.CronJobLister, jobLister v1.JobLister) EventHandler

type Job

type Job struct {
	ID          string     `json:"id"`
	CronJobID   string     `json:"cronJobId"`
	Status      Status     `json:"status"`
	CreatedAt   time.Time  `json:"createdAt"`
	UpdatedAt   time.Time  `json:"updatedAt"`
	CompletedAt *time.Time `json:"completedAt"`
}

type Repository

type Repository interface {
	Add(ctx context.Context, j Job) (bool, error)
	List(ctx context.Context) ([]Job, error)
	CompleteByID(ctx context.Context, id string, s Status, t time.Time) (bool, error)
	DeleteByCronJobID(ctx context.Context, cronJobID string) error
	FindByID(ctx context.Context, id string) (*Job, error)
}

func NewRepository

func NewRepository(db *sql.DB) Repository

type Service

type Service interface {
	Create(ctx context.Context, id string, cronJobID string, t time.Time) (*Job, error)
	Succeed(ctx context.Context, id string, t time.Time) (*Job, error)
	Fail(ctx context.Context, id string, t time.Time) (*Job, error)
	List(ctx context.Context) ([]Job, error)
	Delete(ctx context.Context, cronJobID string) error
}

func NewService

func NewService(r Repository) Service

type Status

type Status int
const (
	Running Status = iota + 1
	Succeeded
	Failed
)

func (Status) MarshalJSON

func (s Status) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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