MyGit

gin-middleware/xxl-job-executor

Fork: 11 Star: 35 (更新于 2024-11-01 01:30:15)

license: Apache-2.0

Language: Go .

与xxl-job-executor的集成

最后发布版本: v1.0.0 ( 2020-12-23 16:50:07)

GitHub网址

xxl-job-executor的gin中间件

背景

xxl-job-executor-go是xxl-job的golang执行器,可以独立运行,有时候我们要与项目或者框架(如:gin框架)集成起来合并为一个服务,本项目因此而生。

执行器项目地址

https://github.com/xxl-job/xxl-job-executor-go

与gin集成示例

package main

import (
	"github.com/gin-gonic/gin"
	"github.com/gin-middleware/xxl-job-executor"
	"github.com/xxl-job/xxl-job-executor-go"
	"github.com/xxl-job/xxl-job-executor-go/example/task"
	"log"
)

const Port = "9999"

func main() {
	//初始化执行器
	exec := xxl.NewExecutor(
		xxl.ServerAddr("http://127.0.0.1/xxl-job-admin"),
		xxl.AccessToken(""),            //请求令牌(默认为空)
		xxl.ExecutorIp("127.0.0.1"),    //可自动获取
		xxl.ExecutorPort(Port),         //默认9999(此处要与gin服务启动port必需一至)
		xxl.RegistryKey("golang-jobs"), //执行器名称
	)
	exec.Init()
	defer exec.Stop()
	//添加到gin路由
	r := gin.Default()
	xxl_job_executor_gin.XxlJobMux(r, exec)

	//注册gin的handler
	r.GET("ping", func(cxt *gin.Context) {
		cxt.JSON(200, "pong")
	})

	//注册任务handler
	exec.RegTask("task.test", task.Test)
	exec.RegTask("task.test2", task.Test2)
	exec.RegTask("task.panic", task.Panic)

	log.Fatal(r.Run(":" + Port))
}

最近版本更新:(数据更新于 2024-09-06 11:54:54)

2020-12-23 16:50:07 v1.0.0

主题(topics):

xxl-job, xxljob, xxljobexecutor

gin-middleware/xxl-job-executor同语言 Go最近更新仓库

2024-11-22 20:14:47 daytonaio/daytona

2024-11-22 15:17:23 SagerNet/sing-box

2024-11-21 22:49:20 containerd/containerd

2024-11-21 13:50:50 XTLS/Xray-core

2024-11-21 07:36:18 kubernetes/kubernetes

2024-11-21 06:27:30 ollama/ollama