diff --git a/README.md b/README.md index 62dc910..90e4806 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ 8.失败重试次数(在参数param中,目前由任务自行处理) 9.可自定义日志 10.自定义日志查看handler +11.支持外部路由(可与gin集成) ``` # Example @@ -62,8 +63,10 @@ func (l *logger) Error(format string, a ...interface{}) { log.Println(fmt.Sprintf("自定义日志 - "+format, a...)) } ``` -# see +# 示例项目 github.com/xxl-job/xxl-job-executor-go/example/ +# 与gin框架集成 +https://github.com/gin-middleware/xxl-job-executor # xxl-job-admin配置 ### 添加执行器 执行器管理->新增执行器,执行器列表如下: diff --git a/executor.go b/executor.go index edc32f9..a6d596c 100644 --- a/executor.go +++ b/executor.go @@ -22,6 +22,13 @@ type Executor interface { LogHandler(handler LogHandler) //注册任务 RegTask(pattern string, task TaskFunc) + //运行任务 + RunTask(writer http.ResponseWriter, request *http.Request) + //杀死任务 + KillTask(writer http.ResponseWriter, request *http.Request) + //任务日志 + TaskLog(writer http.ResponseWriter, request *http.Request) + //运行服务 Run() error } @@ -287,3 +294,18 @@ func (e *executor) post(action, body string) (resp *http.Response, err error) { } return client.Do(request) } + +//runTask +func (e *executor) RunTask(writer http.ResponseWriter, request *http.Request) { + e.runTask(writer, request) +} + +//killTask +func (e *executor) KillTask(writer http.ResponseWriter, request *http.Request) { + e.killTask(writer, request) +} + +//taskLog +func (e *executor) TaskLog(writer http.ResponseWriter, request *http.Request) { + e.taskLog(writer, request) +}