Interface Worker
public interface Worker
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Workercreate(String taskType, Function<Task, TaskResult> executor) Executes a task and returns the updated task.default StringOverride this method to app specific rules.default intOverride this method to change the interval between polls.Retrieve the name of the task definition the worker is currently working on.default booleandefault voidonErrorUpdate(Task task) Called when the task coordinator fails to update the task to the server.default booleanpaused()Override this method to pause the worker from polling.
-
Field Details
-
PROP_DOMAIN
- See Also:
-
PROP_ALL_WORKERS
- See Also:
-
PROP_LOG_INTERVAL
- See Also:
-
PROP_POLL_INTERVAL
- See Also:
-
PROP_LEASE_EXTEND_ENABLED
- See Also:
-
PROP_PAUSED
- See Also:
-
-
Method Details
-
getTaskDefName
String getTaskDefName()Retrieve the name of the task definition the worker is currently working on.- Returns:
- the name of the task definition.
-
execute
Executes a task and returns the updated task.- Parameters:
task- Task to be executed.- Returns:
- the
TaskResultobject If the task is not completed yet, return with the status as IN_PROGRESS.
-
onErrorUpdate
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- Parameters:
task- Task which cannot be updated back to the server.
-
paused
default boolean paused()Override this method to pause the worker from polling.- Returns:
- true if the worker is paused and no more tasks should be polled from server.
-
getIdentity
Override this method to app specific rules.- Returns:
- 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.- Returns:
- interval in millisecond at which the server should be polled for worker tasks.
-
leaseExtendEnabled
default boolean leaseExtendEnabled() -
create
-