NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
neograph::graph::ReducerRegistry Class Reference

Singleton registry for channel reducer functions. More...

#include <loader.h>

Public Member Functions

ReducerFn get (const std::string &name) const
 Look up a reducer by name.
 
std::vector< std::string > names () const
 List all registered reducer names, sorted.
 
void register_reducer (const std::string &name, ReducerFn fn)
 Register a named reducer function.
 

Static Public Member Functions

static ReducerRegistryinstance ()
 Get the singleton instance.
 

Detailed Description

Singleton registry for channel reducer functions.

Maps reducer names (used in JSON graph definitions) to ReducerFn implementations. Built-in reducers: "overwrite", "append".

[](const json& current, const json& incoming) {
return current.get<int>() + incoming.get<int>();
});
void register_reducer(const std::string &name, ReducerFn fn)
Register a named reducer function.
static ReducerRegistry & instance()
Get the singleton instance.
Note
Process-wide singleton.

ReducerRegistry, ConditionRegistry, and NodeFactory are global state shared across every GraphEngine in the process. This is fine for most embeddings (a single host process compiling its graphs once), but it has caveats:

  • Two embedders coexisting in the same process can't register conflicting reducer/condition/node-type names without stepping on each other.
  • Test isolation: the registries persist across test cases, so a node-type registered in one test is visible in subsequent tests; tests must use unique type names or deregister.
  • Pybind users: state survives pytest-case boundaries.

A future major version (v1.0) is expected to thread per-engine Registry instances through NodeContext/compile(), with the global singleton kept as a default-fallback layer. Until then, avoid duplicate registrations across test cases / embedders.

Definition at line 56 of file loader.h.

Member Function Documentation

◆ get()

ReducerFn neograph::graph::ReducerRegistry::get ( const std::string &  name) const

Look up a reducer by name.

Parameters
nameReducer name.
Returns
The ReducerFn, or throws if not found.

◆ instance()

static ReducerRegistry & neograph::graph::ReducerRegistry::instance ( )
static

Get the singleton instance.

Returns
Reference to the global ReducerRegistry.

◆ names()

std::vector< std::string > neograph::graph::ReducerRegistry::names ( ) const

List all registered reducer names, sorted.

Introspection accessor for external tooling (e.g. a visual topology editor) that needs to enumerate the available reducer palette without grepping engine source.

Returns
Sorted vector of reducer names.

◆ register_reducer()

void neograph::graph::ReducerRegistry::register_reducer ( const std::string &  name,
ReducerFn  fn 
)

Register a named reducer function.

Parameters
nameReducer name (referenced in JSON channel definitions).
fnReducer function that merges current and incoming values.

The documentation for this class was generated from the following file: