models

package
v0.0.0-...-70b3fac Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// StatusDisabled means this item is disabled
	StatusDisabled Status = iota

	// StatusEnabled means this item is enabled
	StatusEnabled

	// StatusDisabledString means this item is disabled (used for graphql)
	StatusDisabledString string = "DISABLED"

	// StatusEnabledString means this item is enabled (used for graphql)
	StatusEnabledString string = "ENABLED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job struct {
	// gorm base model
	gorm.Model

	// TaskID indicates the task ID associated with the Job
	TaskID uint

	// Task indicates the task associated with the Job
	Task Task

	// TaskRuleID indicates the task rule ID associated with the Job
	TaskRuleID uint

	// TaskRule indicates the task rule associated with the Job
	TaskRule TaskRule

	// Stdout stores the standard output of the Job
	Stdout string

	// Stderr stores the standard error output of the Job
	Stderr string

	// StartAt stores the start time of the Job
	StartAt time.Time

	// StopAt stores the stop time of the Job
	StopAt time.Time

	// Flags store multiple flag values to indicate Job status
	Flags uint64
}

Job define the data structure of a task execution

func (*Job) AddFlag

func (job *Job) AddFlag(flag JobFlag)

AddFlag helps the caller to add flags to the Job record

func (Job) GetCreatedAt

func (job Job) GetCreatedAt() int64

GetCreatedAt is a function to get the field value of GraphQL Model

func (Job) GetID

func (job Job) GetID() int64

GetID is a function to get the field value of GraphQL Model

func (Job) GetUpdatedAt

func (job Job) GetUpdatedAt() int64

GetUpdatedAt is a function to get the field value of GraphQL Model

func (*Job) HasFlag

func (job *Job) HasFlag(flag JobFlag) bool

HasFlag helps the caller to check the flags in the Job record

func (Job) IsModel

func (job Job) IsModel()

IsModel is a flag field of the GraphQL Model interface

func (*Job) RemoveFlag

func (job *Job) RemoveFlag(flag JobFlag)

RemoveFlag helps the caller to remove the flags from the Job record

type JobFlag

type JobFlag uint64

JobFlag is a unique type of flag in Job, which is used as bitmask

const (
	// JobFlagTimeout indicates that the task execution exceeds the time limit
	JobFlagTimeout JobFlag = 1 << iota
)

type Status

type Status uint8

Status indicates the current item status

func (Status) MarshalGQL

func (s Status) MarshalGQL(w io.Writer)

MarshalGQL implements GQLGEN dependent encoding function

func (*Status) UnmarshalGQL

func (s *Status) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements GQLGEN dependent decoding function

type Task

type Task struct {
	// gorm base model
	gorm.Model

	// Name of task
	Name string

	// Type indicates the type of this task
	Type TaskType

	// Configuration
	Configuration datatypes.JSON

	// Rules of task
	Rules []TaskRule

	// LastRunningAt indicates the last running time of the current task
	LastRunningAt sql.NullTime

	// LastRunningTime indicates the time consumed for the last run of the current task
	LastRunningTime int64

	// Status indicates the current task status
	Status Status
}

Task define the data structure of a timed task

func (Task) GetCreatedAt

func (t Task) GetCreatedAt() int64

GetCreatedAt is a function to get the field value of GraphQL Model

func (Task) GetID

func (t Task) GetID() int64

GetID is a function to get the field value of GraphQL Model

func (Task) GetUpdatedAt

func (t Task) GetUpdatedAt() int64

GetUpdatedAt is a function to get the field value of GraphQL Model

func (Task) IsModel

func (t Task) IsModel()

IsModel is a flag field of the GraphQL Model interface

type TaskConfigurationShell

type TaskConfigurationShell struct {
	Command string        `json:"command"`
	Timeout time.Duration `json:"timeout"`
}

TaskConfigurationShell define the data structure of shell task configuration

func (TaskConfigurationShell) IsTaskConfiguration

func (tcs TaskConfigurationShell) IsTaskConfiguration()

IsTaskConfiguration is a flag function for task configuration

type TaskConfigurationWebhook

type TaskConfigurationWebhook struct {
	URL    string `json:"url"`
	Method string `json:"method"`
}

TaskConfigurationWebhook define the data structure of webhook task configuration

func (TaskConfigurationWebhook) IsTaskConfiguration

func (tcw TaskConfigurationWebhook) IsTaskConfiguration()

IsTaskConfiguration is a flag function for task configuration

type TaskRule

type TaskRule struct {
	// gorm base model
	gorm.Model

	// TaskID indicates the task ID associated with the rule
	TaskID uint

	// Task indicates the task associated with the Job
	Task Task

	// Description of task rule
	Description sql.NullString

	// Rule of task
	Rule string

	// LastRunningAt indicates the last running time of the current task rule
	LastRunningAt sql.NullTime

	// LastRunningTime indicates the time consumed for the last run of the current task rule
	LastRunningTime int64

	// Status indicates the current task rule status
	Status Status
}

TaskRule define the data structure of task running rule

func (TaskRule) GetCreatedAt

func (tr TaskRule) GetCreatedAt() int64

GetCreatedAt is a function to get the field value of GraphQL Model

func (TaskRule) GetID

func (tr TaskRule) GetID() int64

GetID is a function to get the field value of GraphQL Model

func (TaskRule) GetUpdatedAt

func (tr TaskRule) GetUpdatedAt() int64

GetUpdatedAt is a function to get the field value of GraphQL Model

func (TaskRule) IsModel

func (tr TaskRule) IsModel()

IsModel is a flag field of the GraphQL Model interface

type TaskType

type TaskType string

TaskType is the type used to describe the type of task

const (
	// TaskTypeShell is a task for starting external process via shell
	TaskTypeShell TaskType = "SHELL"
	// TaskTypeWebhook is a task type that triggers an external webhook
	TaskTypeWebhook TaskType = "WEBHOOK"
)

Jump to

Keyboard shortcuts

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