接口 Worker
-
- 所有已知实现类:
AnnotatedWorker
,DynamicForkWorker
public interface Worker
-
-
字段概要
字段 修饰符和类型 字段 说明 static org.slf4j.Logger
logger
-
方法概要
所有方法 静态方法 实例方法 抽象方法 默认方法 修饰符和类型 方法 说明 static Worker
create(String taskType, Function<ExecutingTask,TaskExecResult> executor)
TaskExecResult
execute(ExecutingTask task)
Executes a task and returns the updated task.default int
getBatchPollTimeoutInMS()
default String
getIdentity()
Override this method to app specific rules.default int
getPollingInterval()
Override this method to change the interval between polls.String
getTaskDefName()
Retrieve the name of the task definition the worker is currently working on.default boolean
leaseExtendEnabled()
default void
onErrorUpdate(ExecutingTask task)
Called when the task coordinator fails to update the task to the server.default boolean
paused()
Override this method to pause the worker from polling.
-
-
-
方法详细资料
-
getTaskDefName
String getTaskDefName()
Retrieve the name of the task definition the worker is currently working on.- 返回:
- the name of the task definition.
-
execute
TaskExecResult execute(ExecutingTask task)
Executes a task and returns the updated task.- 参数:
task
- Task to be executed.- 返回:
- the
TaskExecResult
object If the task is not completed yet, return with the status as IN_PROGRESS.
-
onErrorUpdate
default void onErrorUpdate(ExecutingTask task)
Called when the task coordinator fails to update the task to the server. Client should store the task id (in a database) and retry the update later- 参数:
task
- Task which cannot be updated back to the server.
-
paused
default boolean paused()
Override this method to pause the worker from polling.- 返回:
- true if the worker is paused and no more tasks should be polled from server.
-
getIdentity
default String getIdentity()
Override this method to app specific rules.- 返回:
- returns the serverId as the id of the instance that the worker is running.
-
getPollingInterval
default int getPollingInterval()
Override this method to change the interval between polls.- 返回:
- interval in millisecond at which the server should be polled for worker tasks.
-
leaseExtendEnabled
default boolean leaseExtendEnabled()
-
getBatchPollTimeoutInMS
default int getBatchPollTimeoutInMS()
-
create
static Worker create(String taskType, Function<ExecutingTask,TaskExecResult> executor)
-
-