Listener: Listener

Represents a Subscriber Service listener endpoint.

Constructor

Initiliazes websub:Listener instance.

1listener websub:Listener websubListenerEp = check new (9090);
init (int | Listener listenTo, *ListenerConfiguration config)
  • listenTo int | Listener
  • Port number or a http:Listener instance

  • config *ListenerConfiguration
  • Custom websub:ListenerConfiguration to be provided to underlying HTTP Listener

LifeCycle Methods

attach

Attaches the provided websub:SubscriberService to the websub:Listener.

Methods

attachWithConfig

Attaches the provided Service to the websub:Listener with custom websub:SubscriberServiceConfiguration.

detach

Detaches the provided websub:SubscriberService from the websub:Listener.

'start

Starts the registered service programmatically..

gracefulStop

Stops the service listener gracefully.

immediateStop

Stops the service listener immediately.

attach

function attach(SubscriberService subscriberService, string[ ] | string? name) returns Error?
Isolated Function

Attaches the provided websub:SubscriberService to the websub:Listener.

1check websubListenerEp.attach('service, "/subscriber");

Parameters

  • name string[ ] | string? (default ())
  • The path of the Service to be hosted

Return Type

(Error?)

An websub:Error, if an error occurred during the service attaching process or else ()

attachWithConfig

function attachWithConfig(SubscriberService subscriberService, SubscriberServiceConfiguration configuration, string[ ] | string? name) returns Error?
Isolated Function

Attaches the provided Service to the websub:Listener with custom websub:SubscriberServiceConfiguration.

1check websubListenerEp.attachWithConfig('service, {
2 target: "http://0.0.0.0:9191/common/discovery",
3 leaseSeconds: 36000
4}, "/subscriber");

Parameters

  • name string[ ] | string? (default ())
  • The path of the Service to be hosted

Return Type

(Error?)

An websub:Error, if an error occurred during the service attaching process or else ()

detach

function detach(SubscriberService s) returns Error?
Isolated Function

Detaches the provided websub:SubscriberService from the websub:Listener.

1check websubListenerEp.detach('service);

Parameters

Return Type

(Error?)

An websub:Error, if an error occurred during the service detaching process or else ()

'start

function 'start() returns Error?
Isolated Function

Starts the registered service programmatically..

1check websubListenerEp.'start();

Return Type

(Error?)

An websub:Error, if an error occurred during the listener starting process or else ()

gracefulStop

function gracefulStop() returns Error?
Isolated Function

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

1check websubListenerEp.gracefulStop();

Return Type

(Error?)

An websub:Error, if an error occurred during the listener stopping process or else ()

immediateStop

function immediateStop() returns Error?
Isolated Function

Stops the service listener immediately.

1check websubListenerEp.immediateStop();

Return Type

(Error?)

An websub:Error, if an error occurred during the listener stopping process or else ()