This API documentation is for Ballerina 1.2.0. View API documentation for the latest release.

Object - task : Scheduler

Represents a ballerina task Scheduler, which can be used to run jobs periodically, using the given configurations.

Constructor

__init

(TimerConfiguration | AppointmentConfiguration configuration)

Methods

Attaches the provided service to the task.

Detaches the provided service from the task.

Starts running the task.

Stops the task.

Pauses the task.

Resumes a paused task.

Checks whether the task listener is started or not.

attach

(service serviceToAttach, any... attachments)

returns SchedulerError?

Attaches the provided service to the task.

Parameters

  • serviceToAttach service
  • Ballerina service object, which needs to be attached to the task

  • attachments any...
  • Set of optional parameters, which need to be passed inside the resources

  • Return Type

    (SchedulerError?)
  • A task:SchedulerError if the process failed due to any reason or else ()

detach

(service attachedService)

returns SchedulerError?

Detaches the provided service from the task.

Parameters

  • attachedService service
  • Ballerina service object, which needs to be detached from the task

  • Return Type

    (SchedulerError?)
  • A task:SchedulerError if the process failed due to any reason or else ()

start

()

returns SchedulerError?

Starts running the task. Task Scheduler will not run until this has been called.

  • Return Type

    (SchedulerError?)
  • A task:SchedulerError if the process failed due to any reason or else ()

stop

()

returns SchedulerError?

Stops the task. This will stop after running the existing jobs.

  • Return Type

    (SchedulerError?)
  • A task:SchedulerError if the process failed due to any reason or else ()

pause

()

returns SchedulerError?

Pauses the task.

  • Return Type

    (SchedulerError?)
  • A task:SchedulerError if an error is occurred while pausing or else ()

resume

()

returns SchedulerError?

Resumes a paused task.

  • Return Type

    (SchedulerError?)
  • A task:SchedulerError when an error occurred while resuming or else ()

isStarted

()

returns boolean

Checks whether the task listener is started or not.

  • Return Type

    (boolean)
  • true if the Scheduler is already started or else false if the Scheduler is not started yet or stopped calling the Scheduler.stop() function