16 #ifndef TENSORFLOW_SERVING_CORE_STATIC_SOURCE_ROUTER_H_
17 #define TENSORFLOW_SERVING_CORE_STATIC_SOURCE_ROUTER_H_
23 #include "tensorflow/core/lib/strings/str_util.h"
24 #include "tensorflow/core/platform/macros.h"
25 #include "tensorflow_serving/core/source_router.h"
27 namespace tensorflow {
42 static Status Create(
const std::vector<string>& route_substrings,
47 int num_output_ports()
const override {
48 return routes_except_default_.size() + 1;
51 int Route(
const StringPiece servable_name,
59 std::vector<string> routes_except_default_;
69 const std::vector<string>& route_substrings,
76 StaticSourceRouter<T>::~StaticSourceRouter() {
77 TargetBase<T>::Detach();
81 int StaticSourceRouter<T>::Route(
const StringPiece servable_name,
82 const std::vector<ServableData<T>>& versions) {
83 for (
int i = 0; i < routes_except_default_.size(); ++i) {
84 if (str_util::StrContains(servable_name, routes_except_default_[i])) {
85 VLOG(2) <<
"Routing servable(s) from stream " << servable_name
91 VLOG(2) <<
"Routing servable(s) from stream " << servable_name
92 <<
" to default route " << routes_except_default_.size();
93 return routes_except_default_.size();
97 StaticSourceRouter<T>::StaticSourceRouter(
98 const std::vector<string>& route_substrings)
99 : routes_except_default_(route_substrings) {}