Problem Summary:
Now the etcd client address do not support host format such as
http://[ipv6]:port.
and [RFC
3986](https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2)
```
A host identified by an Internet Protocol literal address, version 6
[[RFC3513](https://datatracker.ietf.org/doc/html/rfc3513)] or later, is distinguished by enclosing the IP literal
within square brackets ("[" and "]"). This is the only place where
square bracket characters are allowed in the URI syntax. In
anticipation of future, as-yet-undefined IP literal address formats,
an implementation may use an optional version flag to indicate such a
format explicitly rather than rely on heuristic determination.
IP-literal = "[" ( IPv6address / IPvFuture ) "]"
```
the ipv6 address is distinguished by enclosing the IP literal within
square brackets ("[" and "]").
What is changed and how it works:
if we find the host part of a URL starts with a "[" and ends with a "]".
it will be specifically judged whether it is a valid IPv6 address. If it
is a valid address, it can be returned directly without call the
`getaddrinfo` interface.
remove rm_if interface param: value in README.md
rm_if define as below:
```
/**
* Removes a single key but only if it has a specific value. Fails if the key
* does not exists or the its value differs from the expected one.
* @param key is the key to be deleted
*
* @return Returns etcdv3::ERROR_KEY_NOT_FOUND if the key does not exist.
*/
pplx::task<Response> rm_if(std::string const& key,
std::string const& old_value);
/**
* Removes an existing key only if it has a specific modification index value.
* Fails if the key does not exists or the modification index of it differs
* from the expected one.
* @param key is the key to be deleted
* @param old_index is the expected index of the existing value
*
* @return Returns etcdv3::ERROR_KEY_NOT_FOUND if the key does not exist.
*/
pplx::task<Response> rm_if(std::string const& key, int64_t old_index);
```
To compile protobuf, CMake needs to use the protoc and grpc-cpp-plugin
in the host architecture.
Unfortunately by default the protoc and grpc-cpp-plugin are the one for
the Target.
And since gRPC 1.52 they are explictly not exported when Cross Compiling
to avoid architecture mismatch.
See:
831d2a6855
Fix this by looking at the correct program
See example.
https://github.com/grpc/grpc/blob/master/examples/cpp/cmake/common.cmake#L54-L62
Signed-off-by: Clément Péron <peron.clem@gmail.com>
When I [Update](https://github.com/microsoft/vcpkg/pull/32747)
etcd-cpp-apiv3 version from 0.14.2 to 0.15.2, I get two build error:
````
fatal error LNK1107: invalid or corrupt file: cannot read at 0x330
````
````
error: use of undeclared identifier 'IPPROTO_TCP'
````
The first error was because the target `etcd-cpp-api-core-objects`
linked the wrong `libprotobufd.dll` file instead of the .lib file, I
used the usage provided by vcpkg to link the correct .lib file to fix
this error.
Another error was because `IPPROTO_TCP` was missing declaration
`"<netinet/in.h>"`, I added it to fix this error.
---------
Signed-off-by: Tao He <linzhu.ht@alibaba-inc.com>
Co-authored-by: Zhao Liu <v-zhli17@microsoft.com>
Co-authored-by: Tao He <linzhu.ht@alibaba-inc.com>