|
NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
|
Thread-safe container for all graph state channels. More...
#include <state.h>
Public Member Functions | |
| void | apply_writes (const std::vector< ChannelWrite > &writes) |
| Apply a batch of channel writes atomically (exclusive lock). | |
| std::vector< std::string > | channel_names () const |
| List all channel names in this state. | |
| uint64_t | channel_version (const std::string &channel) const |
| Get the version counter of a specific channel. | |
| json | get (const std::string &channel) const |
| Read a channel's current value (thread-safe, shared lock). | |
| std::vector< ChatMessage > | get_messages () const |
| Convenience method to read the "messages" channel as a vector of ChatMessage. | |
| uint64_t | global_version () const |
| Get the global version counter across all channels. | |
| void | init_channel (const std::string &name, ReducerType type, ReducerFn reducer, const json &initial_value=json()) |
| Initialize a new channel with a reducer and optional initial value. | |
| void | restore (const json &data) |
| Restore state from a JSON snapshot (for time-travel). | |
| json | serialize () const |
| Serialize the entire state to JSON (for checkpointing). | |
| void | write (const std::string &channel, const json &value) |
| Write a value to a single channel through its reducer (exclusive lock). | |
Thread-safe container for all graph state channels.
Provides concurrent read access (shared lock) and exclusive write access (unique lock) to state channels. Supports serialization for checkpointing and version tracking for change detection.
| void neograph::graph::GraphState::apply_writes | ( | const std::vector< ChannelWrite > & | writes | ) |
Apply a batch of channel writes atomically (exclusive lock).
All writes in the batch are applied under a single lock acquisition, ensuring consistency when multiple channels must be updated together.
| writes | Vector of ChannelWrite objects to apply. |
| std::vector< std::string > neograph::graph::GraphState::channel_names | ( | ) | const |
List all channel names in this state.
| uint64_t neograph::graph::GraphState::channel_version | ( | const std::string & | channel | ) | const |
Get the version counter of a specific channel.
| channel | Channel name. |
| json neograph::graph::GraphState::get | ( | const std::string & | channel | ) | const |
Read a channel's current value (thread-safe, shared lock).
| channel | Channel name. |
| std::vector< ChatMessage > neograph::graph::GraphState::get_messages | ( | ) | const |
Convenience method to read the "messages" channel as a vector of ChatMessage.
| uint64_t neograph::graph::GraphState::global_version | ( | ) | const |
Get the global version counter across all channels.
| void neograph::graph::GraphState::init_channel | ( | const std::string & | name, |
| ReducerType | type, | ||
| ReducerFn | reducer, | ||
| const json & | initial_value = json() |
||
| ) |
Initialize a new channel with a reducer and optional initial value.
| name | Channel name (must be unique within the graph). |
| type | Reducer strategy for merging writes. |
| reducer | Custom reducer function (used when type == ReducerType::CUSTOM). |
| initial_value | Initial channel value (default: null). |
| void neograph::graph::GraphState::restore | ( | const json & | data | ) |
Restore state from a JSON snapshot (for time-travel).
| data | JSON object previously produced by serialize(). |
| json neograph::graph::GraphState::serialize | ( | ) | const |
Serialize the entire state to JSON (for checkpointing).
| void neograph::graph::GraphState::write | ( | const std::string & | channel, |
| const json & | value | ||
| ) |
Write a value to a single channel through its reducer (exclusive lock).
| channel | Channel name. |
| value | Value to merge via the channel's reducer. |