Package ai.preferred.venom.job
Class Job
- java.lang.Object
-
- ai.preferred.venom.job.Job
-
public class Job extends java.lang.Object
This class will be placed in a scheduler for queuing requests.- Author:
- Maksim Tkachenko, Ween Jiann Lee
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Handler
getHandler()
Get the handler to handle the response of the job.<T extends JobAttribute>
TgetJobAttribute(java.lang.Class<T> clazz)
Get the job attribute for a specific attribute class or returnnull
if not found.@NotNull Request
getRequest()
Get the request of this job.int
getTryCount()
Get attempt number of this job.void
prepareRetry()
This method is called before the job is scheduled for a retry.Job
setJobAttribute(JobAttribute jobAttribute)
Adds or replace the current job attribute if the class of attribute is already present in the map.
-
-
-
Constructor Detail
-
Job
public Job(@NotNull @NotNull Request request, Handler handler, @NotNull @NotNull JobAttribute... jobAttributes)
Constructs a basic job.- Parameters:
request
- The request of this job.handler
- The handler of this job.jobAttributes
- attributes to insert to the job.
-
Job
public Job(@NotNull @NotNull Request request, Handler handler)
Constructs a basic job.- Parameters:
request
- The request of this job.handler
- The handler of this job.
-
Job
public Job(@NotNull @NotNull Request request)
Constructs a basic job.- Parameters:
request
- The request of this job.
-
-
Method Detail
-
getRequest
@NotNull public final @NotNull Request getRequest()
Get the request of this job.- Returns:
- Request of the job.
-
getHandler
@Nullable public final Handler getHandler()
Get the handler to handle the response of the job.If handler is null, routed handler will be used to assign a handler to the response, based on its criteria.
- Returns:
- Handler for the response or null.
-
getTryCount
public final int getTryCount()
Get attempt number of this job.- Returns:
- Attempt (try) count of the job.
-
prepareRetry
public final void prepareRetry()
This method is called before the job is scheduled for a retry.This method allows you to specify the logic to move the job into its subsequent state for a retry.
-
setJobAttribute
public final Job setJobAttribute(JobAttribute jobAttribute)
Adds or replace the current job attribute if the class of attribute is already present in the map.- Parameters:
jobAttribute
- the job attribute to add or replace.- Returns:
- this.
-
getJobAttribute
public final <T extends JobAttribute> T getJobAttribute(java.lang.Class<T> clazz)
Get the job attribute for a specific attribute class or returnnull
if not found.- Type Parameters:
T
- the class of attribute to find.- Parameters:
clazz
- the class of attribute to find.- Returns:
- an instance of job attribute for class or null.
-
-