Skip to content

Commit e71af6e

Browse files
committed
remove should_close_channel
1 parent faa73b6 commit e71af6e

File tree

4 files changed

+8
-23
lines changed

4 files changed

+8
-23
lines changed

src/viam/examples/modules/complex/proto/buf.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ deps:
44
- remote: buf.build
55
owner: googleapis
66
repository: googleapis
7-
commit: 751cbe31638d43a9bfb6162cd2352e67
8-
digest: shake256:87f55470d9d124e2d1dedfe0231221f4ed7efbc55bc5268917c678e2d9b9c41573a7f9a557f6d8539044524d9fc5ca8fbb7db05eb81379d168285d76b57eb8a4
7+
commit: 61b203b9a9164be9a834f58c37be6f62
8+
digest: shake256:e619113001d6e284ee8a92b1561e5d4ea89a47b28bf0410815cb2fa23914df8be9f1a6a98dcf069f5bc2d829a2cfb1ac614863be45cd4f8a5ad8606c5f200224

src/viam/sdk/robot/client.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,12 @@ void RobotClient::connect_logging() {
116116
}
117117

118118
RobotClient::~RobotClient() {
119-
if (should_close_channel_) {
120-
try {
121-
this->close();
122-
} catch (const std::exception& e) {
123-
VIAM_SDK_LOG(error) << "Received err while closing RobotClient: " << e.what();
124-
} catch (...) {
125-
VIAM_SDK_LOG(error) << "Received unknown err while closing RobotClient";
126-
}
119+
try {
120+
this->close();
121+
} catch (const std::exception& e) {
122+
VIAM_SDK_LOG(error) << "Received err while closing RobotClient: " << e.what();
123+
} catch (...) {
124+
VIAM_SDK_LOG(error) << "Received unknown err while closing RobotClient";
127125
}
128126
}
129127

@@ -256,7 +254,6 @@ void RobotClient::refresh_every() {
256254

257255
RobotClient::RobotClient(ViamChannel channel)
258256
: viam_channel_(std::move(channel)),
259-
should_close_channel_(false),
260257
impl_(std::make_unique<impl>(RobotService::NewStub(viam_channel_.channel()))) {}
261258

262259
std::vector<Name> RobotClient::resource_names() const {
@@ -307,7 +304,6 @@ std::shared_ptr<RobotClient> RobotClient::at_address(const std::string& address,
307304
const char* uri = address.c_str();
308305
auto robot =
309306
RobotClient::with_channel(ViamChannel::dial_initial(uri, options.dial_options()), options);
310-
robot->should_close_channel_ = true;
311307

312308
return robot;
313309
};
@@ -318,7 +314,6 @@ std::shared_ptr<RobotClient> RobotClient::at_local_socket(const std::string& add
318314
auto robot = RobotClient::with_channel(
319315
ViamChannel(sdk::impl::create_viam_channel(addr, grpc::InsecureChannelCredentials())),
320316
options);
321-
robot->should_close_channel_ = true;
322317

323318
return robot;
324319
};

src/viam/sdk/robot/client.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ struct LogBackend;
3232
/// - `RobotClient::at_address(...)`
3333
/// - `RobotClient::with_channel(...)`
3434
/// @ingroup Robot
35-
///
36-
/// You must `close()` a robot when finished with it in order to release its resources.
37-
/// Robots creates via `at_address` will automatically close, but robots created via
38-
/// `with_channel` require a user call to `close()`.
3935
class RobotClient {
4036
public:
4137
/// @enum status
@@ -88,8 +84,6 @@ class RobotClient {
8884
/// @brief Creates a robot client connected to the provided channel.
8985
/// @param channel The channel to connect with.
9086
/// @param options Options for connecting and refreshing.
91-
/// Connects directly to a pre-existing channel. A robot created this way must be
92-
/// `close()`d manually.
9387
static std::shared_ptr<RobotClient> with_channel(ViamChannel channel, const Options& options);
9488

9589
std::vector<Name> resource_names() const;
@@ -171,7 +165,6 @@ class RobotClient {
171165
unsigned int refresh_interval_;
172166

173167
ViamChannel viam_channel_;
174-
bool should_close_channel_;
175168

176169
struct impl;
177170
std::unique_ptr<impl> impl_;

src/viam/sdk/tests/test_robot.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ void robot_client_to_mocks_pipeline(F&& test_case) {
5555
// Run the passed-in test case on the created stack and give access to the
5656
// created RobotClient and MockRobotService.
5757
std::forward<F>(test_case)(client, service);
58-
59-
// Shutdown Server afterward.
60-
server->shutdown();
6158
}
6259

6360
BOOST_AUTO_TEST_CASE(test_registering_resources) {

0 commit comments

Comments
 (0)