Everett
Loading...
Searching...
No Matches
connection.h
Go to the documentation of this file.
1
12#pragma once
13
14#include <everett/multiverse.h>
20#include <everett/typed_world.h>
21#include <everett/typed_scan.h>
22
23#include <concepts>
24#include <cstdint>
25#include <exception>
26#include <filesystem>
27#include <memory>
28#include <optional>
29#include <stdexcept>
30#include <string>
31#include <string_view>
32#include <type_traits>
33#include <utility>
34#include <variant>
35
36namespace everett {
38 // Empty selects Core's default. Custom registries require an explicit,
39 // stable identity for their ordering, codecs, hashing and semantics.
40 std::string schema_id{};
41 bool create_if_missing = true;
42 // Omitted limits use this Core's quote for 1024 record-equivalents.
43 // Explicit limits are honored exactly, including a zero work/byte limit.
44 std::optional<session_limits> limits{};
45 };
46
47 namespace connection_detail { struct logical_state {}; }
48 template <class Core> struct transaction;
49
50 struct transaction_conflict : std::runtime_error {
51 transaction_conflict() : std::runtime_error("transaction base is no longer current") {}
52 };
53
54 template <class World> struct stored_world : World {
56 std::shared_ptr<connection_detail::logical_state const> logical = std::make_shared<connection_detail::logical_state>())
57 : World(std::move(value)), head_(std::make_shared<catalog_session_head const>(std::move(head))), logical_(std::move(logical)) {}
58 catalog_session_head const & head() const & noexcept { return *head_; }
59 catalog_session_head const & head() const && = delete;
60 auto logical_identity() const noexcept { return logical_; }
61 private:
62 std::shared_ptr<catalog_session_head const> head_;
63 std::shared_ptr<connection_detail::logical_state const> logical_;
64 };
65
66 namespace connection_detail {
67 template <class Core> auto restore_checkpoint(typename Core::runtime_family::snapshot_type runtime,
68 std::span<std::byte const> semantic, std::string_view schema) {
69 if constexpr (requires { Core::restore_checkpoint(std::move(runtime), semantic, schema); })
70 return Core::restore_checkpoint(std::move(runtime), semantic, schema);
71 else {
72 auto metadata = Core::metadata_type::decode(semantic);
73 return Core::world_type::restore(std::move(runtime), std::move(metadata), schema);
74 }
75 }
76 }
77
78 // Single-threaded durable Engine for session. Core owns interpretation and
79 // private merge continuations; the published snapshot is always mmap-backed.
80 template <class Core = active_engine<>, class Ids = random_object_ids> struct persistent_engine {
81 using core_type = Core;
82 using family_type = typename Core::runtime_family;
83 using policy_type = typename Core::policy_type;
84 using typed_world_type = typename Core::world_type;
86 using ordinary_contribution = typename Core::contribution_type;
88 std::shared_ptr<private_construction<policy_type>> scope;
90 std::unique_ptr<Core> core;
91 prepared_transaction(std::unique_ptr<Core> candidate, world_type original,
92 std::shared_ptr<private_construction<policy_type>> lease)
93 : scope(std::move(lease)), base(std::move(original)), core(std::move(candidate)) {}
94 };
95 // The temporary borrowed form lets session reserve capacity before it copies
96 // or moves an ordinary command. Only an owning form enters the worker queue.
99 using value_type = std::variant<ordinary_contribution, prepared_transaction, borrowed>;
101 contribution_type(ordinary_contribution input) : value(std::move(input)) {}
102 contribution_type(prepared_transaction input) : value(std::move(input)) {}
103 explicit contribution_type(borrowed input) : value(input) {}
108 template <class C> requires std::constructible_from<ordinary_contribution, C &&>
109 static contribution_type borrow(C && input) {
110 if constexpr (std::is_rvalue_reference_v<C &&> && !std::is_const_v<std::remove_reference_t<C>>)
111 return contribution_type(borrowed{&input, &input});
112 else return contribution_type(borrowed{&input, nullptr});
113 }
114 private:
115 static auto take(contribution_type & other) -> value_type {
116 if (auto p = std::get_if<borrowed>(&other.value)) {
117 if (p->move) return value_type(std::in_place_index<0>, std::move(*p->move));
118 if constexpr (std::copy_constructible<ordinary_contribution>)
119 return value_type(std::in_place_index<0>, *p->copy);
120 else throw std::logic_error("move-only command requires an rvalue");
121 }
122 return std::move(other.value);
123 }
124 };
125 using metadata_type = typename Core::metadata_type;
127
128 // The directory must already exist durably. Catalog creation is exclusive;
129 // a competing creator can fail this call, but no existing file is formatted.
130 static persistent_engine connect(std::filesystem::path const & root, std::string_view name,
131 connection_options const & options = {}, Ids ids = {}) {
133 Core seed = options.schema_id.empty() ? Core{} : Core(options.schema_id);
134 auto initial = seed.snapshot();
135 auto schema = initial.metadata().schema_id;
136 auto store = open_store(root, options.create_if_missing, std::move(ids));
137 auto found = store.find(name);
138 if (!found) {
139 if (!options.create_if_missing) throw std::out_of_range("unknown named Everett session");
140 found.emplace(store.create_session(name, initial.runtime(), initial.metadata().encode()));
141 }
142 auto current = restore(std::move(*found), schema);
143 auto core = [&] {
144 if constexpr (requires { family_type::open_storage(store.root(), schema); })
145 return Core::from_snapshot(current, family_type::open_storage(store.root(), schema));
146 else if constexpr (requires { family_type::open_storage(store.root()); })
147 return Core::from_snapshot(current, family_type::open_storage(store.root()));
148 else return Core::from_snapshot(current);
149 }();
150 return persistent_engine(std::move(store), std::move(core), std::move(current), std::move(schema));
151 }
154 persistent_engine(persistent_engine &&) noexcept(std::is_nothrow_move_constructible_v<store_type> &&
155 std::is_nothrow_move_constructible_v<Core> && std::is_nothrow_move_constructible_v<world_type>) = default;
156 persistent_engine & operator=(persistent_engine &&) = delete;
157
158 template <class C> requires std::same_as<std::remove_cvref_t<C>, ordinary_contribution> &&
159 std::constructible_from<ordinary_contribution, C &&>
161 return contribution_type::borrow(std::forward<C>(input));
162 }
164 if (auto ordinary = std::get_if<ordinary_contribution>(&input.value)) return Core::reservation(*ordinary);
165 if (auto borrowed = std::get_if<typename contribution_type::borrowed>(&input.value))
166 return Core::reservation(*borrowed->copy);
167 // Private execution has already paid its structural work. The queue still
168 // reserves one contribution until publication is acknowledged.
169 return {};
170 }
171 world_type snapshot() const { return current_; }
172 bool failed() const noexcept { return failed_ || core_->failed() || store_.failed(); }
173 bool pending() const noexcept { return core_->pending(); }
174 bool admission_ready() const noexcept { return !failed() && core_->admission_ready(); }
175 std::string const & last_operation() const noexcept {
176 if (catalog_failure_) {
177 try { std::rethrow_exception(catalog_failure_); }
178 catch (catalog_error const & error) { return error.operation; }
179 catch (...) {}
180 }
181 return store_.last_operation();
182 }
183
186 if (auto prepared = std::get_if<prepared_transaction>(&input.value))
187 return install(std::move(*prepared));
188 if (!std::holds_alternative<ordinary_contribution>(input.value))
189 throw std::logic_error("borrowed contribution escaped admission");
190 return contribute_ordinary(std::move(std::get<ordinary_contribution>(input.value)));
191 }
194 // Only empty input needs this comparison. A pending Core can own a
195 // different physical layout from the last mapped durable publication.
196 std::optional<typed_world_type> before;
197 if constexpr (requires { input.records().empty(); })
198 if (input.records().empty()) before.emplace(core_->snapshot());
199 // Core's healthy failure contract means no logical update was admitted.
200 // Encoding, old-value validation and an absent deletion can reject just
201 // this ticket; publication failures may never take that path.
202 auto updated = [&] {
203 try { return core_->contribute(std::move(input)); }
204 catch (...) { remember_failure(); if (core_->failed()) poison(); throw; }
205 }();
206 try {
207 if (before && updated.runtime().same_layout(before->runtime()) && updated.metadata() == before->metadata())
208 return current_;
209 return publish(std::move(updated), true);
210 } catch (...) { remember_failure(); poison(); throw; }
211 }
212 std::optional<world_type> advance(std::uint64_t budget) {
214 try {
215 auto updated = core_->advance(budget);
216 if (!updated) return std::nullopt;
217 return publish(std::move(*updated), false);
218 } catch (...) { remember_failure(); poison(); throw; }
219 }
220
221 private:
223 std::shared_ptr<private_construction<policy_type>> core_scope_;
224 std::unique_ptr<Core> core_;
226 std::string schema_;
227 std::exception_ptr catalog_failure_;
228 bool failed_ = false;
229
230 persistent_engine(store_type store, Core core, world_type current, std::string schema)
231 : store_(std::move(store)), core_(std::make_unique<Core>(std::move(core))), current_(std::move(current)), schema_(std::move(schema)) {}
232 static store_type open_store(std::filesystem::path const & root, bool create, Ids ids) {
233 if (!std::filesystem::is_directory(root)) throw std::invalid_argument("Everett backing directory must already exist");
234 if (std::filesystem::exists(root / "catalog.sqlite3") || !create)
235 return store_type::open(root, std::move(ids));
236 return store_type::create(root, std::move(ids));
237 }
238 static world_type restore(typename store_type::stored_type saved, std::string_view schema,
239 std::shared_ptr<connection_detail::logical_state const> logical = std::make_shared<connection_detail::logical_state>()) {
240 auto world = connection_detail::restore_checkpoint<Core>(std::move(saved.snapshot), saved.semantic, schema);
241 return {std::move(world), std::move(saved.head), std::move(logical)};
242 }
243 world_type publish(typed_world_type updated, bool mutation) {
244 auto saved = store_.publish(current_.head(), updated.runtime(), updated.metadata().encode());
245 auto mapped = restore(std::move(saved), schema_, mutation ?
246 std::make_shared<connection_detail::logical_state>() : current_.logical_identity());
247 // Keep partial builders alive until their carry completes. Restarting the
248 // Core on every equivalent publication would discard paid private work.
249 if (!core_->pending()) {
250 if constexpr (requires { core_->rebase(mapped); }) core_->rebase(mapped);
251 else core_ = std::make_unique<Core>(Core::from_snapshot(mapped));
252 }
253 current_ = std::move(mapped);
254 catalog_failure_ = nullptr;
255 return current_;
256 }
259 if (!input.core) return current_;
260 try {
261 auto updated = input.core->snapshot();
262 auto saved = store_.publish(current_.head(), updated.runtime(), updated.metadata().encode());
263 auto mapped = restore(std::move(saved), schema_);
264 if (!input.core->pending()) {
265 if constexpr (requires { input.core->rebase(mapped); }) input.core->rebase(mapped);
266 else input.core = std::make_unique<Core>(Core::from_snapshot(mapped));
267 }
268 // mapped owns the acknowledged graph before either old executor or its
269 // construction lease is released. Keep the candidate's private jobs.
270 core_ = std::move(input.core);
271 core_scope_ = std::move(input.scope);
272 current_ = std::move(mapped);
273 catalog_failure_ = nullptr;
274 return current_;
275 } catch (...) { remember_failure(); poison(); throw; }
276 }
277 void remember_failure() noexcept {
278 // A streamed Core has its own catalog connection. Keep its exact error
279 // alive without copying the operation string while handling a failure.
280 try { throw; }
281 catch (catalog_error const &) { catalog_failure_ = std::current_exception(); }
282 catch (...) { catalog_failure_ = nullptr; }
283 }
284 void require_active() const { if (failed()) throw std::logic_error("failed persistent Everett engine; reconnect it"); }
285 void poison() noexcept {
286 failed_ = true;
287 if constexpr (requires { { core_->poison() } noexcept; }) core_->poison();
288 }
289 };
290
291 // Ordinary callers use the mutable connection; snapshots retain the same
292 // conditional update API as typed_world. Catalog operations below open their
293 // own connection and never touch the worker's SQLite handle.
294 template <class Core = active_engine<>> struct connection {
295 using core_type = Core;
296 using policy_type = typename Core::policy_type;
300 using contribution_type = typename Core::contribution_type;
302 using ticket = typename session_type::ticket;
305
306 connection(std::filesystem::path const & root, std::string_view name, connection_options options = {})
307 : root_(std::filesystem::canonical(root)), options_(checked_options(std::move(options))),
308 session_(std::make_shared<session_type>(engine_type::connect(root_, name, options_), *options_.limits)) {}
309 connection(connection const &) = delete;
310 connection & operator=(connection const &) = delete;
311 connection(connection &&) = delete;
313
314 ~connection() { session_->shutdown(); }
316 world_type snapshot() const { return session_->snapshot()->world; }
317 session_limits limits() const noexcept { return *options_.limits; }
318 publication_type publication() const noexcept { return session_->snapshot(); }
319 std::filesystem::path const & root() const & noexcept { return root_; }
320 std::filesystem::path const & root() const && = delete;
321 template <class S = typed_detail::default_sort_t<policy_type>> auto range(
322 std::optional<typed_detail::key_t<S>> lo = {}, std::optional<typed_detail::key_t<S>> hi = {}) const {
323 return everett::range<S>(snapshot(), std::move(lo), std::move(hi));
324 }
325 template <class S = typed_detail::default_sort_t<policy_type>> world_type erase_range(
326 std::optional<typed_detail::key_t<S>> lo = {}, std::optional<typed_detail::key_t<S>> hi = {})
327 requires typed_detail::replacement<S> {
328 return apply(everett::erase_range<S>(snapshot(), std::move(lo), std::move(hi)));
329 }
330 template <class S = typed_detail::default_sort_t<policy_type>> ticket erase_range_async(
331 std::optional<typed_detail::key_t<S>> lo = {}, std::optional<typed_detail::key_t<S>> hi = {})
332 requires typed_detail::replacement<S> {
333 return submit(everett::erase_range<S>(snapshot(), std::move(lo), std::move(hi)));
334 }
335 template <class S = typed_detail::default_sort_t<policy_type>> auto get(typed_detail::key_t<S> const & key) const {
336 return session_->snapshot()->world.template get<S>(key);
337 }
338 template <class S = typed_detail::default_sort_t<policy_type>> world_type put(
339 typed_detail::key_t<S> const & key, typed_detail::state_t<S> const & value)
340 requires typed_detail::replacement<S> { return apply(Core::template put<S>(key, value)); }
341 template <class S = typed_detail::default_sort_t<policy_type>> world_type erase(typed_detail::key_t<S> const & key)
342 requires typed_detail::replacement<S> { return apply(Core::template erase<S>(key)); }
343 template <class S = typed_detail::default_sort_t<policy_type>> world_type change(
344 typed_detail::key_t<S> const & key, typed_detail::arrow_t<S> const & arrow) {
345 return apply(Core::template change<S>(key, arrow));
346 }
347 template <class S = typed_detail::default_sort_t<policy_type>> ticket put_async(
348 typed_detail::key_t<S> const & key, typed_detail::state_t<S> const & value)
349 requires typed_detail::replacement<S> { return submit(Core::template put<S>(key, value)); }
350 template <class S = typed_detail::default_sort_t<policy_type>> ticket erase_async(typed_detail::key_t<S> const & key)
351 requires typed_detail::replacement<S> { return submit(Core::template erase<S>(key)); }
352 template <class S = typed_detail::default_sort_t<policy_type>> ticket change_async(
353 typed_detail::key_t<S> const & key, typed_detail::arrow_t<S> const & arrow) {
354 return submit(Core::template change<S>(key, arrow));
355 }
356
357 template <class C> requires std::same_as<std::remove_cvref_t<C>, contribution_type>
358 std::optional<ticket> try_submit(C && value) { return session_->try_submit(engine_type::contribution_type::borrow(std::forward<C>(value))); }
359 template <class C> requires std::same_as<std::remove_cvref_t<C>, contribution_type>
360 ticket submit(C && value) { return session_->submit(engine_type::contribution_type::borrow(std::forward<C>(value))); }
361 template <class C> requires std::same_as<std::remove_cvref_t<C>, contribution_type>
362 world_type apply(C && value) { return submit(std::forward<C>(value)).get()->world; }
363 bool cancel(ticket const & value) { return session_->cancel(value); }
364 session_reservation outstanding() const { return session_->outstanding(); }
365 std::uint64_t pending_count() const { return session_->pending_count(); }
366 std::exception_ptr failure() const { return session_->failure(); }
367 void close() { session_->close(); }
368 void shutdown() { session_->shutdown(); }
369
370 void save(std::string_view name) const { save(name, snapshot()); }
371 void save(std::string_view name, world_type const & state) const {
372 auto storage = store_type::open(root_);
373 storage.save(name, state.head());
374 }
375 std::optional<world_type> load(std::string_view name) const {
376 auto storage = store_type::open(root_);
377 auto saved = storage.find_save(name);
378 if (!saved) return std::nullopt;
379 auto world = connection_detail::restore_checkpoint<Core>(std::move(saved->snapshot), saved->semantic,
380 session_->snapshot()->world.metadata().schema_id);
381 return world_type(std::move(world), std::move(saved->head));
382 }
383 connection fork(std::string_view name) const { return fork(name, snapshot()); }
384 connection fork(std::string_view name, world_type const & state) const {
385 auto storage = store_type::open(root_);
386 (void)storage.fork(name, state.head());
387 auto options = options_;
388 options.create_if_missing = false;
389 options.schema_id = state.metadata().schema_id;
390 return connection(root_, name, std::move(options));
391 }
392 private:
394 if (!options.limits) {
395 std::uint64_t work = 128'000'000;
396 if constexpr (requires { Core::reservation_work(std::uint64_t{}); }) work = Core::reservation_work(1024);
397 options.limits = session_limits{work, 64 * 1024 * 1024, 64, 4096};
398 }
399 if (!options.limits->contributions || !options.limits->maintenance_budget)
400 throw std::invalid_argument("connection needs a positive contribution limit and maintenance budget");
401 return options;
402 }
403 std::filesystem::path root_;
405 std::shared_ptr<session_type> session_;
407 };
408
409 template <class Core = active_engine<>> connection<Core> connect(
410 std::filesystem::path const & root, std::string_view name, connection_options options = {}) {
411 return connection<Core>(root, name, std::move(options));
412 }
413
414 template <class P> std::size_t multiverse<P>::recover_transactions() const {
416 }
417
418 template <class P> auto multiverse<P>::connect(std::string_view name) const -> session {
419 return session(root(), name);
420 }
421 template <class P> auto multiverse<P>::connect(std::string_view name, connection_options const & options) const -> session {
422 return session(root(), name, options);
423 }
424}
425
426#include <everett/transaction.h>
Selects the charged runtime and streamed output used by ordinary named sessions.
Declares Everett's multiverse support.
void name(std::string_view value)
Definition sqlite_catalog.h:198
constexpr char schema[]
Definition sqlite_catalog.h:282
auto restore_checkpoint(typename Core::runtime_family::snapshot_type runtime, std::span< std::byte const > semantic, std::string_view schema)
Definition connection.h:67
typename sort_codec< S >::value_codec::value_type arrow_t
Definition typed_world.h:53
typename sort_codec< S >::key_codec::value_type key_t
Definition typed_world.h:52
typename sort_semantics< S >::state_type state_t
Definition typed_world.h:54
Definition active_engine.h:18
connection< Core > connect(std::filesystem::path const &root, std::string_view name, connection_options options={})
Definition connection.h:409
Keeps private transaction construction pinned until its last owner or crash recovery.
Encodes the full redundant frontier, including hidden completed artifacts and restart recipes.
Seals runtime frontiers and restores named sessions through immutable mappings.
Persists sort-owned native files behind the redundant runtime's exact checkpoints.
Definition sqlite_catalog.h:92
std::string operation
Definition sqlite_catalog.h:97
Definition sqlite_catalog.h:76
Definition connection.h:37
bool create_if_missing
Definition connection.h:41
std::optional< session_limits > limits
Definition connection.h:44
std::string schema_id
Definition connection.h:40
Definition connection.h:294
typename Core::policy_type policy_type
Definition connection.h:296
transaction_type begin()
Definition transaction.h:234
connection(connection &&)=delete
connection(std::filesystem::path const &root, std::string_view name, connection_options options={})
Definition connection.h:306
world_type apply(C &&value)
Definition connection.h:362
session_reservation outstanding() const
Definition connection.h:364
std::optional< world_type > load(std::string_view name) const
Definition connection.h:375
bool cancel(ticket const &value)
Definition connection.h:363
static connection_options checked_options(connection_options options)
Definition connection.h:393
std::uint64_t pending_count() const
Definition connection.h:365
connection fork(std::string_view name, world_type const &state) const
Definition connection.h:384
void close()
Definition connection.h:367
persistent_engine< Core > engine_type
Definition connection.h:297
void save(std::string_view name) const
Definition connection.h:370
std::filesystem::path const & root() const &noexcept
Definition connection.h:319
std::filesystem::path const & root() const &&=delete
connection & operator=(connection const &)=delete
ticket erase_range_async(std::optional< typed_detail::key_t< S > > lo={}, std::optional< typed_detail::key_t< S > > hi={})
Definition connection.h:330
friend transaction_type
Definition connection.h:406
transaction< Core > transaction_type
Definition connection.h:301
connection fork(std::string_view name) const
Definition connection.h:383
void save(std::string_view name, world_type const &state) const
Definition connection.h:371
world_type erase(typed_detail::key_t< S > const &key)
Definition connection.h:341
ticket erase_async(typed_detail::key_t< S > const &key)
Definition connection.h:350
world_type put(typed_detail::key_t< S > const &key, typed_detail::state_t< S > const &value)
Definition connection.h:338
typename Core::contribution_type contribution_type
Definition connection.h:300
connection(connection const &)=delete
world_type erase_range(std::optional< typed_detail::key_t< S > > lo={}, std::optional< typed_detail::key_t< S > > hi={})
Definition connection.h:325
void shutdown()
Definition connection.h:368
std::filesystem::path root_
Definition connection.h:403
publication_type publication() const noexcept
Definition connection.h:318
ticket change_async(typed_detail::key_t< S > const &key, typed_detail::arrow_t< S > const &arrow)
Definition connection.h:352
connection_options options_
Definition connection.h:404
session_limits limits() const noexcept
Definition connection.h:317
auto range(std::optional< typed_detail::key_t< S > > lo={}, std::optional< typed_detail::key_t< S > > hi={}) const
Definition connection.h:321
typename session_type::ticket ticket
Definition connection.h:302
std::optional< ticket > try_submit(C &&value)
Definition connection.h:358
session< engine_type > session_type
Definition connection.h:298
typename engine_type::world_type world_type
Definition connection.h:299
std::exception_ptr failure() const
Definition connection.h:366
Core core_type
Definition connection.h:295
~connection()
Definition connection.h:314
ticket submit(C &&value)
Definition connection.h:360
typename session_type::snapshot_type publication_type
Definition connection.h:303
world_type snapshot() const
Definition connection.h:316
connection & operator=(connection &&)=delete
world_type change(typed_detail::key_t< S > const &key, typed_detail::arrow_t< S > const &arrow)
Definition connection.h:343
auto get(typed_detail::key_t< S > const &key) const
Definition connection.h:335
ticket put_async(typed_detail::key_t< S > const &key, typed_detail::state_t< S > const &value)
Definition connection.h:347
std::shared_ptr< session_type > session_
Definition connection.h:405
session connect(std::string_view name) const
Definition connection.h:418
std::size_t recover_transactions() const
Definition connection.h:414
ordinary_contribution const * copy
Definition connection.h:98
ordinary_contribution * move
Definition connection.h:98
contribution_type & operator=(contribution_type const &)=delete
contribution_type & operator=(contribution_type &&)=delete
contribution_type(contribution_type const &)=delete
static auto take(contribution_type &other) -> value_type
Definition connection.h:115
std::variant< ordinary_contribution, prepared_transaction, borrowed > value_type
Definition connection.h:99
contribution_type(prepared_transaction input)
Definition connection.h:102
contribution_type(borrowed input)
Definition connection.h:103
value_type value
Definition connection.h:100
contribution_type(ordinary_contribution input)
Definition connection.h:101
static contribution_type borrow(C &&input)
Definition connection.h:109
contribution_type(contribution_type &&other)
Definition connection.h:106
std::shared_ptr< private_construction< policy_type > > scope
Definition connection.h:88
std::unique_ptr< Core > core
Definition connection.h:90
prepared_transaction(std::unique_ptr< Core > candidate, world_type original, std::shared_ptr< private_construction< policy_type > > lease)
Definition connection.h:91
world_type base
Definition connection.h:89
Definition connection.h:80
std::unique_ptr< Core > core_
Definition connection.h:224
void remember_failure() noexcept
Definition connection.h:277
static store_type open_store(std::filesystem::path const &root, bool create, Ids ids)
Definition connection.h:232
void poison() noexcept
Definition connection.h:285
void require_active() const
Definition connection.h:284
world_type contribute(contribution_type input)
Definition connection.h:184
typename Core::contribution_type ordinary_contribution
Definition connection.h:86
persistent_engine(store_type store, Core core, world_type current, std::string schema)
Definition connection.h:230
bool failed() const noexcept
Definition connection.h:172
world_type contribute_ordinary(ordinary_contribution input)
Definition connection.h:192
std::string const & last_operation() const noexcept
Definition connection.h:175
world_type current_
Definition connection.h:225
static persistent_engine connect(std::filesystem::path const &root, std::string_view name, connection_options const &options={}, Ids ids={})
Definition connection.h:130
bool admission_ready() const noexcept
Definition connection.h:174
world_type publish(typed_world_type updated, bool mutation)
Definition connection.h:243
persistent_engine(persistent_engine const &)=delete
world_type install(prepared_transaction input)
Definition connection.h:257
static contribution_type borrow_contribution(C &&input)
Definition connection.h:160
persistent_engine & operator=(persistent_engine const &)=delete
typename Core::metadata_type metadata_type
Definition connection.h:125
Core core_type
Definition connection.h:81
typename Core::runtime_family family_type
Definition connection.h:82
std::shared_ptr< private_construction< policy_type > > core_scope_
Definition connection.h:223
std::exception_ptr catalog_failure_
Definition connection.h:227
store_type store_
Definition connection.h:222
world_type snapshot() const
Definition connection.h:171
bool pending() const noexcept
Definition connection.h:173
static session_reservation reservation(contribution_type const &input)
Definition connection.h:163
typename Core::policy_type policy_type
Definition connection.h:83
stored_world< typed_world_type > world_type
Definition connection.h:85
static world_type restore(typename store_type::stored_type saved, std::string_view schema, std::shared_ptr< connection_detail::logical_state const > logical=std::make_shared< connection_detail::logical_state >())
Definition connection.h:238
std::optional< world_type > advance(std::uint64_t budget)
Definition connection.h:212
typename Core::world_type typed_world_type
Definition connection.h:84
bool failed_
Definition connection.h:228
std::string schema_
Definition connection.h:226
persistent_engine(persistent_engine &&) noexcept(std::is_nothrow_move_constructible_v< store_type > &&std::is_nothrow_move_constructible_v< Core > &&std::is_nothrow_move_constructible_v< world_type >)=default
Definition private_construction.h:27
static std::size_t recover(std::filesystem::path const &root)
Definition private_construction.h:55
Definition runtime_store.h:58
stored_type publish(catalog_session_head const &expected, snapshot_type const &source, std::span< std::byte const > semantic={})
Definition runtime_store.h:122
static runtime_store open(std::filesystem::path const &root, Ids ids={}, catalog_options options={}, Ops ops={})
Definition runtime_store.h:79
bool failed() const noexcept
Definition runtime_store.h:89
std::string const & last_operation() const noexcept
Definition runtime_store.h:146
static runtime_store create(std::filesystem::path const &root, Ids ids={}, catalog_options options={}, Ops ops={})
Definition runtime_store.h:74
Definition session.h:89
Definition session.h:39
Definition session.h:33
Definition session.h:71
std::shared_ptr< publication const > snapshot_type
Definition session.h:82
Definition runtime_store.h:49
catalog_session_head head
Definition runtime_store.h:50
Family::snapshot_type snapshot
Definition runtime_store.h:51
std::vector< std::byte > semantic
Definition runtime_store.h:52
Definition connection.h:54
std::shared_ptr< catalog_session_head const > head_
Definition connection.h:62
auto logical_identity() const noexcept
Definition connection.h:60
catalog_session_head const & head() const &&=delete
std::shared_ptr< connection_detail::logical_state const > logical_
Definition connection.h:63
catalog_session_head const & head() const &noexcept
Definition connection.h:58
stored_world(World value, catalog_session_head head, std::shared_ptr< connection_detail::logical_state const > logical=std::make_shared< connection_detail::logical_state >())
Definition connection.h:55
Definition connection.h:50
transaction_conflict()
Definition connection.h:51
Definition transaction.h:28
Definition multiverse.h:41
Private typed nurseries, persistent read snapshots and checked durable commit.
Scans one sort in an immutable typed world with chronological resolution.
Connects sort-owned semantics to encoded COLA updates and immutable typed snapshots.