McrouterRouteHandlePtr makeFailoverWithExptimeRoute( RouteHandleFactory<McrouterRouteHandleIf>& factory, const folly::dynamic& json) { checkLogic(json.isObject(), "FailoverWithExptimeRoute is not an object"); auto jnormal = json.get_ptr("normal"); checkLogic(jnormal, "FailoverWithExptimeRoute: normal not found"); auto normal = factory.create(*jnormal); int32_t failoverExptime = 60; if (auto jexptime = json.get_ptr("failover_exptime")) { checkLogic(jexptime->isInt(), "FailoverWithExptimeRoute: " "failover_exptime is not an integer"); failoverExptime = jexptime->getInt(); } std::vector<McrouterRouteHandlePtr> failover; if (auto jfailover = json.get_ptr("failover")) { failover = factory.createList(*jfailover); } auto children = getFailoverChildren(std::move(normal), std::move(failover), failoverExptime); return makeFailoverRoute(json, std::move(children)); }
McrouterRouteHandlePtr makeFailoverWithExptimeRoute( McrouterRouteHandlePtr normal, std::vector<McrouterRouteHandlePtr> failover, int32_t failoverExptime, FailoverErrorsSettings failoverErrors) { auto children = getFailoverChildren(std::move(normal), std::move(failover), failoverExptime); return makeFailoverRoute(std::move(children), std::move(failoverErrors), /* failoverTagging */ false); }
McrouterRouteHandlePtr makeFailoverRoute( RouteHandleFactory<McrouterRouteHandleIf>& factory, const folly::dynamic& json) { std::vector<McrouterRouteHandlePtr> children; if (json.isObject()) { if (auto jchildren = json.get_ptr("children")) { children = factory.createList(*jchildren); } } else { children = factory.createList(json); } return makeFailoverRoute(json, std::move(children)); }
McrouterRouteHandlePtr makeFailoverRoute( const folly::dynamic& json, std::vector<McrouterRouteHandlePtr> children) { FailoverErrorsSettings failoverErrors; std::unique_ptr<FailoverRateLimiter> rateLimiter; bool failoverTagging = false; if (json.isObject()) { if (auto jFailoverErrors = json.get_ptr("failover_errors")) { failoverErrors = FailoverErrorsSettings(*jFailoverErrors); } if (auto jFailoverTag = json.get_ptr("failover_tag")) { checkLogic(jFailoverTag->isBool(), "Failover: failover_tag is not bool"); failoverTagging = jFailoverTag->getBool(); } if (auto jFailoverLimit = json.get_ptr("failover_limit")) { rateLimiter = folly::make_unique<FailoverRateLimiter>(*jFailoverLimit); } } return makeFailoverRoute(std::move(children), std::move(failoverErrors), std::move(rateLimiter), failoverTagging); }