Skip to content
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
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#
# A Bazel (http://bazel.io) workspace for the Google Cloud Endpoints runtime.

ISTIO_PROXY = "557d0c6a7f1136e98ca1a05494df0b51c5bad7d2"
ISTIO_PROXY = "987223f6ce6998a8af0f3524545bed7f0d0a1ebb"

git_repository(
name = "nginx",
Expand Down Expand Up @@ -158,7 +158,7 @@ git_repository(
#
git_repository(
name = "io_bazel_rules_go",
commit = "76c63b5cd0d47c1f2b47ab4953db96c574af1c1d",
commit = "2d9f328a9723baf2d037ba9db28d9d0e30683938", # Apr 6, 2017 (buildifier fix)
remote = "https://github.com/bazelbuild/rules_go.git",
)

Expand Down
1 change: 1 addition & 0 deletions src/grpc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ cc_library(
],
visibility = ["//visibility:public"],
deps = [
"@istio_proxy_git//contrib/endpoints/src/grpc/transcoding:transcoder_input_stream",
"//external:grpc",
"//external:grpc++",
"//external:protobuf",
Expand Down
2 changes: 1 addition & 1 deletion src/grpc/zero_copy_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void GrpcZeroCopyInputStream::BackUp(int count) {
}
}

::google::protobuf::int64 GrpcZeroCopyInputStream::ByteCount() const {
int64_t GrpcZeroCopyInputStream::BytesAvailable() const {
return (current_buffer_size_ - position_) + serializer_.ByteCount();
}

Expand Down
8 changes: 5 additions & 3 deletions src/grpc/zero_copy_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include <deque>

#include "contrib/endpoints/src/grpc/transcoding/transcoder_input_stream.h"
#include "google/protobuf/io/zero_copy_stream.h"
#include "grpc++/support/byte_buffer.h"
#include "src/grpc/message_serializer.h"
Expand All @@ -38,7 +39,7 @@ namespace grpc {

// ZeroCopyInputStream implementation over a stream of gRPC messages.
class GrpcZeroCopyInputStream
: public ::google::protobuf::io::ZeroCopyInputStream {
: public ::google::api_manager::transcoding::TranscoderInputStream {
public:
GrpcZeroCopyInputStream();

Expand All @@ -53,8 +54,9 @@ class GrpcZeroCopyInputStream

bool Next(const void** data, int* size);
void BackUp(int count);
bool Skip(int count) { return false; } // not supported
::google::protobuf::int64 ByteCount() const;
bool Skip(int count) { return false; } // not supported
::google::protobuf::int64 ByteCount() const { return 0; } // Not implemented
int64_t BytesAvailable() const;

private:
GrpcMessageSerializer serializer_;
Expand Down
38 changes: 19 additions & 19 deletions src/grpc/zero_copy_stream_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,63 +86,63 @@ TEST_F(GrpcZeroCopyInputStreamTest, SimpleRead) {
stream.AddMessage(CreateByteBuffer(SliceData{slice21, slice22}), true);
stream.Finish();

// Test ByteCount()
// Test BytesAvailable()
EXPECT_EQ(slice11.size() + slice12.size() + slice21.size() + slice22.size() +
10, // +10 bytes for two delimiters
stream.ByteCount());
stream.BytesAvailable());

// Test the message1 delimiter
ASSERT_TRUE(stream.Next(&data, &size));
ASSERT_EQ(5, size);
EXPECT_EQ(slice11.size() + slice12.size(),
DelimiterToSize(reinterpret_cast<const unsigned char *>(data)));

// Test ByteCount()
// Test BytesAvailable()
EXPECT_EQ(slice11.size() + slice12.size() + slice21.size() + slice22.size() +
5, // +5 bytes for one delimiter
stream.ByteCount());
stream.BytesAvailable());

// Test the slices
ASSERT_TRUE(stream.Next(&data, &size));
ASSERT_EQ(slice11.size(), size);
EXPECT_EQ(slice11, std::string(reinterpret_cast<const char *>(data), size));

// Test ByteCount()
// Test BytesAvailable()
EXPECT_EQ(slice12.size() + slice21.size() + slice22.size() +
5, // +5 bytes for one delimiter
stream.ByteCount());
stream.BytesAvailable());

ASSERT_TRUE(stream.Next(&data, &size));
ASSERT_EQ(slice12.size(), size);
EXPECT_EQ(slice12, std::string(reinterpret_cast<const char *>(data), size));

// Test ByteCount()
// Test BytesAvailable()
EXPECT_EQ(slice21.size() + slice22.size() + 5, // +5 bytes for one delimiter
stream.ByteCount());
stream.BytesAvailable());

// Test the message2 delimiter
ASSERT_TRUE(stream.Next(&data, &size));
ASSERT_EQ(5, size);
EXPECT_EQ(slice21.size() + slice22.size(),
DelimiterToSize(reinterpret_cast<const unsigned char *>(data)));

// Test ByteCount()
EXPECT_EQ(slice21.size() + slice22.size(), stream.ByteCount());
// Test BytesAvailable()
EXPECT_EQ(slice21.size() + slice22.size(), stream.BytesAvailable());

// Test the slices
ASSERT_TRUE(stream.Next(&data, &size));
ASSERT_EQ(slice21.size(), size);
EXPECT_EQ(slice21, std::string(reinterpret_cast<const char *>(data), size));

// Test ByteCount()
EXPECT_EQ(slice22.size(), stream.ByteCount());
// Test BytesAvailable()
EXPECT_EQ(slice22.size(), stream.BytesAvailable());

ASSERT_TRUE(stream.Next(&data, &size));
ASSERT_EQ(slice22.size(), size);
EXPECT_EQ(slice22, std::string(reinterpret_cast<const char *>(data), size));

// Test the end of the stream
EXPECT_EQ(0, stream.ByteCount());
EXPECT_EQ(0, stream.BytesAvailable());
EXPECT_FALSE(stream.Next(&data, &size));
}

Expand All @@ -167,9 +167,9 @@ TEST_F(GrpcZeroCopyInputStreamTest, Backups) {
// Back up
stream.BackUp(5);

// Test the ByteCount()
// Test the BytesAvailable()
EXPECT_EQ(slice1.size() + slice2.size() + 5, // +5 bytes for the delimiter
stream.ByteCount());
stream.BytesAvailable());

// Test the slice again
ASSERT_TRUE(stream.Next(&data, &size));
Expand All @@ -184,14 +184,14 @@ TEST_F(GrpcZeroCopyInputStreamTest, Backups) {

// Back up & test again
stream.BackUp(size);
EXPECT_EQ(slice1.size() + slice2.size(), stream.ByteCount());
EXPECT_EQ(slice1.size() + slice2.size(), stream.BytesAvailable());
ASSERT_TRUE(stream.Next(&data, &size));
ASSERT_EQ(slice1.size(), size);
EXPECT_EQ(slice1, std::string(reinterpret_cast<const char *>(data), size));

// Now Back up 10 bytes & test again
stream.BackUp(10);
EXPECT_EQ(10 + slice2.size(), stream.ByteCount());
EXPECT_EQ(10 + slice2.size(), stream.BytesAvailable());
ASSERT_TRUE(stream.Next(&data, &size));
ASSERT_EQ(10, size);
EXPECT_EQ(slice1.substr(slice1.size() - 10),
Expand All @@ -204,14 +204,14 @@ TEST_F(GrpcZeroCopyInputStreamTest, Backups) {

// Back up and test again
stream.BackUp(size);
EXPECT_EQ(slice2.size(), stream.ByteCount());
EXPECT_EQ(slice2.size(), stream.BytesAvailable());
ASSERT_TRUE(stream.Next(&data, &size));
ASSERT_EQ(slice2.size(), size);
EXPECT_EQ(slice2, std::string(reinterpret_cast<const char *>(data), size));

// Now Back up size - 1 bytes (all but 1) and check again
stream.BackUp(size - 1);
EXPECT_EQ(slice2.size() - 1, stream.ByteCount());
EXPECT_EQ(slice2.size() - 1, stream.BytesAvailable());
ASSERT_TRUE(stream.Next(&data, &size));
ASSERT_EQ(slice2.size() - 1, size);
EXPECT_EQ(slice2.substr(1),
Expand Down
1 change: 1 addition & 0 deletions third_party/BUILD.golang_protobuf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ go_library(
"proto/lib.go",
"proto/message_set.go",
"proto/pointer_reflect.go",
"proto/pointer_unsafe.go",
"proto/properties.go",
"proto/text.go",
"proto/text_parser.go",
Expand Down