Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint protobuf files, place in xviz.v2 package, ensure bazel compat #476

Merged
merged 1 commit into from
Jun 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions docs/protocol-formats/protobuf-protocol.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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.

Loading