File tree Expand file tree Collapse file tree 12 files changed +208
-180
lines changed Expand file tree Collapse file tree 12 files changed +208
-180
lines changed Original file line number Diff line number Diff line change @@ -266,4 +266,13 @@ jobs:
266266
267267 pip install conan
268268 conan profile detect
269+
270+ mkdir b2-tmp
271+ echo '[requires]
272+ b2/5.3.2
273+ ' > b2-tmp/conanfile.txt
274+ cat b2-tmp/conanfile.txt
275+ conan install b2-tmp --build=b2/5.3.2 -s compiler.cppstd=14 -s:a compiler.cppstd=14
276+ rm -r b2-tmp
277+
269278 conan create . --build=missing -s compiler.cppstd=14 -s:a compiler.cppstd=14
Original file line number Diff line number Diff line change 4141 cmake_minimum_required (VERSION 3.25 FATAL_ERROR)
4242endif ()
4343
44- set (CMAKE_PROJECT_VERSION 0.10 .0)
44+ set (CMAKE_PROJECT_VERSION 0.11 .0)
4545
4646# Identify the project.
4747project (viam-cpp-sdk
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ bool isStatusCancelled(int status) noexcept {
2323 return status == ::grpc::StatusCode::CANCELLED;
2424}
2525
26+ void set_name (...) {} // NOLINT(cert-dcl50-cpp)
27+
2628} // namespace client_helper_details
2729
2830ClientContext::ClientContext () : wrapped_context_(std::make_unique<GrpcClientContext>()) {
Original file line number Diff line number Diff line change @@ -15,6 +15,19 @@ namespace client_helper_details {
1515// Helper function to test equality of status with grpc::StatusCode::CANCELLED.
1616bool isStatusCancelled (int status) noexcept ;
1717
18+ // Set the mutable name of a request to the client name.
19+ // This function only participates in overload resolution if the request has a mutable_name method.
20+ template <typename RequestType,
21+ typename ClientType,
22+ typename = decltype (&RequestType::mutable_name)>
23+ void set_name (RequestType* req, const ClientType* client) {
24+ *req->mutable_name () = client->name ();
25+ }
26+
27+ // No-op version of set_name above. This overload is only selected if the request type does not have
28+ // a mutable_name field.
29+ void set_name (...);
30+
1831} // namespace client_helper_details
1932
2033// the authority on a grpc::ClientContext is sometimes set to an invalid uri on mac, causing
@@ -96,7 +109,7 @@ class ClientHelper {
96109
97110 template <typename ResponseHandlerCallable, typename ErrorHandlerCallable>
98111 auto invoke (ResponseHandlerCallable&& rhc, ErrorHandlerCallable&& ehc) {
99- *request_. mutable_name () = client_-> name ( );
112+ client_helper_details::set_name (&request_, client_);
100113 ClientContext ctx;
101114
102115 if (debug_key_ != " " ) {
Original file line number Diff line number Diff line change @@ -133,11 +133,15 @@ void LogManager::init_logging() {
133133 console_sink_ = boost::make_shared<
134134 boost::log::sinks::synchronous_sink<boost::log::sinks::text_ostream_backend>>(backend);
135135
136- console_sink_->set_filter (Filter{this });
136+ boost::log::core::get ()->add_sink (console_sink_);
137+
137138 console_sink_->set_formatter (fmt);
139+ enable_console_logging ();
140+ }
138141
139- boost::log::core::get ()->add_sink (console_sink_);
140- VIAM_SDK_LOG (debug) << " Initialized console logging" ;
142+ void LogManager::enable_console_logging () {
143+ console_sink_->set_filter (Filter{this });
144+ VIAM_SDK_LOG (debug) << " Console logging enabled" ;
141145}
142146
143147void LogManager::disable_console_logging () {
Original file line number Diff line number Diff line change @@ -113,6 +113,7 @@ class LogManager {
113113 LogManager& operator =(LogManager&&) = delete ;
114114
115115 void init_logging ();
116+ void enable_console_logging ();
116117 void disable_console_logging ();
117118
118119 LogSource sdk_logger_;
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ struct ModuleService::ServiceImpl : viam::module::v1::ModuleService::Service {
5454 ModuleService& parent;
5555
5656 // TODO(RSDK-6528) - to the extent possible, switch to using `server_helper`
57- ::grpc::Status AddResource (::grpc::ServerContext*,
57+ ::grpc::Status AddResource (::grpc::ServerContext* ctx ,
5858 const ::viam::module ::v1::AddResourceRequest* request,
5959 ::viam::module ::v1::AddResourceResponse*) override {
6060 const viam::app::v1::ComponentConfig& proto = request->config ();
@@ -74,7 +74,7 @@ struct ModuleService::ServiceImpl : viam::module::v1::ModuleService::Service {
7474 }
7575 };
7676 try {
77- parent.server_ ->add_resource (res);
77+ parent.server_ ->add_resource (res, ctx-> deadline () );
7878 } catch (const std::exception& exc) {
7979 return grpc::Status (::grpc::INTERNAL, exc.what ());
8080 }
You can’t perform that action at this time.
0 commit comments