Class AsyncOperations

java.lang.Object
ai.docling.serve.client.operations.AsyncOperations
Direct Known Subclasses:
ChunkOperations, ConvertOperations

public abstract class AsyncOperations extends Object
Abstract base class for managing asynchronous operations, providing methods to execute tasks asynchronously and poll for their status until completion. Subclasses must implement specific logic for retrieving task results.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AsyncOperations(HttpOperations httpOperations, ai.docling.serve.api.DoclingServeTaskApi taskApi, Duration asyncPollInterval, Duration asyncTimeout)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected <I, O> CompletionStage<O>
    executeAsync(I request, String uri)
    Executes an asynchronous operation by sending a request to the specified URI and polling for the task completion.
    protected abstract <O> O
    getTaskResult(ai.docling.serve.api.task.request.TaskResultRequest taskResultRequest)
    Retrieves the result of a task based on the provided task result request.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AsyncOperations

      protected AsyncOperations(HttpOperations httpOperations, ai.docling.serve.api.DoclingServeTaskApi taskApi, Duration asyncPollInterval, Duration asyncTimeout)
  • Method Details

    • getTaskResult

      protected abstract <O> O getTaskResult(ai.docling.serve.api.task.request.TaskResultRequest taskResultRequest)
      Retrieves the result of a task based on the provided task result request. This method is abstract and meant to be implemented by subclasses. It uses the information provided in the TaskResultRequest to obtain the result of the task execution.
      Type Parameters:
      O - the type of the result object returned
      Parameters:
      taskResultRequest - the request containing the details, including the task ID, required to retrieve the task result
      Returns:
      the result of the task execution, of the type O
    • executeAsync

      protected <I, O> CompletionStage<O> executeAsync(I request, String uri)
      Executes an asynchronous operation by sending a request to the specified URI and polling for the task completion. This method uses an HTTP POST operation to start the task and then repeatedly polls the task status to determine when the operation is complete.
      Type Parameters:
      I - the type of the request object being sent
      O - the type of the response object returned upon completion
      Parameters:
      request - the request object containing the data necessary to initialize the task
      uri - the endpoint URI to which the request will be sent
      Returns:
      a CompletionStage that will be completed with the result of the asynchronous operation