Listener -
task
: Listener
Represents a ballerina task listener, which can be used to schedule and execute tasks periodically.
Constructor
__init
(TimerConfiguration | AppointmentConfiguration configurations)
- configurations TimerConfiguration | AppointmentConfiguration
-
A
task:TimerConfiguration
ortask:AppointmentConfiguration
record to define thetask:Listener
behavior
Methods
Detaches the given service
from the task:Listener
.
Gracefully stops the task:Listener
and the attached services. It will wait if there are any tasks still to be
completed. This may panic if the stopping causes any error.
Stops the task:Listener
and the attached services immediately. This will cancel any ongoing tasks. This may
panic if the stopping causes any error.
Pauses the task:Listener
and the attached services.
Resumes a paused task:Listener
. Calling this on an already running task:Listener
will not cause any error.
LifeCycle Methods
Methods
Detaches the given service
from the task:Listener
.
Parameters
- s service
-
Service to be detached from the listener
-
Return Type
(error?) Returns nil if detaching the service is successful
Gracefully stops the task:Listener
and the attached services. It will wait if there are any tasks still to be
completed. This may panic if the stopping causes any error.
-
Return Type
(error?) Returns nil if stopping the listener is successful
Stops the task:Listener
and the attached services immediately. This will cancel any ongoing tasks. This may
panic if the stopping causes any error.
-
Return Type
(error?) Returns nil if the stopping the listener is successful
Pauses the task:Listener
and the attached services.
-
Return Type
(ListenerError?) Returns
task:ListenerError
if an error is occurred while resuming or nil Otherwise
Resumes a paused task:Listener
. Calling this on an already running task:Listener
will not cause any error.
-
Return Type
(ListenerError?) Returns
task:ListenerError
when an error occurred while pausing or nil Otherwise
LifeCycle Methods
Attaches the given service
to the task:Listener
. This may panic if the service attachment is fails.
Parameters
- s service
-
Service to attach to the listener
- name string? (default ())
-
Name of the service
-
Return Type
(error?) Returns nil if attaching the service is successful