taskjs

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2025 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

* @Date: 2021-08-15 23:11:38 * @LastEditors: wangjun haodreams@163.com * @LastEditTime: 2025-05-08 15:42:33 * @FilePath: \golib\js\jstask\boss.go * @Description:

* @Author: Wangjun * @Date: 2021-08-16 09:07:58 * @LastEditTime: 2025-05-08 15:55:40 * @LastEditors: wangjun haodreams@163.com * @Description: * @FilePath: \golib\js\jstask\task.go * hnxr

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitAsynJs

func InitAsynJs(path string)

InitAsynJs 初始化异步任务

func InitCronJs

func InitCronJs(path string)

InitSyncJs 初始化同步的任务 *

  • @description:
  • @param {string} path
  • @param {func} initFunc 并发执行时,重新初始化脚本时的回调初始化函数
  • @return {*}

func InitSyncJs

func InitSyncJs(path string)

InitSyncJs 初始化同步的任务 *

  • @description:
  • @param {string} path
  • @param {func} initFunc 并发执行时,重新初始化脚本时的回调初始化函数
  • @return {*}

func LoadJs

func LoadJs(path string) (vm *goja.Runtime, err error)

func ResetReady

func ResetReady()

复位所有任务的ready状态

func SetCallBack

func SetCallBack(f CallBack)

设置全局回调函数, 必须在初始化js脚本前使用

Types

type AsyncTask

type AsyncTask struct {
	Tasks
	// contains filtered or unexported fields
}

AsyncTask 异步

func (*AsyncTask) GetTasks

func (m *AsyncTask) GetTasks() []*Task

GetTasks 获取全部的任务

type Boss

type Boss struct {
	Job Jober
}

type CallBack

type CallBack func(vm *goja.Runtime)

func GetCallBack

func GetCallBack() CallBack

GetCallBack 获取全局回调函数

type CronTask

type CronTask struct {
	// contains filtered or unexported fields
}

和同步基本类似,区别是每次执行重新加载js

func (*CronTask) GetTasks

func (m *CronTask) GetTasks() []*Task

GetTasks 获取全部的任务

type Jober

type Jober interface {
	GetTasks() []*Task
}

type SyncTask

type SyncTask struct {
	// contains filtered or unexported fields
}

SyncTask 同步

func (*SyncTask) GetTasks

func (m *SyncTask) GetTasks() []*Task

GetTasks 获取全部的任务

type Task

type Task struct {
	Time         string //执行时间
	Path         string //路径
	Desc         string //描述
	UsedTime     string //执行任务耗时
	LastCallTime int64  //最后一次调用的开始时间
	Count        int    //执行次数
	Running      bool   //执行状态
	ID           int    //任务ID
	Timeout      int64  //超时时间, 如果超过这个时间还没有执行完,则继续执行
	Msg          string //运行时的提示消息
	// contains filtered or unexported fields
}

Task 任务

func GetTasks

func GetTasks() []*Task

GetTasks 获取所有的任务

func (*Task) Cancel

func (m *Task) Cancel()

Cancel 取消任务

func (*Task) ResetReady

func (m *Task) ResetReady()

func (*Task) Run

func (m *Task) Run()

func (*Task) Setup

func (m *Task) Setup()

type Tasks

type Tasks struct {
	Time string
	ID   int
	// contains filtered or unexported fields
}

Tasks 任务组

func (*Tasks) Run

func (m *Tasks) Run()

Run 运行任务

Jump to

Keyboard shortcuts

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