Interface Worker


public interface Worker
  • Field Details

  • 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

      TaskResult execute(Task task)
      Executes a task and returns the updated task.
      Parameters:
      task - Task to be executed.
      Returns:
      the TaskResult object If the task is not completed yet, return with the status as IN_PROGRESS.
    • onErrorUpdate

      default void onErrorUpdate(Task 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
      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

      default String 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

      static Worker create(String taskType, Function<Task,TaskResult> executor)