ballerina.task package

public function scheduleAppointment ( function()returns(error) onTrigger , function(error) onError , string scheduleCronExpression ) ( string taskId , error e )

Schedules an appointment task

Parameter Name Data Type Description
onTrigger function()returns(error) The function which gets called when the appointment falls due
onError function(error) The function that gets called if the onTrigger function returns an error
scheduleCronExpression string Specifies the Cron expression of the schedule

Return Variable Data Type Description
taskId string The unique ID of the appointment task that was scheduled
e error This error will be returned if an occurs while scheduling the appointment task

public function scheduleTimer ( function()returns(error) onTrigger , function(error) onError , struct {int delay, int interval} schedule ) ( string taskId , error e )

Schedules a timer task

Parameter Name Data Type Description
onTrigger function()returns(error) The function which gets called when the timer goes off
onError function(error) The function that gets called if the onTrigger function returns an error
schedule struct {int delay, int interval} Specifies the initial delay and interval of the timer task

Return Variable Data Type Description
taskId string The unique ID of the timer task that was scheduled
e error This error will be returned if an occurs while scheduling the timer task

public function stopTask ( string taskID ) ( error )

Stops the timer task with ID taskID

Parameter Name Data Type Description
taskID string The unique ID of the timer task that has to be stopped

Return Variable Data Type Description
error This error will be returned if an error occurs while stopping the task