Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6572487
Add TranscoderInputStreamImpl
lizan Jun 9, 2017
a8f8f33
Merge remote-tracking branch 'upstream/master' into grpc_transcoder_i…
lizan Jun 14, 2017
579d342
Refactor ZeroCopyInputStreamImpl out
lizan Jun 15, 2017
118d1e7
Merge remote-tracking branch 'upstream/master' into grpc_transcoder_i…
lizan Jun 15, 2017
ca46f94
fix
lizan Jun 15, 2017
8034159
Use ZeroCopyInputStreamImpl in AsyncClientImpl and RpcChannelImpl
lizan Jun 15, 2017
77f9c00
fix
lizan Jun 15, 2017
dd68af1
fix format
lizan Jun 15, 2017
8d235bd
fix finish test
lizan Jun 15, 2017
98c5ccf
Address review comments
lizan Jun 19, 2017
547b92f
Merge remote-tracking branch 'upstream/master' into grpc_transcoder_i…
lizan Jun 19, 2017
8f1f307
fix format
lizan Jun 19, 2017
b88b0d5
fix test include
lizan Jun 20, 2017
9850c9b
fix format
lizan Jun 20, 2017
53fcf47
fix grammer in comments
lizan Jun 20, 2017
6be5d0d
fix format
lizan Jun 20, 2017
ae9094f
Add transcoding docs
lizan Jun 7, 2017
13b66db
Add transcoding filter from istio/proxy
lizan Jun 9, 2017
5eabe6f
Test WIP
lizan Jun 9, 2017
5446914
align with master
lizan Jun 21, 2017
db48843
Add unittest
lizan Jun 21, 2017
f92d527
Add integration test
lizan Jun 21, 2017
b68400e
Merge remote-tracking branch 'upstream/master' into grpc_json_transco…
lizan Jun 21, 2017
cc27cec
fix format
lizan Jun 21, 2017
c99496d
Merge remote-tracking branch 'upstream/master' into grpc_json_transco…
lizan Jun 22, 2017
c45226a
Address @htuch reviews
lizan Jun 22, 2017
3acba06
refactor method signatures
lizan Jun 22, 2017
65567f4
Add patch and custom test
lizan Jun 22, 2017
41416cd
Add comment for config class
lizan Jun 23, 2017
79791ab
fix code comment, rename to grpc_json_transcoder
lizan Jun 27, 2017
af5ac95
docs
lizan Jun 27, 2017
b2265b0
fix format
lizan Jun 27, 2017
ce354b4
Merge remote-tracking branch 'upstream/master' into grpc_json_transco…
lizan Jun 27, 2017
8b154c7
Update docs
lizan Jun 28, 2017
6894025
Merge remote-tracking branch 'upstream/master' into grpc_json_transco…
lizan Jun 29, 2017
efba771
increase test coverage
lizan Jun 29, 2017
80de522
move descriptor generation into bzl rule
lizan Jun 30, 2017
2a35000
fix format
lizan Jun 30, 2017
d41f9d9
fix format
lizan Jun 30, 2017
38d08fa
Update grpc_json_transcoder_filter.rst
mattklein123 Jun 30, 2017
c82fd4a
assert on error_
lizan Jun 30, 2017
cdeb87d
fix BUILD, add more comments
lizan Jun 30, 2017
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
31 changes: 29 additions & 2 deletions bazel/envoy_build_system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,14 @@ def _proto_header(proto_path):
return None

# Envoy proto targets should be specified with this function.
def envoy_proto_library(name, srcs = [], deps = []):
def envoy_proto_library(name, srcs = [], deps = [], external_deps = []):
internal_name = name + "_internal"
cc_proto_library(
name = internal_name,
srcs = srcs,
default_runtime = "//external:protobuf",
protoc = "//external:protoc",
deps = deps,
deps = deps + [envoy_external_dep_path(dep) for dep in external_deps],
linkstatic = 1,
)
# We can't use include_prefix directly in cc_proto_library, since it
Expand All @@ -278,3 +278,30 @@ def envoy_proto_library(name, srcs = [], deps = []):
deps = [internal_name],
linkstatic = 1,
)

