mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 14:28:17 +03:00
make selection.hosts a shared_ptr
Differential Revision: D17412196 fbshipit-source-id: 872e7e6332284fa00b52e03ce237adeea32fd852
This commit is contained in:
parent
ad930efa69
commit
9a0585ba15
@ -45,13 +45,13 @@ std::optional<SocketAddressWithHostname> ServiceAddress::addressFromSMCTier(
|
||||
#ifdef EDEN_HAVE_SERVICEROUTER
|
||||
auto selection = selector->getSelection(std::get<std::string>(name_));
|
||||
|
||||
if (selection.hosts.empty()) {
|
||||
if (selection.hosts->empty()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// TODO(zeyi, t42568801): better host selection algorithm
|
||||
auto selected = folly::Random::rand32(selection.hosts.size());
|
||||
const auto& host = selection.hosts[selected];
|
||||
auto selected = folly::Random::rand32(selection.hosts->size());
|
||||
const auto& host = selection.hosts->at(selected);
|
||||
auto location = host->location();
|
||||
|
||||
return std::make_pair(
|
||||
|
@ -50,8 +50,9 @@ class MockServiceCacheIf : public ServiceCacheIf {
|
||||
auto location = std::make_shared<HostInfoLocation>("::1", 1234);
|
||||
location->setHostname("some-hostname");
|
||||
|
||||
selection.hosts.push_back(std::make_shared<HostInfo>(
|
||||
std::make_unique<HostInfoProperties>(), std::move(location)));
|
||||
const_cast<ServiceHosts*>(selection.hosts.get())
|
||||
->push_back(std::make_shared<HostInfo>(
|
||||
std::make_unique<HostInfoProperties>(), std::move(location)));
|
||||
}
|
||||
|
||||
return selection;
|
||||
|
Loading…
Reference in New Issue
Block a user