Listener - task : Listener

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

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?)
  • Returns nil if detaching the service is successful

__gracefulStop

()

returns error?

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

__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?)
  • Returns nil if the stopping the listener is successful

pause

()

returns ListenerError?

Pauses the task:Listener and the attached services.

  • Return Type

    (ListenerError?)
  • Returns task:ListenerError if an error is occurred while resuming or nil Otherwise

resume

()

returns ListenerError?

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

__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?)
  • Returns nil if attaching the service is successful

__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?)
  • Returns nil if strating the services is successful