16 #ifndef TENSORFLOW_SERVING_CORE_STATIC_MANAGER_H_
17 #define TENSORFLOW_SERVING_CORE_STATIC_MANAGER_H_
21 #include "tensorflow/core/lib/core/errors.h"
22 #include "tensorflow_serving/core/basic_manager.h"
23 #include "tensorflow_serving/core/manager.h"
24 #include "tensorflow_serving/core/servable_handle.h"
25 #include "tensorflow_serving/core/servable_id.h"
26 #include "tensorflow_serving/core/simple_loader.h"
28 namespace tensorflow {
43 Status AddServable(
const ServableId&
id, std::unique_ptr<T> servable);
46 std::unique_ptr<Manager> Build();
50 std::unique_ptr<BasicManager> basic_manager_;
61 Status StaticManagerBuilder::AddServable(
const ServableId&
id,
62 std::unique_ptr<T> servable) {
63 if (servable ==
nullptr) {
64 return errors::InvalidArgument(
"Servable cannot be null.");
66 TF_RETURN_IF_ERROR(health_);
67 DCHECK(basic_manager_ !=
nullptr);
69 TF_RETURN_IF_ERROR(basic_manager_->ManageServable(CreateServableData(
70 id, std::unique_ptr<Loader>(
new SimpleLoader<T>(
71 [&servable](std::unique_ptr<T>*
const returned_servable) {
72 *returned_servable = std::move(servable);
75 SimpleLoader<T>::EstimateNoResources())))));
77 Notification load_done;
78 basic_manager_->LoadServable(
id, [&](
const Status& status) {
82 load_done.WaitForNotification();