Skip to content

Commit

Permalink
支持外部路由(可与gin集成)
Browse files Browse the repository at this point in the history
  • Loading branch information
rushuinet committed Dec 23, 2020
1 parent 8f93276 commit 239b211
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
8.失败重试次数(在参数param中,目前由任务自行处理)
9.可自定义日志
10.自定义日志查看handler
11.支持外部路由(可与gin集成)
```

# Example
Expand Down Expand Up @@ -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配置
### 添加执行器
执行器管理->新增执行器,执行器列表如下:
Expand Down
22 changes: 22 additions & 0 deletions executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
}

0 comments on commit 239b211

Please sign in to comment.