Skip to content
Open
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
18 changes: 16 additions & 2 deletions worker/src/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,17 @@ void Worker::requestPolicyFromController() {
GetPolicyResponse resp;
grpc::ClientContext context;

auto deadline = std::chrono::system_clock::now() + std::chrono::seconds(1);
context.set_deadline(deadline);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

кажется, логировать это нужно еще


auto status = stub_->GetPolicy(&context, req, &resp);

if (!status.ok()) {
spdlog::error("GetPolicy failed: " + status.error_message());
if (status.error_code() == grpc::DEADLINE_EXCEEDED) {
spdlog::warn("GetPolicy timed out");
} else {
spdlog::error("GetPolicy failed: {}", status.error_message());
}
return;
}

Expand Down Expand Up @@ -283,9 +290,16 @@ bool Worker::classify(const std::string &type, const std::string &target,
ClassifyResponse resp;
grpc::ClientContext context;

auto deadline = std::chrono::system_clock::now() + std::chrono::seconds(1);
context.set_deadline(deadline);

auto status = stub_->Classify(&context, req, &resp);
if (!status.ok()) {
spdlog::error("Classify failed: " + status.error_message());
if (status.error_code() == grpc::DEADLINE_EXCEEDED) {
spdlog::warn("Classify timed out");
} else {
spdlog::error("Classify failed: " + status.error_message());
}
return false;
}

Expand Down
Loading