mesos-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benno Evers <bev...@mesosphere.com>
Subject Re: Review Request 70885: Renamed 'libprocess::network::Address::hostname()'.
Date Mon, 12 Aug 2019 11:45:09 GMT


> On June 24, 2019, 4:20 p.m., Benjamin Mahler wrote:
> > 3rdparty/libprocess/include/process/address.hpp
> > Lines 65-68 (original), 70-74 (patched)
> > <https://reviews.apache.org/r/70885/diff/1/?file=2151346#file2151346line70>
> >
> >     It looks a little strange that stout's functions are hostname/getHostname but
libprocess' is lookup_hostname.
> >     
> >     Rather than change the name to signal the lookup, having this return a Future
seems sufficient to signal the asynchronous nature of this operation (per the existing TODO):
> >     
> >     ```
> >     Future<string> hostname = hostname();
> >     
> >     // or
> >     
> >     Future<vector<string>> hostnames = hostnames();
> >     ```
> >     
> >     That way, stout's `hostname()` is the synchronous blocking way to get it, and
libprocess' `hostname()` asynchronous non-blocking way to get it.
> >     
> >     I think that's generally the naming convention we'd like to stick to.

I think that changing the signature would not address the core of the problem, which is that
in code like


```
    host = address.hostname(); // `host` is some member variable
```

it would still be very hard for a reader to catch what's going on, unless he already has some
prior knowledge that `host` is a future or `hostname()` will do a lookup.

Even in this version, it is very easy to overlook the `.get()`, or assume it belongs to a
`Try`, `Option`, `shared_ptr`, etc.:

```
    string host = address.hostname().get();
```

Renaming, on the other hand, is unambigous and impossible to miss.

Regarding stout, `net::hostname()` actually does something *different* than the function we're
touching here, in particular it does **not** do a lookup. So it seems like the existing naming
was confusing enough to fool even you ;)


- Benno


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/70885/#review216094
-----------------------------------------------------------


On June 19, 2019, 2:44 p.m., Benno Evers wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/70885/
> -----------------------------------------------------------
> 
> (Updated June 19, 2019, 2:44 p.m.)
> 
> 
> Review request for mesos, Joseph Wu and Till Toenshoff.
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Renamed member function `hostname()` to `lookup_hostname()`,
> since the former name hides the fact that a call to this
> function involves a synchronous network access in order
> to make a reverse DNS lookup.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/include/process/address.hpp e740e840c38381bafd7a1a7fcde5f963832ac1fb

>   3rdparty/libprocess/src/tests/http_tests.cpp 97aaf3ed3d4fab6d717d5c9b6d12402562ac6b46

>   3rdparty/libprocess/src/tests/ssl_tests.cpp 6b8496aeeed79ae1bd39d7013f4f403b248fdd4c

> 
> 
> Diff: https://reviews.apache.org/r/70885/diff/1/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Benno Evers
> 
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message