Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
file_journal.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <cstddef>
7#include <cstdint>
8#include <filesystem>
9#include <memory>
10#include <optional>
11
12namespace pulp::timeline {
13
17
31
38 std::uint64_t byte_offset = 0;
39 std::optional<PersistenceError> persistence_error;
40};
41
44 std::uint64_t max_file_bytes = 8ull * 1024ull * 1024ull * 1024ull;
45 std::size_t max_record_bytes = 1024ull * 1024ull * 1024ull;
47};
48
49class FileJournal;
50
58 std::shared_ptr<FileJournal> sink;
61 bool recovered_existing = false;
62 bool repaired_torn_tail = false;
63};
64
74class FileJournal final : public JournalSink {
75 public:
87 open(const std::filesystem::path& path, Project fallback, SchemaRegistry registry,
88 const FileJournalLimits& limits = {});
89
91 ~FileJournal() override;
92
93 FileJournal(const FileJournal&) = delete;
95
98 append_batch(const JournalEntry& entry) noexcept override;
101 checkpoint(const Project& snapshot, DocumentRevision durable_revision) noexcept override;
106 validate_restore(const Project& snapshot, DocumentRevision durable_revision) noexcept override;
107
108 private:
109 struct Impl;
110 explicit FileJournal(std::unique_ptr<Impl> impl);
111 std::unique_ptr<Impl> impl_;
112};
113
115
116} // namespace pulp::timeline
Result<T, E> — either holds a T or an E, never both.
Definition result.hpp:76
Native, crash-consistent Timeline persistence sink.
Definition file_journal.hpp:74
FileJournal & operator=(const FileJournal &)=delete
static runtime::Result< FileJournalOpenResult, FileJournalError > open(const std::filesystem::path &path, Project fallback, SchemaRegistry registry, const FileJournalLimits &limits={})
Opens, creates, or recovers a journal at path.
runtime::Result< bool, JournalSinkError > validate_restore(const Project &snapshot, DocumentRevision durable_revision) noexcept override
Compares snapshot and revision with the sink's recovered durable state.
FileJournal(const FileJournal &)=delete
runtime::Result< bool, JournalSinkError > append_batch(const JournalEntry &entry) noexcept override
Durably appends the entry's resulting canonical snapshot frame.
runtime::Result< bool, JournalSinkError > checkpoint(const Project &snapshot, DocumentRevision durable_revision) noexcept override
Atomically replaces durable history with snapshot at durable_revision.
~FileJournal() override
Flushes no additional state and releases the file and lifetime locks.
JournalSink(const JournalSink &)=delete
Immutable root of a Timeline document and its monotonic identity domain.
Definition model.hpp:1079
Immutable, shareable registry of Timeline schema contracts.
Definition schema_registry.hpp:189
@ UnsupportedVersion
The Project major version is unsupported.
Definition dawproject_import.hpp:42
@ LimitExceeded
A configured import resource limit was exceeded.
Definition dawproject_import.hpp:50
FileJournalErrorCode
File-journal open or recovery failure category.
Definition file_journal.hpp:19
@ AlreadyOpen
Definition file_journal.hpp:27
@ AliasedPath
Definition file_journal.hpp:28
@ DurabilityUncertain
Definition file_journal.hpp:29
@ RevisionMismatch
Definition file_journal.hpp:24
@ CorruptRecord
Definition file_journal.hpp:23
@ InvalidFormat
Definition file_journal.hpp:21
@ IoError
Definition file_journal.hpp:20
Definition program_compiler.hpp:18
Parser, migration, opaque-payload, and Timeline structure quotas.
Definition schema_json.hpp:78
Monotonic document snapshot revision used for optimistic admission.
Definition command.hpp:54
File-journal failure with the offending byte and nested JSON error.
Definition file_journal.hpp:36
std::uint64_t byte_offset
Definition file_journal.hpp:38
std::optional< PersistenceError > persistence_error
Definition file_journal.hpp:39
FileJournalErrorCode code
Definition file_journal.hpp:37
File size, record size, and nested decode ceilings.
Definition file_journal.hpp:43
DecodeLimits decode
Definition file_journal.hpp:46
std::uint64_t max_file_bytes
Definition file_journal.hpp:44
std::size_t max_record_bytes
Definition file_journal.hpp:45
Result of opening or recovering a native Timeline journal.
Definition file_journal.hpp:57
bool repaired_torn_tail
Definition file_journal.hpp:62
DocumentRevision revision
Definition file_journal.hpp:60
std::shared_ptr< FileJournal > sink
Definition file_journal.hpp:58
Project checkpoint
Definition file_journal.hpp:59
bool recovered_existing
Definition file_journal.hpp:61
One contiguous revision transition retained by the command journal.
Definition journal.hpp:37
Structured persistence failure.
Definition schema_json.hpp:46