-
Notifications
You must be signed in to change notification settings - Fork 767
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
Add documentation for closure_grpc_web_library #222
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,6 +105,88 @@ here. | |
- Only unary calls are supported for now. | ||
|
||
|
||
### Bazel | ||
|
||
> :exclamation: ***Disclaimer***: | ||
> Using gRPC-Web in bazel currently requires [rules_closure] with | ||
an unmerged patch \(See [#223](https://github.com/grpc/grpc-web/issues/223)\). | ||
|
||
Add the following to your WORKSPACE: | ||
|
||
```python | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
http_archive( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see the intention here and I think it's a good idea. But this section seems a bit too heavy compared to the rest of the README. Can we shorten it somehow or take the details out to another page? Like perhaps we can move some of the details to https://github.com/grpc/grpc-web/blob/master/net/grpc/gateway/examples/echo/tutorial.md? |
||
name = "io_bazel_rules_closure", | ||
sha256 = "248a7a98eb3962d9f0013e543ea79c5063a83bac7af349ebf412d844e6ab3035", | ||
strip_prefix = "rules_closure-53f2cab21fa6c608f32f114387d88ffd7868c5fc", | ||
urls = [ | ||
"https://github.com/Yannic/rules_closure/archive/53f2cab21fa6c608f32f114387d88ffd7868c5fc.zip", | ||
], | ||
) | ||
|
||
http_archive( | ||
name = "com_github_grpc_grpc_web", | ||
sha256 = "e75d8b37334ec691cad4df1ef4e17b2fefdedda5a8c2ba344f83e2e8b52d3572", | ||
strip_prefix = "grpc-web-9b7b2d5411c486aa646ba2491cfd894d5352775b", | ||
urls = [ | ||
"https://github.com/grpc/grpc-web/archive/9b7b2d5411c486aa646ba2491cfd894d5352775b.zip", | ||
], | ||
) | ||
|
||
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_repositories") | ||
closure_repositories() | ||
``` | ||
|
||
Now, you can use `closure_grpc_web_library` by adding this to your BUILD files | ||
(\([example](bazel_echo_example)\)): | ||
|
||
```python | ||
load( | ||
"@com_github_grpc_grpc_web//bazel:closure_grpc_web_library.bzl", | ||
"closure_grpc_web_library", | ||
) | ||
|
||
load( | ||
"@io_bazel_rules_closure//closure:def.bzl", | ||
"closure_js_library", | ||
"closure_proto_library", | ||
) | ||
|
||
proto_library( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think highlighting these 4 rules is important. Instead of just putting all 4 rules as codes, can we explain what each of these 4 rules are for and why do we need 4 of them? |
||
name = "echo_proto", | ||
srcs = [ | ||
"echo.proto", | ||
], | ||
) | ||
|
||
closure_proto_library( | ||
name = "echo_closure_proto", | ||
deps = [ | ||
":echo_proto", | ||
], | ||
) | ||
|
||
closure_grpc_web_library( | ||
name = "echo_closure_grpc", | ||
deps = [ | ||
":echo_proto", | ||
], | ||
) | ||
|
||
closure_js_library( | ||
name = "echo_lib", | ||
srcs = [ | ||
"echo.js", | ||
], | ||
deps = [ | ||
":echo_closure_grpc", | ||
":echo_closure_proto", | ||
], | ||
) | ||
``` | ||
|
||
|
||
## How It Works | ||
|
||
Let's take a look at how gRPC-Web works with a simple example. You can find out | ||
|
@@ -262,3 +344,7 @@ this project! | |
|
||
* [zaucy](https://github.com/zaucy) | ||
* [yannic](https://github.com/yannic) | ||
|
||
|
||
[rules_closure]: https://github.com/bazelbuild/rules_closure | ||
[bazel_echo_example]: https://github.com/oferb/startup-os-example/tree/master/app/client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.