Skip to content

Commit

Permalink
Lint protobuf files, place in xviz.v2 package, ensure bazel compat
Browse files Browse the repository at this point in the history
We are using Uber's prototool 1.7 for lint with the provided
prototool.yaml setting which rules we are not following. These are not
being followed so that JSON emitted and consumed by the protobuf types
matches that in the JSON schema.

Bazel compatibility allows other projects to pull in our source
releases and use the protobuf rules directly.

See the `docs/protocol-formats/protobuf-protocol.md` for more details
on Bazel and lint/formatting.
  • Loading branch information
jlisee committed Jun 3, 2019
1 parent 94557f3 commit 1f50d20
Show file tree
Hide file tree
Showing 18 changed files with 627 additions and 723 deletions.
62 changes: 62 additions & 0 deletions docs/protocol-formats/protobuf-protocol.md
@@ -0,0 +1,62 @@
# XVIZ Protobuf Protocol Format

The XVIZ JSON schema is compatible with a set of protobuf files found in the `xviz/v2` folder of the
XVIZ repository. With these files you can produce JSON data that is compatible with the XVIZ JSON
schema and XVIZ clients.

## Current Status

**UNSTABLE** - the Prototuf schema for XVIZ is under active development. Anything can change in an
unversioned way: file structure, type names, or naming style to name just a few.

## Linting & Formatting Protobuf

We are using Uber's [prototool](https://github.com/uber/prototool) (version 1.7) to keep our files
consistent and following common conventions where possible (see `prototool.yaml` in the root for
exceptions):

To lint the files:

prototool lint ./xviz/v2

To format the files:

prototool format -w ./xviz/v2

## Using with Bazel

First you would use an external repository rule in your `WORKSPACE` like this but with the **proper
version** (newer than `1.0.0-beta14`) and matching sha256 sum.

```
http_archive(
name = "com_github_uber_xviz",
build_file = "//third_party:xviz.BUILD",
sha256 = "5dee4a6d73b9032e589868fa67748ad2be3cc7face147c192f569c54170ef07c",
strip_prefix = "xviz-1.0.0-beta.14",
urls = ["https://github.com/uber/xviz/archive/v1.0.0-beta.14.zip"],
)
```

The above rule references this `xviz.BUILD` file. This one generate C++ but you can modify it to
produce other language specific Protobuf bindings.

```
proto_library(
name = "proto",
srcs = glob(["xviz/v2/*.proto"]),
deps = [
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:struct_proto",
],
)
cc_proto_library(
name = "cc_proto",
visibility = ["//visibility:public"],
deps = ["proto"],
)
```

You would reference this rule in your other Bazel by using the following target:
`@com_github_uber_xviz//:cc_proto`
2 changes: 2 additions & 0 deletions docs/protocol-schema/introduction.md
Expand Up @@ -73,3 +73,5 @@ types described below:
types into JSON
- [Binary protocol](/docs/protocol-formats/binary-protocol.md) - a Hybrid JSON binary protocol
designed for larger data sets and faster performance
- [Protobuf protocol](/docs/protocol-formats/protobuf-protocol.md) - an in development Protobuf
schema that is compatible with the JSON protocol
2 changes: 1 addition & 1 deletion modules/schema/package.json
Expand Up @@ -24,7 +24,7 @@
},
"scripts": {
"build-schema": "node ./build-schema",
"build-protos": "pbjs --keep-case --target json --path ./proto/v2/*.proto --out dist/proto.v2.json",
"build-protos": "pbjs --keep-case --target json --proto-path ../.. --out dist/proto.v2.json ../../xviz/v2/*.proto",
"pre-build": "npm run build-schema && npm run build-protos"
}
}
28 changes: 0 additions & 28 deletions modules/schema/proto/v2/annotation.proto

This file was deleted.

157 changes: 0 additions & 157 deletions modules/schema/proto/v2/core.proto

This file was deleted.

107 changes: 0 additions & 107 deletions modules/schema/proto/v2/primitives.proto

This file was deleted.

0 comments on commit 1f50d20

Please sign in to comment.