@@ -52,24 +52,35 @@ ViamChannel::ViamChannel(std::shared_ptr<grpc::Channel> channel, const char* pat
5252
5353DialOptions::DialOptions () = default ;
5454
55- void DialOptions::set_credentials (boost::optional<Credentials> creds) {
55+ DialOptions& DialOptions::set_credentials (boost::optional<Credentials> creds) {
5656 credentials_ = std::move (creds);
57+
58+ return *this ;
5759}
5860
59- void DialOptions::set_entity (boost::optional<std::string> entity) {
61+ DialOptions& DialOptions::set_entity (boost::optional<std::string> entity) {
6062 auth_entity_ = std::move (entity);
63+
64+ return *this ;
6165}
6266
63- void DialOptions::set_initial_connection_attempts (int attempts) {
67+ DialOptions& DialOptions::set_initial_connection_attempts (int attempts) {
6468 initial_connection_attempts_ = attempts;
69+
70+ return *this ;
6571}
6672
67- void DialOptions::set_timeout (std::chrono::duration<float > timeout) {
68- timeout_ = std::move (timeout);
73+ DialOptions& DialOptions::set_timeout (std::chrono::duration<float > timeout) {
74+ timeout_ = timeout;
75+
76+ return *this ;
6977}
7078
71- void DialOptions::set_initial_connection_attempt_timeout (std::chrono::duration<float > timeout) {
72- initial_connection_attempt_timeout_ = std::move (timeout);
79+ DialOptions& DialOptions::set_initial_connection_attempt_timeout (
80+ std::chrono::duration<float > timeout) {
81+ initial_connection_attempt_timeout_ = timeout;
82+
83+ return *this ;
7384}
7485
7586const boost::optional<std::string>& DialOptions::entity () const {
@@ -88,25 +99,22 @@ const std::chrono::duration<float>& DialOptions::timeout() const {
8899 return timeout_;
89100}
90101
91- const std::chrono::duration<float >& DialOptions::initial_connection_attempt_timeout () const {
102+ std::chrono::duration<float > DialOptions::initial_connection_attempt_timeout () const {
92103 return initial_connection_attempt_timeout_;
93104}
94105
95- void DialOptions::set_allow_insecure_downgrade (bool allow) {
106+ DialOptions& DialOptions::set_allow_insecure_downgrade (bool allow) {
96107 allow_insecure_downgrade_ = allow;
108+
109+ return *this ;
97110}
98111
99112bool DialOptions::allows_insecure_downgrade () const {
100113 return allow_insecure_downgrade_;
101114}
102115
103- std::shared_ptr<ViamChannel> ViamChannel::dial (const char * uri,
104- const boost::optional<DialOptions>& options,
105- bool initial_attempt) {
106- if (!initial_attempt) {
107- return dial (std::move (uri), options);
108- }
109-
116+ std::shared_ptr<ViamChannel> ViamChannel::dial_initial (
117+ const char * uri, const boost::optional<DialOptions>& options) {
110118 DialOptions opts = options.get_value_or (DialOptions ());
111119 auto timeout = opts.timeout ();
112120 auto attempts_remaining = opts.initial_connection_attempts ();
@@ -120,7 +128,7 @@ std::shared_ptr<ViamChannel> ViamChannel::dial(const char* uri,
120128 auto connection = dial (uri, opts);
121129 opts.set_timeout (timeout);
122130 return connection;
123- } catch (... ) {
131+ } catch (const std::exception& ) {
124132 attempts_remaining -= 1 ;
125133 }
126134 }
0 commit comments