This API documentation is for Ballerina 1.2.0. View API documentation for the latest release.

Listener - task : Listener

Represents a ballerina task listener, which can be used to schedule and execute tasks periodically.

Constructor

__init

(TimerConfiguration | AppointmentConfiguration configuration)

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

Attaches the given service to the task:Listener.

Starts dispatching the services attached to the task:Listener.

Methods

__detach

(service s)

returns error?

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:ListenerError upon failure to detach the service

__gracefulStop

()

returns error?

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:ListenerError upon failure to stop the listener

__immediateStop

()

returns 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.

  • Return Type

    (error?)
  • () or else a task:ListenerError upon failure to stop the listener

pause

()

returns ListenerError?

Pauses the task:Listener and the attached services.

  • Return Type

    (ListenerError?)
  • A task:ListenerError if an error occurred while pausing or else ()

resume

()

returns ListenerError?

Resumes a paused task:Listener. Calling this on an already-running task:Listener will not cause any error.

  • Return Type

    (ListenerError?)
  • A task:ListenerError if an error occurred while resuming or else ()

LifeCycle Methods

__attach

(service s, string? name)

returns error?

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:ListenerError upon failure to attach the service

__start

()

returns error?

Starts dispatching the services attached to the task:Listener. This may panic if the service dispatching causes any error.

  • Return Type

    (error?)
  • () or else a task:ListenerError upon failure to start the listener