Listener: Listener

This is used for creating HTTP server endpoints. An HTTP server endpoint is capable of responding to remote callers. The Listener is responsible for initializing the endpoint using the provided configurations.

Constructor

Gets invoked during module initialization to initialize the listener.

init (int port, ListenerConfiguration? config)
  • port int
  • Listening port of the HTTP service listener

LifeCycle Methods

attach

Attaches a service to the listener.

Methods

'start

Starts the registered service programmatically.

gracefulStop

Stops the service listener gracefully.

immediateStop

Stops the service listener immediately.

detach

Detaches a Http service from the listener.

getPort

Retrieves the port of the HTTP listener.

getConfig

Retrieves the ListenerConfiguration of the HTTP listener.

attach

function attach(Service s, string[ ] | string? name) returns error?
Isolated Function

Attaches a service to the listener.

Parameters

  • s Service
  • The service that needs to be attached

Return Type

(error?)

An error an error occurred during the service attachment process or else nil

'start

function 'start() returns error?
Isolated Function

Starts the registered service programmatically.

Return Type

(error?)

An error if an error occurred during the listener starting process

gracefulStop

function gracefulStop() returns error?
Isolated Function

Stops the service listener gracefully. Already-accepted requests will be served before connection closure.

Return Type

(error?)

An error if an error occurred during the listener stopping process

immediateStop

function immediateStop() returns error?
Isolated Function

Stops the service listener immediately. It is not implemented yet.

Return Type

(error?)

An error if an error occurred during the listener stop process

detach

function detach(Service s) returns error?
Isolated Function

Detaches a Http service from the listener.

Parameters

  • s Service
  • The service to be detached

Return Type

(error?)

An error if one occurred during detaching of a service or else ()

getPort

function getPort() returns int
Isolated Function

Retrieves the port of the HTTP listener.

Return Type

(int)

The HTTP listener port

getConfig

function getConfig() returns readonly & ListenerConfiguration
Isolated Function

Retrieves the ListenerConfiguration of the HTTP listener.

Return Type

(readonly & ListenerConfiguration)

The readonly HTTP listener configuration