# Envoy proto descriptor targets should be specified with this function.
# This is used for testing only.
def envoy_proto_descriptor(name, out, srcs = [], protocopts = [], external_deps = []):
input_files = ["$(location " + src + ")" for src in srcs]
include_paths = [".", PACKAGE_NAME]

if "http_api_protos" in external_deps:
srcs.append("@googleapis//:http_api_protos_src")
include_paths.append("external/googleapis")

if "well_known_protos" in external_deps:
srcs.append("@protobuf_bzl//:well_known_protos")
include_paths.append("external/protobuf_bzl/src")

options = protocopts[:]
options.extend(["-I" + include_path for include_path in include_paths])
options.append("--descriptor_set_out=$@")

cmd = "$(location //external:protoc) " + " ".join(options + input_files)
native.genrule(
name = name,
srcs = srcs,
outs = [out],
cmd = cmd,
tools = ["//external:protoc"],
)
8 changes: 8 additions & 0 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ def envoy_api_deps(skip_targets):
name = "envoy_eds",
actual = "@envoy_api//api:eds",
)
native.bind(
Copy link
Member

Choose a reason for hiding this comment

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

This seems like the wrong if statement to have this under? I will defer to @htuch for review on all of the bazel changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Since googleapis is loaded from envoy-api, so I added here, let me know if this should go somewhere else. @htuch

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, this is OK, but in theory you could source http_api_protos independently, let's keep it like this for now.

name = "http_api_protos",
actual = "@googleapis//:http_api_protos",
)
native.bind(
name = "http_api_protos_genproto",
actual = "@googleapis//:http_api_protos_genproto",
)

def envoy_dependencies(path = "@envoy_deps//", skip_protobuf_bzl = False, skip_targets = []):
if not skip_protobuf_bzl:
Expand Down
56 changes: 56 additions & 0 deletions docs/configuration/http_filters/grpc_json_transcoder_filter.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.. _config_http_filters_grpc_json_transcoder:

gRPC-JSON transcoder filter
===========================

gRPC :ref:`architecture overview <arch_overview_grpc>`.

This is a filter which allows a RESTful JSON API client to send requests to Envoy over HTTP
and get proxied to a gRPC service. The HTTP mapping for the gRPC service has to be defined by
`custom options <https://cloud.google.com/service-management/reference/rpc/google.api#http>`_.

Configure gRPC-JSON transcoder
------------------------------

The filter config for the filter requires the descriptor file as well as a list of the gRPC
services to be transcoded.

.. code-block:: json

{
"type": "both",
"name": "grpc_json_transcoder",
"config": {
"proto_descriptors": "proto.pb",
Copy link
Member

@mattklein123 mattklein123 Jun 27, 2017

Choose a reason for hiding this comment

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

(Not a full review, will do full code review tomorrow)

Can we get a description of each of these config parameters? If I understand correctly, it's required that all descriptors get merged into a single pb file, right? What if there are multiple services from multiple protos? How do those get merged? Can you maybe provide an example?

For "services" what happens if the .pb file contains more services than you specify? Those aren't transcoded? Can you clarify?

Also, in general, I would love to talk about reflection possibilities. Obviously this is a follow up, but from Lyft perspective (and I think others), this filter is vastly less useful and more difficult to use if Envoy has to know ahead of time the .pb files and we need to keep them up to date. If we could do this with reflection I think that is the true absolutely killer feature. cc @twoism @rodaine @louiscryan

Copy link
Member Author

Choose a reason for hiding this comment

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

Can we get a description of each of these config parameters? If I understand correctly, it's required that all descriptors get merged into a single pb file, right? What if there are multiple services from multiple protos? How do those get merged? Can you maybe provide an example?

Will write it in docs, in short, protoc accepts multiple input files, so just do them together.

For "services" what happens if the .pb file contains more services than you specify? Those aren't transcoded? Can you clarify?

Right, those aren't transcoded.

Also, in general, I would love to talk about reflection possibilities. Obviously this is a follow up, but from Lyft perspective (and I think others), this filter is vastly less useful and more difficult to use if Envoy has to know ahead of time the .pb files and we need to keep them up to date. If we could do this with reflection I think that is the true absolutely killer feature.

I totally agree with you that would provide better usability, I'm just saying that won't included in this PR as this is big enough :) Feel free to open an issue and assign to me once this get merged.

"services": ["grpc.service.Service"]
}
}

