-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6489cd8
commit 1611d75
Showing
6 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/test/java/io/github/artlibs/testsupport/PowerJobCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.github.artlibs.testsupport; | ||
|
||
import tech.powerjob.worker.core.processor.ProcessResult; | ||
import tech.powerjob.worker.core.processor.TaskContext; | ||
import tech.powerjob.worker.core.processor.sdk.BasicProcessor; | ||
|
||
public class PowerJobCase implements BasicProcessor, Injected { | ||
@Override | ||
public ProcessResult process(TaskContext context) throws Exception { | ||
graspInjected(); | ||
return new ProcessResult(true); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/test/java/tech/powerjob/worker/core/processor/ProcessResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package tech.powerjob.worker.core.processor; | ||
|
||
public class ProcessResult { | ||
|
||
private boolean success = false; | ||
|
||
private String msg; | ||
|
||
public ProcessResult(boolean success) { | ||
this.success = success; | ||
} | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
src/test/java/tech/powerjob/worker/core/processor/TaskContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package tech.powerjob.worker.core.processor; | ||
|
||
public class TaskContext { | ||
} |
23 changes: 23 additions & 0 deletions
23
src/test/java/tech/powerjob/worker/core/processor/sdk/BasicProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package tech.powerjob.worker.core.processor.sdk; | ||
|
||
import tech.powerjob.worker.core.processor.ProcessResult; | ||
import tech.powerjob.worker.core.processor.TaskContext; | ||
|
||
/** | ||
* 基础的处理器,适用于单机执行 | ||
* | ||
* @author tjq | ||
* @since 2020/3/18 | ||
*/ | ||
public interface BasicProcessor { | ||
|
||
/** | ||
* 核心处理逻辑 | ||
* 可通过 {@link TaskContext#getWorkflowContext()} 方法获取工作流上下文 | ||
* | ||
* @param context 任务上下文,可通过 jobParams 和 instanceParams 分别获取控制台参数和OpenAPI传递的任务实例参数 | ||
* @return 处理结果,msg有长度限制,超长会被裁剪,不允许返回 null | ||
* @throws Exception 异常,允许抛出异常,但不推荐,最好由业务开发者自己处理 | ||
*/ | ||
ProcessResult process(TaskContext context) throws Exception; | ||
} |