celepar-microservices-grpc
Basic Microservices lib, working with gRPC and Redis.
The idea is take advantage of Redis pub/sub and sets to find available servers and connect directly to them. If you add more services, it will be detected automatically and client will call them. If one or more service fall, the client will try to another.
server.js
const Server = const srv = package: 'helloworld' service: 'Greeter' // You could make diferent services from the same proto file proto: __dirname + '/hello.proto' redis: host: 'localhost' port: 6379 db: 10 let obj = SayHello: asyncctx return message: 'Hello ' + ctxrequestname + ' ' + Date SayBye: asyncctx return message: 'Hello ' + ctxrequestname + ' ' + Date // OR { return { // random response time } } async { return message: 'Hello ' + ctxrequestname + ' ' + Date } srvstart
client.js
const Client = let cli = services: // You could add more services from the same proto file package: 'helloworld' service: 'Greeter' proto: __dirname + '/hello.proto' redis: host: 'localhost' port: 6379 db: 10 start let test = async try let res = await clihelloworldGreeter console catch err console