Package ai.preferred.venom.job
Class Job
- java.lang.Object
-
- ai.preferred.venom.job.Job
-
public class Job extends 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 HandlergetHandler()Get the handler to handle the response of the job.<T extends JobAttribute>
TgetJobAttribute(Class<T> clazz)Get the job attribute for a specific attribute class or returnnullif not found.@NotNull RequestgetRequest()Get the request of this job.intgetTryCount()Get attempt number of this job.voidprepareRetry()This method is called before the job is scheduled for a retry.JobsetJobAttribute(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(Class<T> clazz)
Get the job attribute for a specific attribute class or returnnullif 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.
-
-