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

Add documentation for closure_grpc_web_library #222

Closed
wants to merge 2 commits into from
Closed
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
86 changes: 86 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,88 @@ here.
- Only unary calls are supported for now.


### Bazel
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Can we move this section between "TypeScript Support" and "Proxy Interoperability"
  2. Can we use two hashes headings "## Bazel Support"?


> :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(
Copy link
Collaborator

Choose a reason for hiding this comment

The 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(
Copy link
Collaborator

Choose a reason for hiding this comment

The 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
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
workspace(name = "com_github_grpc_grpc_web")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# TODO(yannic): Update to use official repository.
# See https://github.com/bazelbuild/rules_closure/pull/278
http_archive(
Expand Down
2 changes: 1 addition & 1 deletion net/grpc/gateway/examples/echo/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ proto_library(
)

closure_grpc_web_library(
name = "echo",
name = "echo_closure_grpc",
deps = [
":echo_proto",
],
Expand Down