actuator

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeDockerActuator

func MakeDockerActuator(initFunc InitFunction) *dockerActuator

func MakeFucntionActuator

func MakeFucntionActuator(runFunc RunFunction, initFunc InitFunction) (*fucntionActuator, error)

runFunc 待调度的执行函数,注意实现该函数的时候,需要使用传入 ctx 进行超时和退出处理,框架否则无法控制超时时间 callbackChannel 用来执行器进行任务回调,返回已经完成的任务,如果不需要回调,传入 nil 即可

Types

type DockerTask

type DockerTask struct {
	Image         string   // 镜像
	Cmd           []string // 容器执行命令
	ContainerName string   // 容器名,不能重复

	// 资源限制
	MemoryLimit int64 // bytes
	CpuPercent  int   // cpu 占用百分比, 比如暂用 2 核就是 200

	// 可选配置
	ExposedPorts    []string          // 暴露端口
	Env             []string          // 环境变量
	WorkingDir      string            // 工作目录
	NetworkDisabled bool              // 是否关闭网络
	NetworkMode     string            // 网络模式
	Privileged      bool              // Is the container in privileged mode
	VolumeBinds     map[string]string // host 路径到容器路径的映射,类似于 -v 参数

	ContainerId string // 执行后对应的 容器 Id
}

DockerTask docker 任务

type InitFunction

type InitFunction func(ctx context.Context, task *framework.Task) (newTask *framework.Task, err error)

InitFunction 任务执行前的初始工作

type RunFunction

type RunFunction func(ctx context.Context, task *framework.Task) (data interface{}, err error)

RunFunction 执行函数的定义,实现该函数的时候,建议使用传入 ctx 进行超时和退出处理 data 任务执行完成返回的数据

Jump to

Keyboard shortcuts

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