Class Executor

  • Direct Known Subclasses:
    Executor.Default, MockExecutor

    public abstract class Executor
    extends Object
    Interface for a class that executes requests on behalf of a Json API client.

    NOTE: This can be used to intercept or mock all "execute" requests.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Executor.Default
      A default, failure-tolerant implementation of the Executor class.
    • Constructor Summary

      Constructors 
      Constructor Description
      Executor()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      <T> T execute​(com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest<T> request)
      Executes the request, returning a response of the appropriate type.
      abstract <T> T execute​(RequestCallable<T> request)
      Executes the request, returning a response of the appropriate type.
      void sleep()
      Surface this as a canonical means by which to sleep, so that clients can layer their own retry logic on top of the executor using the same sleep facility;
      void sleep​(int retryAttempt)
      Surface this as a canonical means by which to sleep, so that clients can layer their own retry logic on top of the executor using the same sleep facility;
    • Constructor Detail

      • Executor

        public Executor()
    • Method Detail

      • execute

        public <T> T execute​(com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest<T> request)
                      throws IOException,
                             ExecutorException
        Executes the request, returning a response of the appropriate type.
        Type Parameters:
        T - The type of the expected response
        Parameters:
        request - The request we are issuing
        Returns:
        a Json object of the given type
        Throws:
        IOException - if anything goes wrong
        ExecutorException
      • execute

        public abstract <T> T execute​(RequestCallable<T> request)
                               throws IOException,
                                      ExecutorException
        Executes the request, returning a response of the appropriate type.
        Type Parameters:
        T - The type of the expected response
        Parameters:
        request - The request we are issuing
        Returns:
        a Json object of the given type
        Throws:
        IOException - if anything goes wrong
        ExecutorException
      • sleep

        public void sleep()
        Surface this as a canonical means by which to sleep, so that clients can layer their own retry logic on top of the executor using the same sleep facility;
      • sleep

        public void sleep​(int retryAttempt)
        Surface this as a canonical means by which to sleep, so that clients can layer their own retry logic on top of the executor using the same sleep facility;
        Parameters:
        retryAttempt - indicates how many times we had retried, to allow for increasing back-off time.