Listener -
task
: Listener
Represents a ballerina task listener, which can be used to schedule and execute tasks periodically.
Constructor
__init
(TimerConfiguration | AppointmentConfiguration configuration)
- configuration TimerConfiguration | AppointmentConfiguration
-
The
task:TimerConfigurationortask:AppointmentConfigurationrecord to define thetask:Listenerbehavior
Methods
Detaches the given service from the task:Listener.
Stops the task:Listener and the attached services gracefully.
Stops the task:Listener and the attached services immediately.
Pauses the task:Listener and the attached services.
Resumes a paused task:Listener.
LifeCycle Methods
Methods
Detaches the given service from the task:Listener.
Parameters
- s service
-
Service to be detached from the listener
-
Return Type
(error?) () or else a
task:ListenerErrorupon failure to detach the service
Stops the task:Listener and the attached services gracefully. It will wait if there are any tasks still to be
completed. This may panic if the stopping causes any error.
-
Return Type
(error?) () or else a
task:ListenerErrorupon failure to stop the listener
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?) () or else a
task:ListenerErrorupon failure to stop the listener
Pauses the task:Listener and the attached services.
-
Return Type
(ListenerError?) A
task:ListenerErrorif an error occurred while pausing or else ()
Resumes a paused task:Listener. Calling this on an already-running task:Listener will not cause any error.
-
Return Type
(ListenerError?) A
task:ListenerErrorif an error occurred while resuming or else ()
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?) () or else a
task:ListenerErrorupon failure to attach the service