Skip to content

Commit

Permalink
Merge pull request protocolbuffers#2 from protobufjs/master
Browse files Browse the repository at this point in the history
sync with protobufjs
  • Loading branch information
timc88 authored Apr 29, 2019
2 parents 0ffa2a3 + b5b6632 commit 1299b81
Show file tree
Hide file tree
Showing 7 changed files with 558 additions and 431 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,27 @@ function rpcImpl(method, requestData, callback) {
}
```
Below is a working example with a typescript implementation using grpc npm package.
```ts
const grpc = require('grpc')

const Client = grpc.makeGenericClientConstructor({})
const client = new Client(
grpcServerUrl,
grpc.credentials.createInsecure()
)

const rpcImpl = function(method, requestData, callback) {
client.makeUnaryRequest(
method.name,
arg => arg,
arg => arg,
requestData,
callback
)
}
```
Example:
```protobuf
Expand Down Expand Up @@ -633,6 +654,7 @@ Translates between file formats and generates static code.
--no-comments Does not output any JSDoc comments.

--force-long Enfores the use of 'Long' for s-/u-/int64 and s-/fixed64 fields.
--force-number Enfores the use of 'number' for s-/u-/int64 and s-/fixed64 fields.
--force-message Enfores the use of message instances instead of plain objects.

usage: pbjs [options] file1.proto file2.json ... (or pipe) other | pbjs [options] -
Expand Down
4 changes: 4 additions & 0 deletions cli/pbts.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ exports.main = function(args, callback) {
"// DO NOT EDIT! This is a generated file. Edit the JSDoc in src/*.js instead and run 'npm run types'.",
""
);
output.push(
"import * as Long from \"long\";",
""
);
if (argv.global)
output.push(
"export as namespace " + argv.global + ";",
Expand Down
4 changes: 2 additions & 2 deletions ext/descriptor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ var protobuf = require("protobufjs"), // requires the full library
var root = ...;

// convert any existing root instance to the corresponding descriptor type
var descriptor = root.toDescriptor("proto2");
var descriptorMsg = root.toDescriptor("proto2");
// ^ returns a FileDescriptorSet message, see table below

// encode to a descriptor buffer
var buffer = descriptor.FileDescriptorSet.encode(descriptor).finish();
var buffer = descriptor.FileDescriptorSet.encode(descriptorMsg).finish();

// decode from a descriptor buffer
var decodedDescriptor = descriptor.FileDescriptorSet.decode(buffer);
Expand Down
Loading

0 comments on commit 1299b81

Please sign in to comment.