Listener: Listener
The server listener of which one or more services can be registered so that the Ballerina program can offer a service through this listener.
Constructor
Gets called when the endpoint is being initialized during the module init time.
1listener grpc:Listener listenerEp = new (9092);
init (int port, *ListenerConfiguration config)
- port int
The listener port
- config *ListenerConfiguration
The listener endpoint configuration
LifeCycle Methods
attach | Gets called every time a service attaches itself to this endpoint - also happens at module init time. |
Methods
'start | Starts the registered service. |
gracefulStop | Stops the service listener gracefully. |
immediateStop | Stops the registered service. |
detach | Detaches an HTTP or WebSocket service from the listener. |
attach
Gets called every time a service attaches itself to this endpoint - also happens at module init time.
1error? result = listenerEp.attach(helloService);
Parameters
- grpcService Service
The type of the service to be registered
gracefulStop
function gracefulStop() returns error?
Stops the service listener gracefully. Already-accepted requests will be served before the connection closure.
1error? result = listenerEp.gracefulStop();
detach
Detaches an HTTP or WebSocket service from the listener. Note that detaching a WebSocket service would not affect the functionality of the existing connections.
1error? result = listenerEp.detach(helloService);
Parameters
- grpcService Service
The service to be detached