/*************************************************************************** * * Copyright (c) 2018 Baidu.com, Inc. All Rights Reserved * **************************************************************************/ /** * @file endpoint_config.h * @author wanlijin01(wanlijin01@baidu.com) * @date 2018/07/12 15:17:56 * @brief * **/ #include "common.h" #include #ifndef BAIDU_PADDLE_SERVING_SDK_CPP_ENDPOINT_CONFIG_H #define BAIDU_PADDLE_SERVING_SDK_CPP_ENDPOINT_CONFIG_H namespace baidu { namespace paddle_serving { namespace sdk_cpp { #define PARSE_CONF_ITEM(conf, item, name, fail) \ do { \ if (conf.has_##name()) { \ item.set(conf.name()); \ } \ else { \ LOG(ERROR) << "Not found key in configue: " << #name;\ } \ } while (0) #define ASSIGN_CONF_ITEM(dest, src, fail) \ do { \ if (!src.init) { \ LOG(ERROR) << "Cannot assign an unintialized item: " \ << #src << " to dest: " << #dest; \ return fail; \ } \ dest = src.value; \ } while (0) template struct type_traits { static type_traits tag; }; template type_traits type_traits::tag; template struct ConfigItem { T value; bool init; ConfigItem() : init(false) {} void set(const T& unit) { value = unit; init = true; } }; struct Connection { ConfigItem tmo_conn; ConfigItem tmo_rpc; ConfigItem tmo_hedge; ConfigItem cnt_retry_conn; ConfigItem cnt_retry_hedge; ConfigItem cnt_maxconn_per_host; ConfigItem type_conn; }; struct NamingInfo { ConfigItem cluster_naming; ConfigItem load_balancer; ConfigItem cluster_filter; }; struct RpcParameters { ConfigItem protocol; ConfigItem compress_type; ConfigItem package_size; ConfigItem route_tag; ConfigItem max_channel; }; struct SplitParameters { ConfigItem split_tag; ConfigItem tag_cands_str; std::vector tag_values; }; struct VariantInfo { VariantInfo() {} Connection connection; NamingInfo naminginfo; RpcParameters parameters; SplitParameters splitinfo; }; struct EndpointInfo { EndpointInfo() : ab_test(NULL) {} std::string endpoint_name; std::string stub_service; std::vector vars; void* ab_test; }; } // sdk_cpp } // paddle_serving } // baidu #endif //BAIDU_PADDLE_SERVING_SDK_CPP_ENDPOINT_CONFIG_H /* vim: set expandtab ts=4 sw=4 sts=4 tw=100: */