Package com.google.jenkins.plugins.util
Class Executor
java.lang.Object
com.google.jenkins.plugins.util.Executor
- Direct Known Subclasses:
Executor.Default
,MockExecutor
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 ClassesModifier and TypeClassDescriptionstatic class
A default, failure-tolerant implementation of theExecutor
class. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<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 Details
-
Executor
public Executor()
-
-
Method Details
-
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 wrongExecutorException
-
execute
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 wrongExecutorException
-
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.
-