-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathreadme.hbs
108 lines (87 loc) · 3.03 KB
/
readme.hbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# grpc-inspect
[![npm version](https://img.shields.io/npm/v/grpc-inspect.svg?style=flat-square)](https://www.npmjs.com/package/grpc-inspect)
[![build status](https://img.shields.io/travis/bojand/grpc-inspect/master.svg?style=flat-square)](https://travis-ci.org/bojand/grpc-inspect)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](https://standardjs.com)
[![License](https://img.shields.io/github/license/bojand/grpc-inspect.svg?style=flat-square)](https://raw.githubusercontent.com/bojand/grpc-inspect/master/LICENSE)
[![Greenkeeper badge](https://badges.greenkeeper.io/bojand/grpc-inspect.svg)](https://greenkeeper.io/)
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:
```js
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:
```js
{ 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
{{>all-docs~}}
## License
Apache 2.0