14#include <shared_mutex>
17namespace neograph::graph {
38 const json& initial_value = json());
45 json
get(
const std::string& channel)
const;
58 void write(
const std::string& channel,
const json& value);
109 std::map<std::string, Channel> channels_;
110 uint64_t global_version_ = 0;
111 mutable std::shared_mutex mutex_;
NEOGRAPH_API export/import macro for shared-library builds.
Thread-safe container for all graph state channels.
uint64_t channel_version(const std::string &channel) const
Get the version counter of a specific channel.
std::vector< ChatMessage > get_messages() const
Convenience method to read the "messages" channel as a vector of ChatMessage.
void write(const std::string &channel, const json &value)
Write a value to a single channel through its reducer (exclusive lock).
std::vector< std::string > channel_names() const
List all channel names in this state.
void restore(const json &data)
Restore state from a JSON snapshot (for time-travel).
void apply_writes(const std::vector< ChannelWrite > &writes)
Apply a batch of channel writes atomically (exclusive lock).
uint64_t global_version() const
Get the global version counter across all channels.
json serialize() const
Serialize the entire state to JSON (for checkpointing).
json get(const std::string &channel) const
Read a channel's current value (thread-safe, shared lock).
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.
Graph engine type definitions: channels, edges, nodes, events, and control flow.
std::function< json(const json ¤t, const json &incoming)> ReducerFn
Custom reducer function signature.
ReducerType
Strategy for merging values when writing to a channel.