Functions
configureWorkerPool | I Configure the scheduler worker pool. |
getRunningJobs | I Gets all the running jobs. |
getTimeInMillies | I Gets time in milliseconds of the given |
pauseAllJobs | I Pauses all the jobs. |
pauseJob | I Pauses the particular job. |
resumeAllJobs | I Resumes all the jobs. |
resumeJob | I Resumes the particular job. |
scheduleJobRecurByFrequency | I Schedule the recurring |
scheduleOneTimeJob | I Schedule the given |
unscheduleJob | I Unschedule the |
configureWorkerPool
Configure the scheduler worker pool.
1check task:configureWorkerPool(4, 7);
Parameters
- workerCount int (default 5)
Specifies the number of workers that are available for the concurrent execution of jobs. It should be a positive integer. The recommendation is to set a value less than 10. Default sets to 5.
- waitingTime Seconds (default 5)
The number of seconds as a decimal the scheduler will tolerate a trigger to pass its next-fire-time
before being considered as ignored the trigger
.
getRunningJobs
function getRunningJobs() returns JobId[ ]
Gets all the running jobs.
1task:JobId[] result = task:getRunningJobs();
getTimeInMillies
Gets time in milliseconds of the given time:Civil
.
Parameters
- time Civil
The Ballerina time:Civil
pauseAllJobs
function pauseAllJobs() returns Error?
Pauses all the jobs.
1check task:pauseAllJobs();
pauseJob
Pauses the particular job.
1check task:pauseJob(jobId);
Parameters
- jobId JobId
The ID of the job as a task:JobId
, which needs to be paused
resumeAllJobs
function resumeAllJobs() returns Error?
Resumes all the jobs.
1check task:resumeAllJobs();
resumeJob
Resumes the particular job.
1check task:resumeJob(jobId);
Parameters
- jobId JobId
The ID of the job as a task:JobId
, which needs to be resumed
scheduleJobRecurByFrequency
function scheduleJobRecurByFrequency(Job job, decimal interval, int maxCount, Civil? startTime, Civil? endTime, TaskPolicy taskPolicy) returns JobId | Error
Schedule the recurring task:Job
according to the given duration. Once scheduled, it will return the job ID, which
can be used to manage the job.
1task:JobId jobId = check task:scheduleJobRecurByFrequency(new Job(), 3);
Parameters
- job Job
Ballerina job, which is to be executed by the scheduler.
- interval decimal
The duration of the trigger (in seconds), which is used to run the job frequently
- maxCount int (default -1)
The maximum number of trigger counts
- startTime Civil? (default ())
The trigger start time in Ballerina time:Civil
. If it is not provided, a trigger will
start immediately
- endTime Civil? (default ())
The trigger end time in Ballerina time:Civil
- taskPolicy TaskPolicy (default {})
The policy, which is used to handle the error and will be waiting during the trigger time
scheduleOneTimeJob
Schedule the given task:Job
for the given time. Once scheduled, it will return a job ID, which can be used to manage
the job.
1time:Utc newTime = time:utcAddSeconds(time:utcNow(), 3);2time:Civil time = time:utcToCivil(newTime);3task:JobId jobId = check task:scheduleOneTimeJob(new Job(), time);
unscheduleJob
Unschedule the task:Job
, which is associated with the given job ID. If no job is running in the scheduler,
the scheduler will be shut down automatically.
1check task:unscheduleJob(jobId);
Parameters
- jobId JobId
The ID of the job as a task:JobId
, which needs to be unscheduled