Skip to content

Commit

Permalink
Merge pull request #156 from IBM/step_grpc
Browse files Browse the repository at this point in the history
Step gRPC version to 1.66.1
  • Loading branch information
rainerschoe authored Sep 25, 2024
2 parents 557f32f + c92f4ce commit a968d5d
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 144 deletions.
2 changes: 1 addition & 1 deletion cmake/gRPC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ if(GWHISPER_FORCE_BUILDING_GRPC OR GRPC_NOT_FOUND)
FetchContent_Declare(
grpc
GIT_REPOSITORY https://github.com/grpc/grpc
GIT_TAG v1.62.0
GIT_TAG v1.66.1
GIT_PROGRESS TRUE
)
set(FETCHCONTENT_QUIET OFF)
Expand Down
4 changes: 4 additions & 0 deletions src/gwhisper/gwhisper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <libCli/Call.hpp>
#include <libCli/Completion.hpp>
#include <versionDefine.h> // generated during build
#include "absl/log/initialize.h"

using namespace ArgParse;

Expand Down Expand Up @@ -48,6 +49,9 @@ const char* g_helpString =

int main(int argc, char **argv)
{
// Some components we are consuming from gRPC (descDb / cliCall) use absl logging. Initialize it here:
absl::InitializeLog();

// First we construct the initial Grammar for the CLI tool:
Grammar grammarPool;
GrammarElement *grammarRoot = cli::constructGrammar(grammarPool);
Expand Down
2 changes: 1 addition & 1 deletion src/libCli/MessageFormatterJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace cli
printOptions.preserve_proto_field_names = true;

// Will print primitive fields regardless of their values. So e.g. an int32 field set to 0 will not be omitted.
printOptions.always_print_primitive_fields = true;
printOptions.always_print_fields_with_no_presence = true;

const auto status = google::protobuf::util::MessageToJsonString(f_message, &resultString, printOptions);
if(not status.ok())
Expand Down
57 changes: 29 additions & 28 deletions third_party/gRPC_utils/cli_call.cc
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
//
//
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//

// MODIFIED by IBM (Rainer Schoenberger)
// original: #include "test/cpp/util/cli_call.h"
Expand All @@ -31,9 +31,10 @@
#include <iostream>
#include <utility>

#include "absl/log/check.h"

#include <grpc/grpc.h>
#include <grpc/slice.h>
#include <grpc/support/log.h>
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
#include <grpcpp/support/byte_buffer.h>
Expand Down Expand Up @@ -69,8 +70,8 @@ CliCall::CliCall(const std::shared_ptr<grpc::Channel>& channel,
: stub_(new grpc::GenericStub(channel)) {
gpr_mu_init(&write_mu_);
gpr_cv_init(&write_cv_);
// MODIFIED by IBM (Anna Riesch)
// original: no deadline
// MODIFIED by IBM (Anna Riesch, Rainer Schoenberger)
// original: deadline parsed from CLI args
if (deadline.has_value()) {
// Set timeout if optional parameter has a value. Otherwise don't set timeout = infinite deadline
auto deadlineMs = deadline.value();
Expand All @@ -89,7 +90,7 @@ CliCall::CliCall(const std::shared_ptr<grpc::Channel>& channel,
void* got_tag;
bool ok;
cq_.Next(&got_tag, &ok);
GPR_ASSERT(ok);
CHECK(ok);
}

CliCall::~CliCall() {
Expand All @@ -106,7 +107,7 @@ void CliCall::Write(const std::string& request) {
grpc::ByteBuffer send_buffer(&req_slice, 1);
call_->Write(send_buffer, tag(2));
cq_.Next(&got_tag, &ok);
GPR_ASSERT(ok);
CHECK(ok);
}

bool CliCall::Read(std::string* response,
Expand All @@ -121,7 +122,7 @@ bool CliCall::Read(std::string* response,
return false;
}
std::vector<grpc::Slice> slices;
GPR_ASSERT(recv_buffer.Dump(&slices).ok());
CHECK(recv_buffer.Dump(&slices).ok());

response->clear();
for (size_t i = 0; i < slices.size(); i++) {
Expand All @@ -140,7 +141,7 @@ void CliCall::WritesDone() {

call_->WritesDone(tag(4));
cq_.Next(&got_tag, &ok);
GPR_ASSERT(ok);
CHECK(ok);
}

void CliCall::WriteAndWait(const std::string& request) {
Expand Down Expand Up @@ -183,7 +184,7 @@ bool CliCall::ReadAndMaybeNotifyWrite(

cq_result = cq_.Next(&got_tag, &ok);
if (got_tag == tag(2)) {
GPR_ASSERT(ok);
CHECK(ok);
}
}

Expand All @@ -194,7 +195,7 @@ bool CliCall::ReadAndMaybeNotifyWrite(
gpr_mu_lock(&write_mu_);
if (!write_done_) {
cq_.Next(&got_tag, &ok);
GPR_ASSERT(got_tag != tag(2));
CHECK(got_tag != tag(2));
write_done_ = true;
gpr_cv_signal(&write_cv_);
}
Expand All @@ -204,7 +205,7 @@ bool CliCall::ReadAndMaybeNotifyWrite(
}

std::vector<grpc::Slice> slices;
GPR_ASSERT(recv_buffer.Dump(&slices).ok());
CHECK(recv_buffer.Dump(&slices).ok());
response->clear();
for (size_t i = 0; i < slices.size(); i++) {
response->append(reinterpret_cast<const char*>(slices[i].begin()),
Expand All @@ -223,7 +224,7 @@ Status CliCall::Finish(IncomingMetadataContainer* server_trailing_metadata) {

call_->Finish(&status, tag(5));
cq_.Next(&got_tag, &ok);
GPR_ASSERT(ok);
CHECK(ok);
if (server_trailing_metadata) {
*server_trailing_metadata = ctx_.GetServerTrailingMetadata();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/*
*
* Copyright 2016 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPC_TEST_CPP_PROTO_SERVER_REFLECTION_DATABSE_H
#define GRPC_TEST_CPP_PROTO_SERVER_REFLECTION_DATABSE_H
//
//
// Copyright 2016 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
#ifndef GRPC_TEST_CPP_UTIL_PROTO_REFLECTION_DESCRIPTOR_DATABASE_H
#define GRPC_TEST_CPP_UTIL_PROTO_REFLECTION_DESCRIPTOR_DATABASE_H

#include <mutex>
#include <unordered_map>
Expand Down Expand Up @@ -44,9 +44,9 @@ class ProtoReflectionDescriptorDatabase : public protobuf::DescriptorDatabase {
std::unique_ptr<reflection::v1alpha::ServerReflection::Stub> stub);

explicit ProtoReflectionDescriptorDatabase(
const std::shared_ptr<grpc::Channel>& channel);
const std::shared_ptr<grpc::ChannelInterface>& channel);

virtual ~ProtoReflectionDescriptorDatabase();
~ProtoReflectionDescriptorDatabase() override;

// The following four methods implement DescriptorDatabase interfaces.
//
Expand Down Expand Up @@ -80,10 +80,7 @@ class ProtoReflectionDescriptorDatabase : public protobuf::DescriptorDatabase {
std::vector<int>* output) override;

// Provide a list of full names of registered services
bool GetServices(std::vector<grpc::string>* output);

/// @brief close the reflection stream with a default deadline.
/// @return return grpc status as a result of call the finish() on the reflection stream.
bool GetServices(std::vector<std::string>* output);
grpc::Status closeDescDbStream();

private:
Expand All @@ -92,18 +89,18 @@ class ProtoReflectionDescriptorDatabase : public protobuf::DescriptorDatabase {
grpc::reflection::v1alpha::ServerReflectionResponse>
ClientStream;

const protobuf::FileDescriptorProto ParseFileDescriptorProtoResponse(
const grpc::string& byte_fd_proto);
protobuf::FileDescriptorProto ParseFileDescriptorProtoResponse(
const std::string& byte_fd_proto);

void AddFileFromResponse(
const grpc::reflection::v1alpha::FileDescriptorResponse& response);

const std::shared_ptr<ClientStream> GetStream();
std::shared_ptr<ClientStream> GetStream();

bool DoOneRequest(
const grpc::reflection::v1alpha::ServerReflectionRequest& request,
grpc::reflection::v1alpha::ServerReflectionResponse& response);

// MODIFIED:
grpc::Status closeStream();

std::shared_ptr<ClientStream> stream_;
Expand Down
Loading

0 comments on commit a968d5d

Please sign in to comment.