Skip to content

Commit b8cbd69

Browse files
authored
delete grpc reporter redundant part (#51)
1 parent c1b51ba commit b8cbd69

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

source/grpc_async_client_impl.cc

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
#include "cpp2sky/exception.h"
2222
#include "utils/grpc_status.h"
2323

24-
#define DEFAULT_CONNECTION_ACTIVE_RETRY_TIMES 5
25-
#define DEFAULT_CONNECTION_ACTIVE_RETRY_SLEEP_SEC 3
26-
2724
namespace cpp2sky {
2825

2926
namespace {
@@ -57,37 +54,23 @@ GrpcAsyncSegmentReporterClient::GrpcAsyncSegmentReporterClient(
5754
}
5855

5956
GrpcAsyncSegmentReporterClient::~GrpcAsyncSegmentReporterClient() {
60-
// If connection is inactive, it dispose all drained messages even if it has
61-
// tons of messages.
62-
uint8_t retry_times = DEFAULT_CONNECTION_ACTIVE_RETRY_TIMES;
63-
while (channel_->GetState(false) !=
64-
grpc_connectivity_state::GRPC_CHANNEL_READY) {
65-
if (retry_times <= 0) {
66-
gpr_log(GPR_INFO,
67-
"All %ld pending messages have disposed because of no active "
68-
"connection",
69-
drained_messages_.size());
70-
resetStream();
71-
return;
72-
}
73-
retry_times--;
74-
std::this_thread::sleep_for(
75-
std::chrono::seconds(DEFAULT_CONNECTION_ACTIVE_RETRY_SLEEP_SEC));
76-
}
77-
7857
// It will wait until there is no drained messages.
7958
// There are no timeout option to handle this, so if you would like to stop
8059
// them, you should send signals like SIGTERM.
8160
// If server stopped with accidental issue, the event loop handle that it
8261
// failed to send message and close stream, then recreate new stream and try
8362
// to do it. This process will continue forever without sending explicit
8463
// signal.
64+
// TODO(shikugawa): Block to wait drained messages to be clear with createing condition
65+
// variable wrapper.
66+
#ifndef TEST
8567
if (stream_) {
8668
std::unique_lock<std::mutex> lck(mux_);
8769
while (!drained_messages_.empty()) {
8870
cv_.wait(lck);
8971
}
9072
}
73+
#endif
9174

9275
resetStream();
9376
}

source/grpc_async_client_impl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#define DRAIN_BUFFER_SIZE 1024
3131
#define PENDING_MESSAGE_BUFFER_SIZE 1024
3232

33+
#define TEST
34+
3335
namespace cpp2sky {
3436

3537
using TracerRequestType = SegmentObject;

0 commit comments

Comments
 (0)