GrpcServer

GrpcServer

gRPC server will be the entry point to your microservice

Constructor

new GrpcServer(config)

Source:
Parameters:
Name Type Description
config object
Name Type Attributes Description
host string

Server host

port number

Server port

services Array.<GrpcService>

Array of GrpcService derived classes to be exposed

onConnected function <optional>

Function to be executed after server connection

onStart function <optional>

Function to be executed before server start (ex. db connection)

onClose function <optional>

Function to be executed before server shutdown (ex. close db connection)

Example
const server = new GrpcServer({
	host: 'localhost',
	port: 5000,
	services: [
		UsersService
	],
	onStart: async () => {
		return database.connect();
	},
	onConnected: () => {
		console.log('Users service is up');
	}
});
server.start(); 

Members

server

Get original gRPC server object

Source:

Methods

(async, private) _initialize()

Initialize and register services

Source:

(async) shutdown()

Shutdown gRPC server

Source:

(async) start()

Start gRPC server

Source: