NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
postgres_transition_store.h
Go to the documentation of this file.
1
5#pragma once
6
8
9#include <memory>
10#include <string>
11#include <string_view>
12
13namespace neograph::program {
14
23class NEOGRAPH_PROGRAM_API PostgreSQLProgramTransitionStore final
25public:
26 explicit PostgreSQLProgramTransitionStore(std::string connection_string);
32
33 std::string process_coordination_key() const override;
34
35 std::optional<ProgramRunPublicationHead> load_run_publication_head_sync(
36 std::string_view owner_scope, std::string_view run_id) const override;
37 std::optional<ProgramCommandPublicationHead> load_command_publication_head_sync(
38 std::string_view owner_scope, std::string_view run_id) const override;
39
40 std::optional<ProgramRunRecord> load_sync(std::string_view owner_scope,
41 std::string_view run_id) const override;
42 std::optional<ProgramJournalRecord> latest_sync(std::string_view owner_scope,
43 std::string_view run_id) const override;
44 std::vector<ProgramEvent> load_events_sync(std::string_view owner_scope,
45 std::string_view run_id,
46 std::uint64_t after_sequence = 0) const override;
47 std::vector<ProgramEffectOutboxEntry> load_effects_sync(
48 std::string_view owner_scope,
49 std::string_view run_id,
50 std::uint64_t after_sequence = 0) const override;
51 std::vector<ProgramJavaScriptCommandJournalEntry> load_javascript_commands_sync(
52 std::string_view owner_scope,
53 std::string_view run_id,
54 std::uint64_t after_sequence = 0) const override;
55 std::vector<ProgramContextPublication> load_context_publications_sync(
56 std::string_view owner_scope,
57 std::string_view run_id,
58 std::uint64_t after_sequence = 0) const override;
59 std::vector<HookOutboxEntry> load_hook_outbox_entries_sync(
60 std::string_view owner_scope, std::string_view run_id) const override;
61 std::vector<ProgramChildSynthesisRecord> load_child_syntheses_sync(
62 std::string_view owner_scope, std::string_view run_id) const override;
63 std::optional<MigrationPlan> load_migration_plan_sync(
64 std::string_view owner_scope, std::string_view run_id) const override;
65 std::optional<ProgramRunLineage> load_lineage_sync(
66 std::string_view owner_scope, std::string_view lineage_id) const override;
67 std::optional<ProgramRunLineage> load_run_lineage_sync(
68 std::string_view owner_scope, std::string_view run_id) const override;
69 std::optional<ProgramRunLineage> load_lineage_head_sync(
70 std::string_view owner_scope,
71 std::string_view lineage_id,
72 std::string_view head_id) const override;
73 std::optional<ProgramRunGeneration> load_generation_sync(
74 std::string_view owner_scope,
75 std::string_view lineage_id,
76 std::uint64_t generation) const override;
77 std::optional<ProgramTransitionPublication> load_generation_initial_publication_sync(
78 std::string_view owner_scope,
79 std::string_view lineage_id,
80 std::uint64_t generation) const override;
81 std::optional<GraphMigrationCapsule> load_graph_migration_capsule_sync(
82 std::string_view owner_scope,
83 std::string_view source_run_id,
84 std::string_view source_lineage_head_id) const override;
85 std::optional<ProgramExecutionLease> load_execution_lease_sync(
86 std::string_view owner_scope, std::string_view run_id) const override;
87
88 ProgramTransitionPublishResult compare_publish_sync(
89 std::string_view owner_scope,
90 std::string_view expected_journal_head,
91 ProgramTransitionPublication publication) override;
92 ProgramTransitionPublishResult compare_publish_execution_sync(
93 std::string_view owner_scope,
94 std::string_view expected_journal_head,
95 ProgramTransitionPublication publication,
96 std::optional<ProgramExecutionLease> expected_lease,
97 std::optional<ProgramExecutionLease> next_lease) override;
98 ProgramTransitionPublishResult compare_publish_graph_safe_point_sync(
99 std::string_view owner_scope,
100 std::string_view expected_journal_head,
101 ProgramTransitionPublication publication,
102 const ProgramGraphSafePointEvidence& evidence,
103 const GraphMigrationCapsule& capsule,
104 const ProgramExecutionLease& execution_lease) override;
105
106protected:
108 bool offloads() const noexcept override { return true; }
109
110private:
111 ProgramTransitionPublishResult compare_publish_impl(
112 std::string_view owner_scope,
113 std::string_view expected_journal_head,
114 ProgramTransitionPublication publication,
115 const ProgramGraphSafePointEvidence* evidence,
116 const GraphMigrationCapsule* capsule,
117 const ProgramExecutionLease* expected_lease,
118 const ProgramExecutionLease* next_lease);
119
120 struct Impl;
121 std::unique_ptr<Impl> impl_;
122};
123
124} // namespace neograph::program
Exact, content-addressed source evidence captured at a durable Core boundary.
Durable owner-scoped ProgramTransitionStore backed by PostgreSQL.
bool offloads() const noexcept override
libpq blocks for long: an awaited operation runs on a thread of the bounded pool (#556).
std::string process_coordination_key() const override
Process-local namespace used to coordinate wrappers over one backend.
Backend-global ownership of one migration-capable root Core dispatch.
Host-only, non-serializable evidence for one running safe-point publication.
Base of a ProgramTransitionStore whose backend is synchronous: the in-memory store,...
Atomic owner-scoped Program transition publication.