npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grpc-inspect

v0.6.0

Published

gRPC protocol buffer inspection utility

Downloads

36,696

Readme

grpc-inspect

npm version build status JavaScript Style Guide License Greenkeeper badge

gRPC Protocol Buffer utility module that generates a descriptor object representing a friendlier descriptor object with utility methods for protocol buffer inspection.

Installation

npm install grpc-inspect

Overview

helloworld.proto

syntax = "proto3";

option java_multiple_files = true;
option java_package = "io.grpc.examples.helloworld";
option java_outer_classname = "HelloWorldProto";
option objc_class_prefix = "HLW";

package helloworld;

service Greeter {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply) {}
}

message HelloRequest {
  string name = 1;
}

message HelloReply {
  string message = 1;
}

Sample usage:

const gi = require('grpc-inspect')
const grpc = require('grpc')
const pbpath = path.resolve(__dirname, './route_guide.proto')
const proto = grpc.load(pbpath)
const d = gi(proto)
console.dir(d)

Returned utility descriptor:

{ namespaces:
   { helloworld:
      { name: 'helloworld',
        messages:
         { HelloRequest:
            { name: 'HelloRequest',
              fields:
               [ { name: 'name',
                   type: 'string',
                   id: 1,
                   required: false,
                   repeated: false,
                   map: false,
                   defaultValue: '' } ] },
           HelloReply:
            { name: 'HelloReply',
              fields:
               [ { name: 'message',
                   type: 'string',
                   id: 1,
                   required: false,
                   repeated: false,
                   map: false,
                   defaultValue: '' } ] } },
        services:
         { Greeter:
            { name: 'Greeter',
              package: 'helloworld',
              methods:
               [ { name: 'SayHello',
                   requestStream: false,
                   responseStream: false,
                   requestName: 'HelloRequest',
                   responseName: 'HelloReply' } ] } } } },
  file: '/Users/me/protos/helloworld.proto',
  options:
   { java_multiple_files: true,
     java_package: 'io.grpc.examples.helloworld',
     java_outer_classname: 'HelloWorldProto',
     objc_class_prefix: 'HLW' } }

NOTE If no package name is specified in the protocol buffer definition an empty '' string is used for the package / namespace name.

API Reference

descriptor : Object

Protocol Buffer utility descriptor represents friendlier descriptor object with utility methods for protocol buffer inspection.

Kind: global class
Access: public

descriptor.namespaceNames() ⇒ Array

Returns an array of namespace names within the protocol buffer definition

Kind: static method of descriptor
Returns: Array - array of names
Example

const grpcinspect = require('grpc-inspect')
const grpc = require('grpc')
const pbpath = path.resolve(__dirname, './route_guide.proto')
const proto = grpc.load(pbpath)
const d = grpcinspect(proto)
console.log(d.namespaceNames()) // ['routeguide']

descriptor.serviceNames(namespace) ⇒ Array

Returns an array of service names

Kind: static method of descriptor
Returns: Array - array of names

| Param | Type | Description | | --- | --- | --- | | namespace | String | Optional name of namespace to get services. If not present returns service names of all services within the definition. |

Example

const grpcinspect = require('grpc-inspect')
const grpc = require('grpc')
const pbpath = path.resolve(__dirname, './route_guide.proto')
const proto = grpc.load(pbpath)
const d = const grpcinspect(proto)
console.log(d.serviceNames()) // ['RouteGuide']

descriptor.service(service) ⇒ Object

Returns the utility descriptor for the service given a servie name. Assumes there are no duplicate service names within the definition.

Kind: static method of descriptor
Returns: Object - service utility descriptor

| Param | Type | Description | | --- | --- | --- | | service | String | name of the service |

Example

const grpcinspect = require('grpc-inspect')
const grpc = require('grpc')
const pbpath = path.resolve(__dirname, './route_guide.proto')
const proto = grpc.load(pbpath)
const d = grpcinspect(proto)
console.dir(d.service('RouteGuide'))

descriptor.methodNames(service) ⇒ Array

Returns an array of method names for a service

Kind: static method of descriptor
Returns: Array - array of names

| Param | Type | Description | | --- | --- | --- | | service | String | name of the service |

Example

const grpcinspect = require('grpc-inspect')
const grpc = require('grpc')
const pbpath = path.resolve(__dirname, './route_guide.proto')
const proto = grpc.load(pbpath)
const d = grpcinspect(proto)
console.log(d.methodNames('RouteGuide')) // [ 'GetFeature', 'ListFeatures', 'RecordRoute', 'RouteChat' ]

descriptor.methods(service) ⇒ Array

Returns an array the utility descriptors for the methods of a service. Assumes there are no duplicate service names within the definition.

Kind: static method of descriptor
Returns: Array - array of method utility descriptors

| Param | Type | Description | | --- | --- | --- | | service | String | name of the service |

Example

const grpcinspect = require('grpc-inspect')
const grpc = require('grpc')
const pbpath = path.resolve(__dirname, './route_guide.proto')
const proto = grpc.load(pbpath)
const d = grpcinspect(proto)
console.dir(d.methods('RouteGuide'))

descriptor.proto() ⇒ Object

Returns the internal proto object

Kind: static method of descriptor
Returns: Object - the internal proto object
Example

const grpcinspect = require('grpc-inspect')
const grpc = require('grpc')
const pbpath = path.resolve(__dirname, './route_guide.proto')
const proto = grpc.load(pbpath)
const d = grpcinspect(proto)
console.dir(d.proto())

descriptor.client(serviceName) ⇒ Object

Gets the gRPC service / client object / function

Kind: static method of descriptor
Returns: Object - the Client object

| Param | Type | Description | | --- | --- | --- | | serviceName | serviceName | The service name. Can and should include package. |

Example

const grpcinspect = require('grpc-inspect')
const grpc = require('grpc')
const pbpath = path.resolve(__dirname, './route_guide.proto')
const proto = grpc.load(pbpath)
const d = grpcinspect(proto)
console.dir(d.client('RouteGuide'))
console.dir(d.client('routeguide.RouteGuide'))

grpcinspect(input) ⇒ Object

Returns protocol buffer utility descriptor. Takes a loaded grpc / protocol buffer object and returns a friendlier descriptor object

Kind: global function
Returns: Object - the utility descriptor

| Param | Type | Description | | --- | --- | --- | | input | Object | loaded proto object |

Example

const gi = require('grpc-inspect')
const grpc = require('grpc')
const pbpath = path.resolve(__dirname, './route_guide.proto')
const proto = grpc.load(pbpath)
const d = gi(proto)
console.dir(d)

License

Apache 2.0