Skip to content

Commit

Permalink
refactoring and adding function description.
Browse files Browse the repository at this point in the history
Signed-off-by: Rahman Abber Tahir <[email protected]>
  • Loading branch information
Rahman Abber Tahir committed Nov 16, 2023
1 parent a6c4cdb commit 41810a5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/libCli/ConnectionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace cli
}

//if proxy exists close the stream with a deadline.
grpc::Status status = m_connections[f_serverAddress].descDbProxy->closeDbStream(deadline);
grpc::Status status = m_connections[f_serverAddress].descDbProxy->closeDescDbStream(deadline);

//delete the proxy, findChannelByAddress() protects from accessing uninitialzed DbProxy.
m_connections[f_serverAddress].descDbProxy.reset();
Expand Down
5 changes: 5 additions & 0 deletions src/libCli/libCli/ConnectionManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ namespace cli
/// @returns the gRpc DescriptorPool of the corresponding server address.
std::shared_ptr<grpc::protobuf::DescriptorPool> getDescPool(std::string f_serverAddress, ArgParse::ParsedElement &f_parseTree);

/// @brief closes the DescDb stream with a given deadline.
/// @param f_serverAddress server addresss to lookup the assigned DescDbProxy.
/// @param deadline optional dealine for closing the stream.
/// @return returns grpc::StatusCode::ABORTED status if no DescDb proxy is attached to the server address,
/// otherwise grpc status as a result of stream closure.
grpc::Status closeDescDbWithDeadline(std::string f_serverAddress,
std::optional<std::chrono::time_point<std::chrono::system_clock>> deadline);

Expand Down
2 changes: 1 addition & 1 deletion src/libLocalDescriptorCache/DescDbProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ void DescDbProxy::getDescriptors(const std::string &f_hostAddress)
}
}

grpc::Status DescDbProxy::closeDbStream(std::optional<std::chrono::time_point<std::chrono::system_clock>> deadline)
grpc::Status DescDbProxy::closeDescDbStream(std::optional<std::chrono::time_point<std::chrono::system_clock>> deadline)
{
if( m_disableCache == false )//cache enabled, no reflection stream required.
{
Expand Down
5 changes: 4 additions & 1 deletion src/libLocalDescriptorCache/DescDbProxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ class DescDbProxy : public grpc::protobuf::DescriptorDatabase{
/// @param hostAdress Address to the current host
void getDescriptors(const std::string &hostAddress);

grpc::Status closeDbStream(std::optional<std::chrono::time_point<std::chrono::system_clock>> deadline);
/// @brief close the DescDb stream with a given deadline. If the dealine is not set it waits for the stream to close indefinitely.
/// @param deadline optional deadline to close the DescDb stream.
/// @return return grpc status as a result of call the finish() on the DescDb stream.
grpc::Status closeDescDbStream(std::optional<std::chrono::time_point<std::chrono::system_clock>> deadline);

DescDbProxy(bool disableCache, const std::string &hostAddress, std::shared_ptr<grpc::Channel> channel, ArgParse::ParsedElement &parseTree);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class ProtoReflectionDescriptorDatabase : public protobuf::DescriptorDatabase {
// Provide a list of full names of registered services
bool GetServices(std::vector<grpc::string>* output);

/// @brief close the reflection stream with a given deadline. If the dealine is not set it waits for the stream to close indefinitely.
/// @param deadline optional deadline to close the reflection stream.
/// @return return grpc status as a result of call the finish() on the reflection stream.
grpc::Status closeStreamWithDeadline(std::optional<std::chrono::time_point<std::chrono::system_clock>> deadline);

private:
Expand Down

0 comments on commit 41810a5

Please sign in to comment.