Skip to content

An example grpc app I'm building to learn the framework

License

Notifications You must be signed in to change notification settings

dills122/grpc-playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gRPC Tooling & Utils

CodeFactor

gRPC tooling to help simplify some of the tasks required by the framework.

Current Features:

  • ClientFactory - Builds a client for a given service and proto
  • SeverFactory - Builds a server for all the needed services and protos

This allows for some cleaner and more organized code since all of your service definitions are within a config.

Example Service config

{
    "protoDefinitionPath": "protos",
    "Services": {
        "FirstService": {
            "protoPath": "/path/to/proto.proto",
            "namespace": "namespace",
            "serviceName": "ServiceName"
        }
    }
}

Using Server Factory

const { createServer } = require("grpc-tooling");
const config = require("path/to/service/config");

createServer
  .serverFactory(config)
  .then(() => {
    //Run any tasks needed once the server is started
  })
  .catch((err) => {
    //Handle server error
  });

Using Client Factory

const { clientFactory } = require("grpc-tooling");
const config = require("path/to/service/config");

const { ClientService } = config.Services;
clientFactory(
  ClientService.protoPath,
  ClientService.serviceName,
  ClientService.namespace
)
  .then((client) => {})
  .catch((err) => {
    console.log(err);
    process.exit(1);
  });

About

An example grpc app I'm building to learn the framework

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published