Implementation:Tensorflow Serving static manager h
| Knowledge Sources | |
|---|---|
| Domains | Model Serving, Core Framework |
| Last Updated | 2026-02-13 00:00 GMT |
Overview
StaticManagerBuilder is a builder class that constructs an immutable Manager holding a static, fixed set of servables.
Description
StaticManagerBuilder provides a simple builder pattern for constructing a Manager that serves a pre-determined set of servables. The resulting manager is immutable and cannot be modified after construction. Internally, it wraps a BasicManager and uses SimpleLoader to wrap each servable object.
The builder works by calling AddServable() for each desired servable, which:
- Creates a
SimpleLoaderwrapping the servable using a move-capturing lambda as the creator. - Wraps it in
ServableDataviaCreateServableData(). - Transfers it to the underlying
BasicManagerviaManageServable(). - Synchronously loads the servable using
LoadServable()with a notification-based callback.
After all servables are added, Build() produces the final Manager. The builder should not be reused after Build() is called. Duplicate IDs and null servables are rejected with an error status.
Usage
Use StaticManagerBuilder when you have a fixed, known set of servables that should be loaded at startup and never changed. This is useful for testing, simple deployments, or embedding pre-built models directly in code.
Code Reference
Source Location
- Repository: Tensorflow_Serving
- File: tensorflow_serving/core/static_manager.h
- Lines: 1-90
Signature
class StaticManagerBuilder {
public:
StaticManagerBuilder();
template <typename T>
Status AddServable(const ServableId& id, std::unique_ptr<T> servable);
std::unique_ptr<Manager> Build();
};
Import
#include "tensorflow_serving/core/static_manager.h"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| id | const ServableId& | Yes | Unique identifier for the servable; duplicates are rejected |
| servable | std::unique_ptr<T> | Yes | The servable object to manage; must not be null |
Outputs
| Name | Type | Description |
|---|---|---|
| AddServable() | Status | OK on success; InvalidArgument if servable is null; error if duplicate ID or internal failure |
| Build() | std::unique_ptr<Manager> | The constructed immutable Manager ready for serving |
Usage Examples
Building a Static Manager
#include "tensorflow_serving/core/static_manager.h"
using namespace tensorflow::serving;
StaticManagerBuilder builder;
// Add servables
auto model_v1 = std::make_unique<MyModel>("config_v1");
TF_CHECK_OK(builder.AddServable({"my_model", 1}, std::move(model_v1)));
auto model_v2 = std::make_unique<MyModel>("config_v2");
TF_CHECK_OK(builder.AddServable({"my_model", 2}, std::move(model_v2)));
// Build the manager
std::unique_ptr<Manager> manager = builder.Build();
// Use the manager to get handles
ServableHandle<MyModel> handle;
TF_CHECK_OK(manager->GetServableHandle(
ServableRequest::Latest("my_model"), &handle));