proto_descriptors
*(required, string)* Supplies the binary protobuf descriptor set for the gRPC services.
The descriptor set has to include all of the types that are used in the services. Make sure
to use the ``--include_import`` option for ``protoc``.

To generate a protobuf descriptor set for the gRPC service, you'll also need to clone the
googleapis repository from Github before running protoc, as you'll need annotations.proto
in your include path.

.. code-block:: bash

git clone https://github.com/googleapis/googleapis
GOOGLEAPIS_DIR=<your-local-googleapis-folder>

Then run protoc to generate the descriptor set from bookstore.proto:

.. code-block:: bash

protoc -I$(GOOGLEAPIS_DIR) -I. --include_imports --include_source_info \
Copy link
Member

Choose a reason for hiding this comment

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

I think we can make this more seamless via some bazel run command in the Envoy repository, that uses our googleapis proto imports. Not for this PR, but maybe raise an issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think bazel run is easier in this case.
The Envoy customer (not developer) might not know how to build Envoy, and just using docker images, or binaries. Let them checkout envoy and install bazel sounds too much.
protoc is something that they are already using when they try Envoy with gRPC.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed I don't think we should assume that the user of envoy has access to the envoy code or bazel.

--descriptor_set_out=proto.pb test/proto/bookstore.proto

If you have more than one proto source files, you can pass all of them in one command.

services
*(required, array)* A list of strings that supplies the service names that the
transcoder will translate. If the service name doesn't exist in ``proto_descriptors``, Envoy
will fail at startup. The ``proto_descriptors`` may contain more services than the service names
specified here, but they won't be translated.
1 change: 1 addition & 0 deletions docs/configuration/http_filters/http_filters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ HTTP filters
fault_filter
dynamodb_filter
grpc_http1_bridge_filter
grpc_json_transcoder_filter
grpc_web_filter
health_check_filter
ip_tagging_filter
Expand Down
3 changes: 3 additions & 0 deletions docs/intro/arch_overview/grpc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ application layer:
client to send requests to Envoy over HTTP/1.1 and get proxied to a gRPC server. It's under
active development and is expected to be the successor to the gRPC :ref:`bridge filter
<config_http_filters_grpc_bridge>`.
* gRPC-JSON transcoder is supported by a :ref:`filter <config_http_filters_grpc_json_transcoder>`
that allows a RESTful JSON API client to send requests to Envoy over HTTP and get proxied to a
gRPC service.
19 changes: 19 additions & 0 deletions source/common/grpc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,25 @@ envoy_cc_library(
],
)

envoy_cc_library(
name = "json_transcoder_filter_lib",
srcs = ["json_transcoder_filter.cc"],
hdrs = ["json_transcoder_filter.h"],
external_deps = [
"path_matcher",
"grpc_transcoding",
"http_api_protos",
],
deps = [
":codec_lib",
":common_lib",
":transcoder_input_stream_lib",
"//include/envoy/http:filter_interface",
"//source/common/common:base64_lib",
"//source/common/http:headers_lib",
],
)

envoy_cc_library(
name = "grpc_web_filter_lib",
srcs = ["grpc_web_filter.cc"],
Expand Down
Loading