Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Tensorflow Serving aspired versions manager builder h

From Leeroopedia
Knowledge Sources
Domains Model Serving, Core Framework
Last Updated 2026-02-13 00:00 GMT

Overview

AspiredVersionsManagerBuilder uses the builder pattern to construct an AspiredVersionsManager with connected sources and source adapter chains, managing their ownership and lifecycle.

Description

AspiredVersionsManagerBuilder simplifies the construction of an AspiredVersionsManager by handling the wiring of sources and source adapter chains. It takes ownership of all sources and adapters, and the resulting Manager handles destruction of itself and its dependencies in the correct order (via UniquePtrWithDeps).

The builder supports two modes of adding sources:

  • AddSource() - Connects a single Source<std::unique_ptr<Loader>> directly to the manager.
  • AddSourceChain() - Connects a chain of Source + SourceAdapters using variadic templates. The chain is wired recursively: each adapter is connected to the next, and the final adapter (which must emit std::unique_ptr<Loader>) is connected to the manager.

The AddSource() method uses static_assert to ensure the source type is convertible to Source<std::unique_ptr<Loader>>*. Dependencies are added to UniquePtrWithDeps in an order that ensures correct reverse-order destruction.

The builder can only be used to build a single manager. It is not thread-safe.

Usage

Use AspiredVersionsManagerBuilder when constructing the serving pipeline during server initialization. It is the standard way to wire up Sources and SourceAdapters to an AspiredVersionsManager while ensuring proper ownership and lifecycle management.

Code Reference

Source Location

  • Repository: Tensorflow_Serving
  • File: tensorflow_serving/core/aspired_versions_manager_builder.h
  • Lines: 1-152

Signature

class AspiredVersionsManagerBuilder {
 public:
  using Options = AspiredVersionsManager::Options;

  static Status Create(Options options,
                       std::unique_ptr<AspiredVersionsManagerBuilder>* builder);
  ~AspiredVersionsManagerBuilder() = default;

  template <typename S>
  void AddSource(std::unique_ptr<S> source);

  template <typename S, typename SA, typename... Args>
  void AddSourceChain(std::unique_ptr<S> source,
                      std::unique_ptr<SA> first_source_adapter,
                      std::unique_ptr<Args>... remaining_source_adapters);

  std::unique_ptr<Manager> Build();
};

Import

#include "tensorflow_serving/core/aspired_versions_manager_builder.h"

I/O Contract

Inputs

Name Type Required Description
options AspiredVersionsManager::Options Yes Configuration options for the underlying manager
source std::unique_ptr Yes A source to connect; must be convertible to Source<std::unique_ptr<Loader>>
first_source_adapter std::unique_ptr<SA> Yes (for chains) First adapter in the chain
remaining_source_adapters std::unique_ptr<Args>... No Additional adapters in the chain; final must emit std::unique_ptr<Loader>

Outputs

Name Type Description
Create() Status OK on success; returns the constructed builder
Build() std::unique_ptr<Manager> The fully wired AspiredVersionsManager with ownership of all dependencies

Usage Examples

Building a Manager with Source and Adapter Chain

#include "tensorflow_serving/core/aspired_versions_manager_builder.h"

using namespace tensorflow::serving;

AspiredVersionsManagerBuilder::Options options;
// ... configure options ...

std::unique_ptr<AspiredVersionsManagerBuilder> builder;
TF_CHECK_OK(AspiredVersionsManagerBuilder::Create(
    std::move(options), &builder));

// Add a direct source
builder->AddSource(std::move(loader_source));

// Add a source + adapter chain
builder->AddSourceChain(
    std::move(path_source),
    std::move(path_to_loader_adapter));

// Build the manager
std::unique_ptr<Manager> manager = builder->Build();

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment