mirror of
https://github.com/sogou/workflow.git
synced 2026-10-23 07:55:07 +08:00
add UpstreamManager::upstream_delete() implementation and update upstream_delete() ret, 0:success, -1:not existed.
This commit is contained in:
@@ -136,9 +136,21 @@ int UpstreamManager::upstream_remove_server(const std::string& name,
|
||||
WFNameService *ns = WFGlobal::get_name_service();
|
||||
UPSGroupPolicy *policy = dynamic_cast<UPSGroupPolicy *>(ns->get_policy(name.c_str()));
|
||||
|
||||
if (policy)
|
||||
return policy->remove_server(address);
|
||||
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int UpstreamManager::upstream_delete(const std::string& name)
|
||||
{
|
||||
WFNameService *ns = WFGlobal::get_name_service();
|
||||
WFNSPolicy *policy = ns->del_policy(name.c_str());
|
||||
|
||||
if (policy)
|
||||
{
|
||||
policy->remove_server(address);
|
||||
delete policy;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -131,8 +131,8 @@ public:
|
||||
* @brief Delete one upstream
|
||||
* @param[in] name upstream name
|
||||
* @return success/fail
|
||||
* @retval 0 fail, not found
|
||||
* @retval 1 success
|
||||
* @retval 0 success
|
||||
* @retval -1 fail, not found
|
||||
*/
|
||||
static int upstream_delete(const std::string& name);
|
||||
|
||||
|
||||
@@ -305,6 +305,9 @@ int main(int argc, char* argv[])
|
||||
|
||||
EXPECT_EQ(RUN_ALL_TESTS(), 0);
|
||||
|
||||
EXPECT_EQ(UpstreamManager::upstream_delete("try_another"), 0);
|
||||
EXPECT_EQ(UpstreamManager::upstream_delete("try_another"), -1);
|
||||
|
||||
http_server1.stop();
|
||||
http_server2.stop();
|
||||
http_server3.stop();
|
||||
|
||||
Reference in New Issue
Block a user