Listener - grpc : Listener

Represents server listener where one or more services can be registered. so that ballerina program can offer service through this listener.

Constructor

__init

(int port, ListenerConfiguration? config)

  • port int
  • Listener port

Methods

Stops the service listener gracefully. Already-accepted requests will be served before the connection closure.
 error? result = listenerEp.__gracefulStop();
Stops the registered service.
 error? result = listenerEp.__immediateStop();
Detaches an HTTP or WebSocket service from the listener. Note that detaching a WebSocket service would not affect the functionality of the existing connections.
 error? result = listenerEp.__detach(helloService);

LifeCycle Methods

Starts the registered service.
 error? result = listenerEp.__start();
Gets called every time a service attaches itself to this endpoint - also happens at module init time.
 error? result = listenerEp.__attach(helloService);

Methods

__gracefulStop

()

returns error?
Stops the service listener gracefully. Already-accepted requests will be served before the connection closure.
 error? result = listenerEp.__gracefulStop();
  • Return Type

    (error?)
  • An error if an error occurred during the listener stopping process or else ()

__immediateStop

()

returns error?
Stops the registered service.
 error? result = listenerEp.__immediateStop();
  • Return Type

    (error?)
  • An error if an error occurs while stopping the server or else ()

__detach

(service s)

returns error?
Detaches an HTTP or WebSocket service from the listener. Note that detaching a WebSocket service would not affect the functionality of the existing connections.
 error? result = listenerEp.__detach(helloService);

Parameters

  • s service
  • The service to be detached

  • Return Type

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

LifeCycle Methods

__start

()

returns error?
Starts the registered service.
 error? result = listenerEp.__start();
  • Return Type

    (error?)
  • An error if an error occurs while starting the server or else ()

__attach

(service s, string? name)

returns error?
Gets called every time a service attaches itself to this endpoint - also happens at module init time.
 error? result = listenerEp.__attach(helloService);

Parameters

  • s service
  • The type of the service to be registered

  • name string? (default ())
  • Name of the service

  • Return Type

    (error?)
  • An error if encounters an error while attaching the service or else ()