|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
Registry of payload migrations, keyed by (actionType, fromSchema). More...
#include <journal.hpp>
Public Types | |
| using | Migration = std::function<std::string(std::string_view)> |
| Rewrites one recorded payload JSON into the current shape. | |
Public Member Functions | |
| void | add (std::string_view actionType, std::string_view fromSchema, Migration migration) |
Registers migration for entries of actionType stamped with fromSchema. Replaces any migration already registered for that exact pair. | |
| const Migration * | find (std::string_view actionType, std::string_view fromSchema) const |
| Looks up the migration for (actionType, fromSchema). | |
| void | clear () |
| Removes every registered migration. | |
| std::size_t | size () const noexcept |
| Returns how many migrations are registered. | |
Registry of payload migrations, keyed by (actionType, fromSchema).
The escape hatch that makes "refuse on mismatch" a livable contract rather than a one-way door. A migration is a pure function over the recorded payload JSON: given the bytes an older build wrote, return the bytes this build's ActionTraits<A>::fromJson should see. Reconstruction applies it in memory only — the journal on disk is never rewritten, so the recorded history stays exactly what was recorded and the migration stays reviewable as code.
Definition at line 107 of file journal.hpp.
| using morph::journal::PayloadMigrationRegistry::Migration = std::function<std::string(std::string_view)> |
Rewrites one recorded payload JSON into the current shape.
Definition at line 110 of file journal.hpp.
|
inline |
Registers migration for entries of actionType stamped with fromSchema. Replaces any migration already registered for that exact pair.
| actionType | LogEntry::actionType the migration applies to. |
| fromSchema | LogEntry::schema value the migration reads. |
| migration | Payload rewriter. |
Definition at line 118 of file journal.hpp.
|
inlinenodiscard |
Looks up the migration for (actionType, fromSchema).
Returns a pointer into the registry, valid until the entry is replaced or the registry is destroyed (std::unordered_map does not invalidate references to surviving elements on rehash).
| actionType | LogEntry::actionType to match. |
| fromSchema | LogEntry::schema to match. |
Definition at line 131 of file journal.hpp.
|
inline |
Removes every registered migration.
Definition at line 138 of file journal.hpp.
|
inlinenodiscardnoexcept |
Returns how many migrations are registered.
Definition at line 142 of file journal.hpp.