generationlogic

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SubtaskGenerationInterval = 10
	SubtaskGenerationMaxTime  = 3600
)
View Source
const (
	SubtaskDefaultTimeout = 300
	SubtaskMaxTimeout     = 1800
)
View Source
const TaskStatusKeyPrefix = "task.status."

保存任务创建

Variables

This section is empty.

Functions

func CreateSubtask

func CreateSubtask(
	taskId taskmodel.TaskIdType,
	taskType uint32,
	impl taskmodel.ITaskGenerator,
	subtaskData *taskmodel.SubtaskBody,
	finished *bool,
) error

创建一个子任务

func GetTaskGenerator

func GetTaskGenerator(taskType uint32, generator *taskmodel.ITaskGenerator) error

get the generator object of the specified task type

func GetTaskStatusKey

func GetTaskStatusKey(taskId taskmodel.TaskIdType) string

获取保存任务调度数据的Key

func LoadStatus

func LoadStatus(
	taskId taskmodel.TaskIdType,
	retTaskStatus *string,
) error

根据任务ID从Redis中加载任务的生成状态

func SaveStatus

func SaveStatus(
	taskId taskmodel.TaskIdType,
	taskStatus string,
) error

保存任务的运行状态数据

Types

type FlowHelper

type FlowHelper struct {
	GenerationQueues generationqueue.GenerationiQueueMgr         // subtask queue manager
	GeneratorMap     map[taskmodel.TaskIdType]TaskGenerationImpl // task generator object map
	Mutex            sync.Mutex                                  // lock
}

generation flow helpr

func GetFlowHelper

func GetFlowHelper() *FlowHelper

func NewFlowHelper

func NewFlowHelper() *FlowHelper

func (*FlowHelper) Begin

func (generator *FlowHelper) Begin(
	taskId taskmodel.TaskIdType,
	taskType uint32,
	taskParam *taskmodel.TaskParam,
	taskGenerator taskmodel.ITaskGenerator,
) error

func (*FlowHelper) End

func (generator *FlowHelper) End(
	taskId taskmodel.TaskIdType,
) error

func (*FlowHelper) GenerationLoop

func (generator *FlowHelper) GenerationLoop(
	taskId taskmodel.TaskIdType,
) error

type GenerationFlow

type GenerationFlow struct {
	TaskId    taskmodel.TaskIdType
	TaskType  uint32
	Generator taskmodel.ITaskGenerator
	TaskParam *taskmodel.TaskParam
}

generation flow

func NewGenerationFlow

func NewGenerationFlow() *GenerationFlow

create a generation flow object every task has their own generation flow object

func (*GenerationFlow) FinishGeneration

func (flow *GenerationFlow) FinishGeneration() error

finish the generation process

func (*GenerationFlow) GenerationLoop

func (flow *GenerationFlow) GenerationLoop() error

generation loop

func (*GenerationFlow) InitGeneration

func (flow *GenerationFlow) InitGeneration(
	taskId taskmodel.TaskIdType,
	taskType uint32,
	taskParam *taskmodel.TaskParam,
) error

init the generation

type TaskGenerationImpl

type TaskGenerationImpl struct {
	Impl     taskmodel.ITaskGenerator
	TaskType uint32
}

Jump to

Keyboard shortcuts

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