acelyc111 commented on code in PR #1464:
URL:
https://github.com/apache/incubator-pegasus/pull/1464#discussion_r1185655327
##########
src/runtime/rpc/rpc_host_port.cpp:
##########
@@ -113,4 +142,43 @@ void host_port::assign_group(const char *name)
_group_host_port->add_ref();
}
+error_s host_port::resolve_addresses(std::vector<rpc_address> &addresses) const
+{
+ CHECK(addresses.empty(), "invalid addresses, not empty");
+ if (type() != HOST_TYPE_IPV4) {
+ return std::move(error_s::make(dsn::ERR_INVALID_STATE, "invalid
host_port type"));
+ }
+
+ rpc_address rpc_addr;
+ if (rpc_addr.from_string_ipv4(this->to_string().c_str())) {
Review Comment:
Add some comments to explain why we can skip the following resolve logic if
call `from_string_ipv4` succeed.
##########
src/runtime/rpc/rpc_host_port.cpp:
##########
@@ -113,4 +142,43 @@ void host_port::assign_group(const char *name)
_group_host_port->add_ref();
}
+error_s host_port::resolve_addresses(std::vector<rpc_address> &addresses) const
+{
+ CHECK(addresses.empty(), "invalid addresses, not empty");
Review Comment:
```suggestion
CHECK(addresses.empty(), "");
```
Since the CHECK will print the content "addresses.empty()", so it's not
needed to print the message again, except it can show more extra information.
##########
src/runtime/rpc/rpc_host_port.cpp:
##########
@@ -113,4 +142,43 @@ void host_port::assign_group(const char *name)
_group_host_port->add_ref();
}
+error_s host_port::resolve_addresses(std::vector<rpc_address> &addresses) const
+{
+ CHECK(addresses.empty(), "invalid addresses, not empty");
+ if (type() != HOST_TYPE_IPV4) {
+ return std::move(error_s::make(dsn::ERR_INVALID_STATE, "invalid
host_port type"));
Review Comment:
Print the actual type in error message would be reasonable.
##########
src/runtime/rpc/dns_resolver.h:
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <vector>
+#include <unordered_map>
+
+#include "runtime/rpc/group_address.h"
+#include "runtime/rpc/group_host_port.h"
+#include "runtime/rpc/rpc_address.h"
+#include "runtime/rpc/rpc_host_port.h"
+#include "utils/errors.h"
+#include "utils/synchronize.h"
+
+namespace dsn {
+
+class dns_resolver
Review Comment:
It would be better to add some comments for the new class and its members.
##########
src/runtime/rpc/rpc_host_port.h:
##########
@@ -68,6 +69,8 @@ class host_port
}
void assign_group(const char *name);
+ error_s resolve_addresses(std::vector<rpc_address> &addresses) const;
Review Comment:
Add some comments for this public API.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]