Ballerina API Documentation

Functions of ballerina.task package

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

Schedules an appointment task

Parameters:

Parameter NameData TypeDescription
onTriggerfunction()returns(error)The function which gets called when the appointment falls due
onErrorfunction(error)The function that gets called if the onTrigger function returns an error
scheduleCronExpressionstringSpecifies the Cron expression of the schedule

Return Parameters:

Return VariableData TypeDescription
taskIdstringstring: The unique ID of the appointment task that was scheduled
eerrorstring: The unique ID of the appointment task that was scheduled

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

Schedules a timer task

Parameters:

Parameter NameData TypeDescription
onTriggerfunction()returns(error)The function which gets called when the timer goes off
onErrorfunction(error)The function that gets called if the onTrigger function returns an error
schedulestruct {int delay, int interval}Specifies the initial delay and interval of the timer task

Return Parameters:

Return VariableData TypeDescription
taskIdstringstring: The unique ID of the timer task that was scheduled
eerrorstring: The unique ID of the timer task that was scheduled

public function stopTask(string taskID) (error)

Stops the timer task with ID taskID

Parameters:

Parameter NameData TypeDescription
taskIDstringThe unique ID of the timer task that has to be stopped

Return Parameters:

Return VariableData TypeDescription
errorerror: This error will be returned if an error occurs while stopping the task


Menu

  • Functions
    • scheduleAppointment(function()returns(error) onTrigger, function(error) onError, string scheduleCronExpression) (string taskId, error e)
    • scheduleTimer(function()returns(error) onTrigger, function(error) onError, struct {int delay, int interval} schedule) (string taskId, error e)
    • stopTask(string taskID) (error )

Copyright 2017 Ballerina API Documentation