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

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

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