grpc.server
a simple abstraction around grpc.Server
api
const server = require('grpc.server')
- server(an optional {})
- address string with the format
url:port
- credentials can use
credentials.createInsecure
or with certificates through an object { key, server }, passed as a Buffer - metadata set metadata that can be used in all calls, an array with { key: value }
- address string with the format
methods
- addServices(an array with the services object)
- package proto package name
- name service name
- proto proto file
- methods an object with the methods
- start(callback function)
- stop(callback function)
note: you can use unary
, stream
or bidirecional
since the comm type should be handled on the proto files and in the methods
example
const server = // proto file/*syntax = "proto3"; package helloWorld; // The greeting service definition.service Greeter { // Sends a greeting rpc sayHello (HelloRequest) returns (HelloReply) {}} // The request message containing the user's name.message HelloRequest { string name = 1;} // The response message containing the greetingsmessage HelloReply { string message = 1;}*/ const serverA = const services = proto: protoshelloWorld package: 'helloWorld' name: 'Greeter' methods: sayHello: sayHello serverA // to stop the serverserverA